2019-02-05 00:41:18 +00:00
|
|
|
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
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2020-05-20 20:49:00 +00:00
|
|
|
import "../opaque" as Opaque
|
2020-05-20 00:03:08 +00:00
|
|
|
import "../opaque/styles"
|
|
|
|
import "../opaque/theme"
|
2020-06-23 23:42:51 +00:00
|
|
|
import "../const"
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
Opaque.SettingsList { // settingsPane
|
2019-04-16 19:40:19 +00:00
|
|
|
id: root
|
2020-04-27 21:55:10 +00:00
|
|
|
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
|
2020-06-23 23:42:51 +00:00
|
|
|
property string authorization
|
2020-07-07 20:57:38 +00:00
|
|
|
property string saveHistory
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2020-11-23 20:50:06 +00:00
|
|
|
Column {
|
|
|
|
id: peerSettings
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width:parent.width -20
|
|
|
|
parent: root.contentItem
|
2020-04-27 21:55:10 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
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()
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2019-02-05 00:41:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
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)
|
2020-07-25 16:47:19 +00:00
|
|
|
toolbar.setTitle(txtDisplayName.text)
|
2020-11-26 22:09:12 +00:00
|
|
|
|
|
|
|
// 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")
|
2020-05-26 18:21:27 +00:00
|
|
|
theStack.pane = theStack.messagePane
|
2020-11-26 22:09:12 +00:00
|
|
|
mm.setHandle(txtOnion.text)
|
|
|
|
gcd.loadMessagesPane(txtOnion.text)
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2019-08-07 02:14:40 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
Opaque.Setting {
|
|
|
|
label: qsTr("block-btn")
|
2020-04-27 18:31:53 +00:00
|
|
|
|
2020-04-29 19:40:13 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
field: Opaque.ToggleSwitch {
|
|
|
|
anchors.right: parent.right
|
2020-04-29 19:40:13 +00:00
|
|
|
|
2020-06-23 23:42:51 +00:00
|
|
|
isToggled: root.authorization == Const.auth_blocked
|
2020-05-26 18:21:27 +00:00
|
|
|
onToggled: function() {
|
2020-06-23 23:42:51 +00:00
|
|
|
if (root.authorization == Const.auth_blocked) {
|
|
|
|
root.authorization = Const.auth_unknown
|
|
|
|
gcd.setPeerAuthorization(txtOnion.text, Const.auth_unknown)
|
2020-05-26 18:21:27 +00:00
|
|
|
} else {
|
2020-06-23 23:42:51 +00:00
|
|
|
root.authorization = Const.auth_blocked
|
|
|
|
gcd.setPeerAuthorization(txtOnion.text, Const.auth_blocked)
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2020-06-23 23:42:51 +00:00
|
|
|
isToggled = root.authorization == Const.auth_blocked
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2020-04-27 18:31:53 +00:00
|
|
|
}
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2019-08-07 02:14:40 +00:00
|
|
|
|
2020-07-07 20:57:38 +00:00
|
|
|
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 {
|
2020-08-24 22:01:00 +00:00
|
|
|
gcd.deleteHistoryForPeer(txtOnion.text)
|
2020-07-07 20:57:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
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
|
|
|
|
2019-02-13 07:09:39 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
onClicked: {
|
|
|
|
gcd.deleteContact(txtOnion.text)
|
|
|
|
theStack.pane = theStack.emptyPane
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2019-02-13 07:09:39 +00:00
|
|
|
|
2020-05-26 18:21:27 +00:00
|
|
|
}
|
2019-02-12 22:47:23 +00:00
|
|
|
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
Connections {
|
|
|
|
target: gcd
|
2019-02-05 00:41:18 +00:00
|
|
|
|
2020-07-07 20:57:38 +00:00
|
|
|
onSupplyPeerSettings: function(onion, nick, authorization, saveHistory) {
|
2020-04-27 21:55:10 +00:00
|
|
|
txtOnion.text = onion
|
|
|
|
txtDisplayName.text = nick
|
2020-06-23 23:42:51 +00:00
|
|
|
root.authorization = authorization
|
2020-07-07 20:57:38 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-27 18:31:53 +00:00
|
|
|
|
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|