Files
purple-electrumwallet/electrum/gui/qml/components/PasswordDialog.qml
T

117 lines
3.1 KiB
QML
Raw Normal View History

2023-07-17 10:49:06 +02:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
2022-06-21 14:11:03 +02:00
import org.electrum 1.0
2022-07-26 10:45:22 +02:00
import "controls"
ElDialog {
2022-06-21 14:11:03 +02:00
id: passworddialog
title: qsTr("Enter Password")
iconSource: Qt.resolvedUrl('../../icons/lock.png')
2022-06-21 14:11:03 +02:00
property bool confirmPassword: false
property string infotext
property string errorMessage
signal passwordEntered(string password)
2022-06-21 14:11:03 +02:00
2022-10-19 14:15:24 +02:00
anchors.centerIn: parent
width: parent.width * 4/5
2022-10-19 14:15:24 +02:00
padding: 0
needsSystemBarPadding: false
2022-10-19 14:15:24 +02:00
2022-06-21 14:11:03 +02:00
ColumnLayout {
id: rootLayout
2022-06-21 14:11:03 +02:00
width: parent.width
2022-10-19 14:15:24 +02:00
spacing: 0
2022-06-21 14:11:03 +02:00
ColumnLayout {
2022-06-21 14:11:03 +02:00
id: password_layout
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
InfoTextArea {
visible: infotext
text: infotext
Layout.bottomMargin: constants.paddingMedium
Layout.fillWidth: true
}
2022-06-21 14:11:03 +02:00
Label {
Layout.fillWidth: true
2022-06-21 14:11:03 +02:00
text: qsTr('Password')
color: Material.accentColor
2022-06-21 14:11:03 +02:00
}
2022-07-26 20:36:43 +02:00
PasswordField {
2022-06-21 14:11:03 +02:00
id: pw_1
Layout.leftMargin: constants.paddingXLarge
2022-06-21 14:11:03 +02:00
}
Label {
Layout.fillWidth: true
2022-06-21 14:11:03 +02:00
text: qsTr('Password (again)')
visible: confirmPassword
color: Material.accentColor
2022-06-21 14:11:03 +02:00
}
2022-07-26 20:36:43 +02:00
PasswordField {
2022-06-21 14:11:03 +02:00
id: pw_2
Layout.leftMargin: constants.paddingXLarge
2022-06-21 14:11:03 +02:00
visible: confirmPassword
showReveal: false
echoMode: pw_1.echoMode
}
RowLayout {
Layout.fillWidth: true
Layout.rightMargin: constants.paddingXLarge
Layout.topMargin: constants.paddingLarge
Layout.bottomMargin: constants.paddingLarge
visible: confirmPassword
Label {
text: qsTr('Strength')
color: Material.accentColor
font.pixelSize: constants.fontSizeSmall
}
PasswordStrengthIndicator {
Layout.fillWidth: true
password: pw_1.text
}
2022-06-21 14:11:03 +02:00
}
Label {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
text: errorMessage
wrapMode: Text.Wrap
visible: errorMessage
color: constants.colorError
font.pixelSize: constants.fontSizeLarge
}
2022-06-21 14:11:03 +02:00
}
2022-10-19 14:15:24 +02:00
FlatButton {
Layout.fillWidth: true
text: qsTr("Ok")
icon.source: '../../icons/confirmed.png'
enabled: confirmPassword ? pw_1.text.length >= 6 && pw_1.text == pw_2.text : true
2022-10-19 14:15:24 +02:00
onClicked: {
passwordEntered(pw_1.text)
2022-06-21 14:11:03 +02:00
}
}
}
function clearPassword() {
pw_1.text = ""
pw_2.text = ""
}
2022-06-21 14:11:03 +02:00
}