2017-03-07 11:10:22 +03:00
|
|
|
import QtQuick 2.5
|
2017-02-10 14:44:10 +03:00
|
|
|
import QtQuick.Controls 1.4
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import QtQuick.Controls.Styles 1.4
|
|
|
|
import QtQuick.Dialogs 1.2
|
|
|
|
|
2017-03-08 12:21:25 +03:00
|
|
|
DefaultDialog {
|
2017-02-10 16:01:49 +03:00
|
|
|
id: setPasswordPrompt
|
2017-02-10 14:44:10 +03:00
|
|
|
title: qsTr("Set new password")
|
2017-02-15 17:14:34 +03:00
|
|
|
modality: Qt.ApplicationModal
|
2017-02-16 17:22:20 +03:00
|
|
|
property string newPassword: newPassword.text
|
2017-03-16 18:34:00 +03:00
|
|
|
property bool matchingPasswords: newPassword.text === confirmPassword.text
|
2017-11-07 12:34:42 +03:00
|
|
|
property bool remember: rememberPassword.checked
|
2017-04-07 13:31:39 +03:00
|
|
|
|
|
|
|
onVisibilityChanged: {
|
|
|
|
// Clear the password from old canceled entries
|
|
|
|
// when a new dialog is shown.
|
|
|
|
if (visible) {
|
|
|
|
clear()
|
|
|
|
}
|
|
|
|
}
|
2017-02-10 14:44:10 +03:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
Label {
|
|
|
|
text: qsTr("New password (blank for none): ")
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: false
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: newPassword
|
2017-03-18 20:21:03 +03:00
|
|
|
focus: true
|
2017-02-10 14:44:10 +03:00
|
|
|
echoMode: TextInput.Password
|
|
|
|
Layout.fillWidth: true
|
2017-03-18 20:21:03 +03:00
|
|
|
KeyNavigation.tab: confirmPassword
|
2017-03-17 17:47:24 +03:00
|
|
|
Keys.onEscapePressed: close()
|
2017-02-10 14:44:10 +03:00
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: qsTr("Confirm password: ")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: confirmPassword
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
Layout.fillWidth: true
|
2017-03-14 12:40:00 +03:00
|
|
|
onAccepted: promptAccepted()
|
2017-11-07 12:34:42 +03:00
|
|
|
KeyNavigation.tab: rememberPassword
|
|
|
|
Keys.onEscapePressed: close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
CheckBox {
|
|
|
|
id: rememberPassword
|
|
|
|
text: qsTr("Remember password")
|
2017-03-18 20:21:03 +03:00
|
|
|
KeyNavigation.tab: setPasswordBtn
|
2017-03-17 17:47:24 +03:00
|
|
|
Keys.onEscapePressed: close()
|
2017-02-10 14:44:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
|
|
|
Button {
|
2017-03-18 20:21:03 +03:00
|
|
|
id: setPasswordBtn
|
2017-02-10 14:44:10 +03:00
|
|
|
text: qsTr("Set password")
|
2017-03-16 18:34:00 +03:00
|
|
|
enabled: matchingPasswords
|
2017-02-10 14:44:10 +03:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
2017-03-14 12:40:00 +03:00
|
|
|
onClicked: promptAccepted()
|
2017-03-18 20:21:03 +03:00
|
|
|
KeyNavigation.tab: cancelBtn
|
|
|
|
Keys.onEscapePressed: close()
|
2017-02-10 14:44:10 +03:00
|
|
|
}
|
|
|
|
Button {
|
2017-03-18 20:21:03 +03:00
|
|
|
id: cancelBtn
|
2017-02-10 14:44:10 +03:00
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: close()
|
2017-03-18 20:21:03 +03:00
|
|
|
KeyNavigation.tab: newPassword
|
|
|
|
Keys.onEscapePressed: close()
|
2017-02-10 14:44:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-14 12:40:00 +03:00
|
|
|
function promptAccepted() {
|
2017-03-16 18:34:00 +03:00
|
|
|
if (matchingPasswords) {
|
|
|
|
close()
|
|
|
|
accepted()
|
|
|
|
}
|
2017-03-14 12:40:00 +03:00
|
|
|
}
|
2017-03-18 20:27:40 +03:00
|
|
|
|
|
|
|
function clear() {
|
|
|
|
newPassword.text = ""
|
|
|
|
confirmPassword.text = ""
|
|
|
|
}
|
2017-02-10 14:44:10 +03:00
|
|
|
}
|