Files
pallectrum/electrum/gui/qml/components/OpenWalletDialog.qml

112 lines
2.8 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import org.electrum 1.0
import "controls"
2022-08-17 11:49:57 +02:00
ElDialog {
id: openwalletdialog
2022-08-17 11:49:57 +02:00
property string name
property string path
property bool _invalidPassword: false
property bool _unlockClicked: false
title: qsTr('Open Wallet')
iconSource: Qt.resolvedUrl('../../icons/wallet.png')
2022-08-17 11:49:57 +02:00
focus: true
width: parent.width * 4/5
anchors.centerIn: parent
padding: 0
2022-08-17 11:49:57 +02:00
ColumnLayout {
spacing: 0
2022-08-17 11:49:57 +02:00
width: parent.width
ColumnLayout {
id: rootLayout
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXXLarge
Layout.rightMargin: constants.paddingXXLarge
spacing: constants.paddingLarge
2023-01-03 18:22:15 +01:00
2022-08-17 11:49:57 +02:00
InfoTextArea {
id: notice
text: Daemon.singlePasswordEnabled || !Daemon.currentWallet
2023-03-09 16:13:24 +01:00
? qsTr('Please enter password')
: qsTr('Wallet <b>%1</b> requires password to unlock').arg(name)
2022-08-17 11:49:57 +02:00
iconStyle: InfoTextArea.IconStyle.Warn
Layout.fillWidth: true
2022-08-17 11:49:57 +02:00
}
2022-07-26 20:36:43 +02:00
Label {
text: qsTr('Password')
Layout.fillWidth: true
color: Material.accentColor
}
2022-07-26 20:36:43 +02:00
PasswordField {
id: password
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXLarge
2022-07-26 20:36:43 +02:00
onTextChanged: {
unlockButton.enabled = true
_unlockClicked = false
2023-11-13 11:35:30 +01:00
_invalidPassword = false
2022-07-26 20:36:43 +02:00
}
onAccepted: {
unlock()
}
}
Label {
Layout.alignment: Qt.AlignHCenter
text: _invalidPassword && _unlockClicked ? qsTr("Invalid Password") : ''
color: constants.colorError
font.pixelSize: constants.fontSizeLarge
}
2022-08-17 11:49:57 +02:00
}
2023-01-09 18:15:53 +01:00
FlatButton {
id: unlockButton
Layout.fillWidth: true
2023-01-09 18:15:53 +01:00
icon.source: '../../icons/unlock.png'
text: qsTr("Unlock")
onClicked: {
unlock()
}
}
}
function unlock() {
unlockButton.enabled = false
_unlockClicked = true
Daemon.loadWallet(openwalletdialog.path, password.text)
}
2022-08-17 11:49:57 +02:00
Connections {
target: Daemon
function onWalletRequiresPassword() {
console.log('invalid password')
_invalidPassword = true
2022-08-17 11:49:57 +02:00
password.tf.forceActiveFocus()
}
function onWalletLoaded() {
openwalletdialog.close()
}
}
2022-08-17 11:49:57 +02:00
Component.onCompleted: {
password.tf.forceActiveFocus()
}
}