303 lines
7.6 KiB
QML
303 lines
7.6 KiB
QML
import QtGraphicalEffects 1.0
|
|
import QtQuick 2.7
|
|
import QtQuick.Controls 2.13
|
|
import QtQuick.Controls.Material 2.0
|
|
import QtQuick.Layouts 1.3
|
|
import QtQuick.Window 2.11
|
|
|
|
|
|
import "../widgets" as Widgets
|
|
// import "../styles"
|
|
|
|
ColumnLayout { // Add Profile Pane
|
|
id: profileAddEditPane
|
|
anchors.fill: parent
|
|
|
|
property string mode // edit or add
|
|
property string onion
|
|
property string tag
|
|
property bool deleting
|
|
property bool changingPassword
|
|
|
|
Widgets.StackToolbar {
|
|
id: stb
|
|
text: mode == "add" ? qsTr("add-profile-title") : qsTr("edit-profile-title")
|
|
aux.visible: false
|
|
membership.visible: false
|
|
stack: "management"
|
|
}
|
|
|
|
function reset() {
|
|
mode = "add"
|
|
txtProfileName.text = qsTr("default-profile-name")
|
|
changingPassword = false
|
|
txtPassword1.text = ""
|
|
txtPassword2.text = ""
|
|
deleting = false
|
|
deleteConfirmLabel.color = "black"
|
|
passwordErrorLabel.visible = false
|
|
txtCurrentPassword.text = ""
|
|
|
|
tag = ""
|
|
confirmDeleteTxt.text = ""
|
|
radioUsePassword.checked = true
|
|
passwordChangeErrorLabel.visible = false
|
|
}
|
|
|
|
function load(userOnion, name, userTag) {
|
|
reset()
|
|
|
|
mode = "edit"
|
|
tag = userTag
|
|
onion = userOnion
|
|
txtPassword1.text = ""
|
|
txtPassword2.text = ""
|
|
onionLabel.text = onion
|
|
txtProfileName.text = name
|
|
|
|
if (tag == "v1-defaultPassword" || tag == "v1-default-password") {
|
|
radioNoPassword.checked = true
|
|
} else {
|
|
radioUsePassword.checked = true
|
|
}
|
|
}
|
|
|
|
|
|
Flickable {
|
|
anchors.top: stb.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
clip:true
|
|
contentWidth: tehcol.width
|
|
contentHeight: tehcol.height
|
|
|
|
Column {
|
|
id: tehcol
|
|
leftPadding: 10
|
|
spacing: 5
|
|
width: profileAddEditPane.width
|
|
|
|
Widgets.ScalingLabel {
|
|
//: Onion
|
|
text: qsTr("profile-onion-label") + ":"
|
|
visible: mode == "edit"
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: onionLabel
|
|
visible: mode == "edit"
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
//: Display name
|
|
text: qsTr("profile-name") + ":"
|
|
}
|
|
|
|
Widgets.TextField {
|
|
id: txtProfileName
|
|
Layout.fillWidth: true
|
|
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
|
//: default suggested profile name
|
|
text: qsTr("default-profile-name")
|
|
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
//id: radioButtons
|
|
|
|
Widgets.RadioButton {
|
|
id: radioUsePassword
|
|
checked: true
|
|
//: Password
|
|
text: qsTr("radio-use-password")
|
|
visible: mode == "add" || tag == "v1-defaultPassword"
|
|
onClicked: {
|
|
changingPassword = true
|
|
}
|
|
}
|
|
|
|
Widgets.RadioButton {
|
|
id: radioNoPassword
|
|
//: Unencrypted (No password)
|
|
text: qsTr("radio-no-password")
|
|
visible: mode == "add" || tag == "v1-defaultPassword"
|
|
onClicked: {
|
|
changingPassword = true
|
|
}
|
|
}
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: noPasswordLabel
|
|
//: Not using a password on this account means that all data stored locally will not be encrypted
|
|
text: qsTr("no-password-warning")
|
|
visible: radioNoPassword.checked
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: currentPasswordLabel
|
|
//: Current Password
|
|
text: qsTr("current-password-label") + ":"
|
|
visible: radioUsePassword.checked && mode == "edit" && tag != "v1-defaultPassword"
|
|
}
|
|
|
|
Widgets.TextField {
|
|
id: txtCurrentPassword
|
|
Layout.fillWidth: true
|
|
echoMode: TextInput.Password
|
|
visible: radioUsePassword.checked && mode == "edit" && tag != "v1-defaultPassword"
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: passwordLabel
|
|
//: Password
|
|
text: qsTr("password1-label") + ":"
|
|
visible: radioUsePassword.checked
|
|
}
|
|
|
|
Widgets.TextField {
|
|
id: txtPassword1
|
|
Layout.fillWidth: true
|
|
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
|
echoMode: TextInput.Password
|
|
visible: radioUsePassword.checked
|
|
|
|
onTextEdited: {
|
|
changingPassword = true
|
|
}
|
|
}
|
|
|
|
|
|
Widgets.ScalingLabel {
|
|
id: passwordReLabel
|
|
//: Reenter password
|
|
text: qsTr("password2-label") + ":"
|
|
visible: radioUsePassword.checked
|
|
}
|
|
|
|
Widgets.TextField {
|
|
id: txtPassword2
|
|
Layout.fillWidth: true
|
|
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
|
echoMode: TextInput.Password
|
|
visible: radioUsePassword.checked
|
|
}
|
|
|
|
Widgets.SimpleButton { // ADD or SAVE button
|
|
//: Create Profile || Save Profile
|
|
text: mode == "add" ? qsTr("create-profile-btn") : qsTr("save-profile-btn")
|
|
|
|
onClicked: {
|
|
if (mode == "add") {
|
|
if (txtPassword1.text != txtPassword2.text) {
|
|
passwordErrorLabel.visible = true
|
|
} else {
|
|
gcd.createProfile(txtProfileName.text, radioNoPassword.checked, txtPassword1.text)
|
|
gcd.reloadProfileList()
|
|
parentStack.pane = parentStack.managementPane
|
|
}
|
|
} else {
|
|
gcd.updateNick(onion, txtProfileName.text)
|
|
|
|
if (changingPassword) {
|
|
if (txtPassword1.text != txtPassword2.text) {
|
|
passwordErrorLabel.visible = true
|
|
} else {
|
|
gcd.changePassword(onion, txtCurrentPassword.text, txtPassword1.text, radioNoPassword.checked)
|
|
}
|
|
} else {
|
|
gcd.reloadProfileList()
|
|
parentStack.pane = parentStack.managementPane
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: passwordErrorLabel
|
|
//: Passwords do not match
|
|
text: qsTr("password-error-match")
|
|
visible: false
|
|
color: "red"
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: passwordChangeErrorLabel
|
|
//: Error changing password: Supplied password rejected
|
|
text: qsTr("password-change-error")
|
|
visible: false
|
|
color: "red"
|
|
}
|
|
|
|
// ***** Delete button and confirm flow *****
|
|
|
|
Widgets.SimpleButton {
|
|
//: Delete Profile
|
|
text: qsTr("delete-profile-btn")
|
|
icon: "regular/trash-alt"
|
|
visible: mode == "edit"
|
|
|
|
|
|
onClicked: {
|
|
deleting = true
|
|
}
|
|
}
|
|
|
|
Widgets.ScalingLabel {
|
|
id: deleteConfirmLabel
|
|
//: Type DELETE to confirm
|
|
text: qsTr("delete-confirm-label")+ ":"
|
|
visible: deleting
|
|
}
|
|
|
|
Widgets.TextField {
|
|
id: confirmDeleteTxt
|
|
Layout.fillWidth: true
|
|
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
|
visible: deleting
|
|
}
|
|
|
|
Widgets.SimpleButton {
|
|
id: confirmDeleteBtn
|
|
icon: "regular/trash-alt"
|
|
|
|
//: Really Delete Profile
|
|
text: qsTr("delete-profile-confirm-btn")
|
|
color: "red"
|
|
visible: deleting
|
|
|
|
onClicked: {
|
|
//: DELETE
|
|
if (confirmDeleteTxt.text == qsTr("delete-confirm-text")) {
|
|
deleteConfirmLabel.color = "black"
|
|
gcd.deleteProfile(onion)
|
|
gcd.reloadProfileList()
|
|
parentStack.pane = parentStack.managementPane
|
|
} else {
|
|
deleteConfirmLabel.color = "red"
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}//end of column with padding
|
|
}//end of flickable
|
|
|
|
Connections { // UPDATE UNREAD MESSAGES COUNTER
|
|
target: gcd
|
|
|
|
onChangePasswordResponse: function(error) {
|
|
if (!error) {
|
|
gcd.reloadProfileList()
|
|
parentStack.pane = parentStack.managementPane
|
|
} else {
|
|
passwordChangeErrorLabel.visible = true
|
|
}
|
|
}
|
|
}
|
|
} |