Files
purple-electrumwallet/electrum/gui/qml/components/PasswordDialog.qml
T
f321x 07f61ebd5a qml: PasswordDialog: show error on invalid password
Currently the PasswordDialog on QML would just close if the user enters
an incorrect password. This is confusing as the user doesn't know why
the dialog closed and if it initiated any action or not.

With the change the PasswordDialog will get the ability to show an error
message and will show "Invalid Password" if an incorrect password is
entered.
I also used it for the password unification warning ("Need to enter
similar password ...") instead of showing a separate popup.
2026-01-20 12:30:31 +01:00

117 lines
3.1 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import org.electrum 1.0
import "controls"
ElDialog {
id: passworddialog
title: qsTr("Enter Password")
iconSource: Qt.resolvedUrl('../../icons/lock.png')
property bool confirmPassword: false
property string infotext
property string errorMessage
signal passwordEntered(string password)
anchors.centerIn: parent
width: parent.width * 4/5
padding: 0
needsSystemBarPadding: false
ColumnLayout {
id: rootLayout
width: parent.width
spacing: 0
ColumnLayout {
id: password_layout
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
InfoTextArea {
visible: infotext
text: infotext
Layout.bottomMargin: constants.paddingMedium
Layout.fillWidth: true
}
Label {
Layout.fillWidth: true
text: qsTr('Password')
color: Material.accentColor
}
PasswordField {
id: pw_1
Layout.leftMargin: constants.paddingXLarge
}
Label {
Layout.fillWidth: true
text: qsTr('Password (again)')
visible: confirmPassword
color: Material.accentColor
}
PasswordField {
id: pw_2
Layout.leftMargin: constants.paddingXLarge
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
}
}
Label {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
text: errorMessage
wrapMode: Text.Wrap
visible: errorMessage
color: constants.colorError
font.pixelSize: constants.fontSizeLarge
}
}
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
onClicked: {
passwordEntered(pw_1.text)
}
}
}
function clearPassword() {
pw_1.text = ""
pw_2.text = ""
}
}