Browse Source

qml: improve OpenWalletDialog, PasswordDialog and PasswordField

master
Sander van Grieken 3 years ago
parent
commit
fc212b1dcc
  1. 78
      electrum/gui/qml/components/OpenWalletDialog.qml
  2. 23
      electrum/gui/qml/components/PasswordDialog.qml
  3. 6
      electrum/gui/qml/components/WalletDetails.qml
  4. 7
      electrum/gui/qml/components/controls/PasswordField.qml

78
electrum/gui/qml/components/OpenWalletDialog.qml

@ -10,16 +10,14 @@ import "controls"
ElDialog { ElDialog {
id: openwalletdialog id: openwalletdialog
width: parent.width * 4/5
anchors.centerIn: parent
title: qsTr("Open Wallet")
iconSource: '../../../icons/wallet.png'
property string name property string name
property string path property string path
property bool _unlockClicked: false
title: qsTr('Open Wallet')
iconSource: Qt.resolvedUrl('../../icons/wallet.png')
modal: true modal: true
parent: Overlay.overlay parent: Overlay.overlay
Overlay.modal: Rectangle { Overlay.modal: Rectangle {
@ -28,45 +26,43 @@ ElDialog {
focus: true focus: true
property bool _unlockClicked: false width: parent.width * 4/5
anchors.centerIn: parent
padding: 0
ColumnLayout { ColumnLayout {
id: rootLayout spacing: 0
width: parent.width width: parent.width
spacing: constants.paddingLarge
Label { ColumnLayout {
Layout.alignment: Qt.AlignHCenter id: rootLayout
text: name Layout.fillWidth: true
} Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
Item { spacing: constants.paddingLarge
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: passwordLayout.width
Layout.preferredHeight: notice.height
InfoTextArea { InfoTextArea {
id: notice id: notice
text: qsTr("Wallet requires password to unlock") text: qsTr("Wallet <b>%1</b> requires password to unlock").arg(name)
visible: wallet_db.needsPassword // visible: false //wallet_db.needsPassword
iconStyle: InfoTextArea.IconStyle.Warn iconStyle: InfoTextArea.IconStyle.Warn
width: parent.width Layout.fillWidth: true
}
} }
RowLayout {
id: passwordLayout
Layout.alignment: Qt.AlignHCenter
Label { Label {
text: qsTr('Password') text: qsTr('Password')
visible: wallet_db.needsPassword visible: wallet_db.needsPassword
Layout.fillWidth: true Layout.fillWidth: true
color: Material.accentColor
} }
PasswordField { PasswordField {
id: password id: password
visible: wallet_db.needsPassword
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: constants.paddingXLarge
visible: wallet_db.needsPassword
onTextChanged: { onTextChanged: {
unlockButton.enabled = true unlockButton.enabled = true
_unlockClicked = false _unlockClicked = false
@ -75,7 +71,6 @@ ElDialog {
unlock() unlock()
} }
} }
}
Label { Label {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -84,17 +79,6 @@ ElDialog {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
} }
FlatButton {
id: unlockButton
Layout.alignment: Qt.AlignHCenter
visible: wallet_db.needsPassword
icon.source: '../../icons/unlock.png'
text: qsTr("Unlock")
onClicked: {
unlock()
}
}
Label { Label {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
visible: wallet_db.requiresSplit visible: wallet_db.requiresSplit
@ -108,6 +92,19 @@ ElDialog {
text: qsTr('Split wallet') text: qsTr('Split wallet')
onClicked: wallet_db.doSplit() onClicked: wallet_db.doSplit()
} }
}
FlatButton {
id: unlockButton
// Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
visible: wallet_db.needsPassword
icon.source: '../../icons/unlock.png'
text: qsTr("Unlock")
onClicked: {
unlock()
}
}
} }
@ -135,6 +132,9 @@ ElDialog {
onInvalidPassword: { onInvalidPassword: {
password.tf.forceActiveFocus() password.tf.forceActiveFocus()
} }
onNeedsPasswordChanged: {
notice.visible = needsPassword
}
} }
Component.onCompleted: { Component.onCompleted: {

23
electrum/gui/qml/components/PasswordDialog.qml

@ -11,7 +11,7 @@ ElDialog {
id: passworddialog id: passworddialog
title: qsTr("Enter Password") title: qsTr("Enter Password")
iconSource: '../../../icons/lock.png' iconSource: Qt.resolvedUrl('../../icons/lock.png')
property bool confirmPassword: false property bool confirmPassword: false
property string password property string password
@ -21,6 +21,7 @@ ElDialog {
modal: true modal: true
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width * 4/5
padding: 0 padding: 0
Overlay.modal: Rectangle { Overlay.modal: Rectangle {
@ -28,37 +29,43 @@ ElDialog {
} }
ColumnLayout { ColumnLayout {
id: rootLayout
width: parent.width width: parent.width
spacing: 0 spacing: 0
ColumnLayout {
id: password_layout
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
InfoTextArea { InfoTextArea {
visible: infotext visible: infotext
text: infotext text: infotext
Layout.margins: constants.paddingMedium Layout.bottomMargin: constants.paddingMedium
Layout.fillWidth: true Layout.fillWidth: true
} }
GridLayout {
id: password_layout
columns: 2
Layout.fillWidth: true
Layout.margins: constants.paddingXXLarge
Label { Label {
Layout.fillWidth: true
text: qsTr('Password') text: qsTr('Password')
color: Material.accentColor
} }
PasswordField { PasswordField {
id: pw_1 id: pw_1
Layout.leftMargin: constants.paddingXLarge
} }
Label { Label {
Layout.fillWidth: true
text: qsTr('Password (again)') text: qsTr('Password (again)')
visible: confirmPassword visible: confirmPassword
color: Material.accentColor
} }
PasswordField { PasswordField {
id: pw_2 id: pw_2
Layout.leftMargin: constants.paddingXLarge
visible: confirmPassword visible: confirmPassword
} }
} }

6
electrum/gui/qml/components/WalletDetails.qml

@ -543,12 +543,10 @@ Pane {
Connections { Connections {
target: Daemon.currentWallet target: Daemon.currentWallet
function onRequestNewPassword() { // new wallet password function onRequestNewPassword() { // new wallet password
var dialog = app.passwordDialog.createObject(app, var dialog = app.passwordDialog.createObject(app, {
{
'confirmPassword': true, 'confirmPassword': true,
'title': qsTr('Enter new password'), 'title': qsTr('Enter new password'),
'infotext': qsTr('If you forget your password, you\'ll need to\ 'infotext': qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely')
restore from seed. Please make sure you have your seed stored safely')
}) })
dialog.accepted.connect(function() { dialog.accepted.connect(function() {
Daemon.currentWallet.set_password(dialog.password) Daemon.currentWallet.set_password(dialog.password)

7
electrum/gui/qml/components/controls/PasswordField.qml

@ -13,6 +13,7 @@ RowLayout {
echoMode: TextInput.Password echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData inputMethodHints: Qt.ImhSensitiveData
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: fontMetrics.advanceWidth('X') * 16
onAccepted: root.accepted() onAccepted: root.accepted()
} }
ToolButton { ToolButton {
@ -21,4 +22,10 @@ RowLayout {
password_tf.echoMode = password_tf.echoMode == TextInput.Password ? TextInput.Normal : TextInput.Password password_tf.echoMode = password_tf.echoMode == TextInput.Password ? TextInput.Normal : TextInput.Password
} }
} }
FontMetrics {
id: fontMetrics
font: password_tf.font
}
} }

Loading…
Cancel
Save