This repository has been archived on 2021-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ui/qml/panes/PeerSettingsPane.qml

167 lines
5.4 KiB
QML
Raw Normal View History

import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.11
2019-02-12 22:47:23 +00:00
import QtQuick.Controls 1.4
2020-04-29 19:40:13 +00:00
import QtQuick.Controls.Styles 1.4
import "../opaque" as Opaque
import "../opaque/styles"
import "../opaque/theme"
import "../const"
Opaque.SettingsList { // settingsPane
2019-04-16 19:40:19 +00:00
id: root
anchors.fill: parent
2020-10-19 22:46:40 +00:00
anchors.topMargin: 20
2020-11-23 20:50:06 +00:00
width: parent.width
height: parent.height
contentHeight: peerSettings.height + 20
property string authorization
property string saveHistory
2020-11-23 20:50:06 +00:00
Column {
id: peerSettings
anchors.horizontalCenter: parent.horizontalCenter
width:parent.width -20
parent: root.contentItem
Opaque.Setting {
inline: false
label: qsTr("address-label")
field: Opaque.ButtonTextField {
id: txtOnion
readOnly: true
button_text: qsTr("copy-btn")
dropShadowColor: Theme.dropShadowPaneColor
onClicked: {
//: notification: copied to clipboard
gcd.popup(qsTr("copied-to-clipboard-notification"))
txtOnion.selectAll()
txtOnion.copy()
}
}
}
Opaque.Setting {
inline: false
label: qsTr("display-name-label")
field: Opaque.ButtonTextField {
id: txtDisplayName
button_text: qsTr("save-btn")
dropShadowColor: Theme.dropShadowPaneColor
onClicked: {
gcd.savePeerSettings(txtOnion.text, txtDisplayName.text)
toolbar.setTitle(txtDisplayName.text)
// FIXME this is kind of a hack as ideally we could just update the peer name
// and have that change broadcast to each message - but there isn't an easy way to do that
// with our current message model setup. As such we simply reset and reload the message pane
gcd.broadcast("ResetMessagePane")
theStack.pane = theStack.messagePane
mm.setHandle(txtOnion.text)
gcd.loadMessagesPane(txtOnion.text)
}
}
}
Opaque.Setting {
label: qsTr("block-btn")
2020-04-29 19:40:13 +00:00
field: Opaque.ToggleSwitch {
anchors.right: parent.right
2020-04-29 19:40:13 +00:00
isToggled: root.authorization == Const.auth_blocked
onToggled: function() {
if (root.authorization == Const.auth_blocked) {
root.authorization = Const.auth_unknown
gcd.setPeerAuthorization(txtOnion.text, Const.auth_unknown)
} else {
root.authorization = Const.auth_blocked
gcd.setPeerAuthorization(txtOnion.text, Const.auth_blocked)
}
isToggled = root.authorization == Const.auth_blocked
}
}
}
Opaque.Setting {
//: Save Peer History
label: qsTr("save-peer-history")
description: qsTr("save-peer-history-description")
field: Opaque.ComboBox {
id: cbSaveHistory
anchors.right: parent.right
anchors.left: parent.left
model: ListModel {
id: cbSaveHistoryItems
ListElement { text: qsTr("dont-save-peer-history"); value: "DeleteHistoryConfirmed" }
ListElement { text: qsTr("save-peer-history"); value: "SaveHistory" }
}
onActivated: {
var item = cbSaveHistoryItems.get(cbSaveHistory.currentIndex)
if (item["value"] == "SaveHistory") {
gcd.storeHistoryForPeer(txtOnion.text)
} else {
gcd.deleteHistoryForPeer(txtOnion.text)
}
}
}
}
Column {
width:parent.width * 0.95
anchors.horizontalCenter: parent.horizontalCenter
Opaque.Button {
icon: "regular/trash-alt"
text: qsTr("delete-btn")
anchors.right: parent.right
2020-04-28 18:47:40 +00:00
onClicked: {
gcd.deleteContact(txtOnion.text)
theStack.pane = theStack.emptyPane
}
}
}
}
2019-02-12 22:47:23 +00:00
Connections {
target: gcd
onSupplyPeerSettings: function(onion, nick, authorization, saveHistory) {
txtOnion.text = onion
txtDisplayName.text = nick
root.authorization = authorization
root.saveHistory = saveHistory
// This will not set the value in the default case where saveHistory = DefaultDeleteHistory and thus
// the combobox will default to showing DeleteHistoryConfirmed
for (var i=0; i < cbSaveHistoryItems.count; i++) {
var item = cbSaveHistoryItems.get(i)
if (item["value"] == root.saveHistory || (root.saveHistory == "DefaultDeleteHistory" && item["value"] == "DeleteHistoryConfirmed")) {
cbSaveHistory.currentIndex = i
break
}
}
}
}
}