2023-07-17 10:49:06 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Material
|
2022-02-24 16:14:55 +01:00
|
|
|
|
|
|
|
|
import org.electrum 1.0
|
|
|
|
|
|
2022-04-06 13:52:21 +02:00
|
|
|
import "controls"
|
|
|
|
|
|
2022-08-17 11:49:57 +02:00
|
|
|
ElDialog {
|
2022-02-24 16:14:55 +01:00
|
|
|
id: openwalletdialog
|
2022-08-17 11:49:57 +02:00
|
|
|
|
2022-02-24 16:14:55 +01:00
|
|
|
property string name
|
|
|
|
|
property string path
|
|
|
|
|
|
2023-10-06 12:06:00 +02:00
|
|
|
property bool _invalidPassword: false
|
2023-02-10 14:14:23 +01:00
|
|
|
property bool _unlockClicked: false
|
|
|
|
|
|
|
|
|
|
title: qsTr('Open Wallet')
|
|
|
|
|
iconSource: Qt.resolvedUrl('../../icons/wallet.png')
|
|
|
|
|
|
2022-08-17 11:49:57 +02:00
|
|
|
focus: true
|
|
|
|
|
|
2023-02-10 14:14:23 +01:00
|
|
|
width: parent.width * 4/5
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
|
|
padding: 0
|
2022-02-24 16:14:55 +01:00
|
|
|
|
2022-08-17 11:49:57 +02:00
|
|
|
ColumnLayout {
|
2023-02-10 14:14:23 +01:00
|
|
|
spacing: 0
|
2022-08-17 11:49:57 +02:00
|
|
|
width: parent.width
|
2022-02-24 16:14:55 +01:00
|
|
|
|
2023-02-10 14:14:23 +01:00
|
|
|
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
|
2023-10-06 12:06:00 +02:00
|
|
|
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
|
2023-02-10 14:14:23 +01:00
|
|
|
Layout.fillWidth: true
|
2022-08-17 11:49:57 +02:00
|
|
|
}
|
2022-02-24 16:14:55 +01:00
|
|
|
|
2022-07-26 20:36:43 +02:00
|
|
|
Label {
|
|
|
|
|
text: qsTr('Password')
|
|
|
|
|
Layout.fillWidth: true
|
2023-02-10 14:14:23 +01:00
|
|
|
color: Material.accentColor
|
2022-07-05 18:30:54 +02:00
|
|
|
}
|
2022-07-26 20:36:43 +02:00
|
|
|
|
|
|
|
|
PasswordField {
|
|
|
|
|
id: password
|
|
|
|
|
Layout.fillWidth: true
|
2023-02-10 14:14:23 +01:00
|
|
|
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()
|
|
|
|
|
}
|
2022-07-05 18:30:54 +02:00
|
|
|
}
|
2022-02-24 16:14:55 +01:00
|
|
|
|
2023-02-10 14:14:23 +01:00
|
|
|
Label {
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-10-06 12:06:00 +02:00
|
|
|
text: _invalidPassword && _unlockClicked ? qsTr("Invalid Password") : ''
|
2023-02-10 14:14:23 +01:00
|
|
|
color: constants.colorError
|
|
|
|
|
font.pixelSize: constants.fontSizeLarge
|
|
|
|
|
}
|
2022-08-17 11:49:57 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-09 18:15:53 +01:00
|
|
|
FlatButton {
|
2022-07-05 18:30:54 +02:00
|
|
|
id: unlockButton
|
2023-02-10 14:14:23 +01:00
|
|
|
Layout.fillWidth: true
|
2023-01-09 18:15:53 +01:00
|
|
|
icon.source: '../../icons/unlock.png'
|
2022-02-24 16:14:55 +01:00
|
|
|
text: qsTr("Unlock")
|
|
|
|
|
onClicked: {
|
2022-07-05 18:30:54 +02:00
|
|
|
unlock()
|
2022-02-24 16:14:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-05 18:30:54 +02:00
|
|
|
function unlock() {
|
|
|
|
|
unlockButton.enabled = false
|
|
|
|
|
_unlockClicked = true
|
2023-10-06 12:06:00 +02:00
|
|
|
Daemon.loadWallet(openwalletdialog.path, password.text)
|
2022-07-05 18:30:54 +02:00
|
|
|
}
|
2022-08-17 11:49:57 +02:00
|
|
|
|
2023-10-06 12:06:00 +02:00
|
|
|
Connections {
|
|
|
|
|
target: Daemon
|
|
|
|
|
function onWalletRequiresPassword() {
|
|
|
|
|
console.log('invalid password')
|
|
|
|
|
_invalidPassword = true
|
2022-08-17 11:49:57 +02:00
|
|
|
password.tf.forceActiveFocus()
|
2022-07-05 18:30:54 +02:00
|
|
|
}
|
2023-10-06 12:06:00 +02:00
|
|
|
function onWalletLoaded() {
|
2023-02-28 14:11:52 +01:00
|
|
|
openwalletdialog.close()
|
|
|
|
|
}
|
2022-07-05 18:30:54 +02:00
|
|
|
}
|
2022-08-17 11:49:57 +02:00
|
|
|
|
2022-07-05 18:30:54 +02:00
|
|
|
Component.onCompleted: {
|
2023-10-06 12:06:00 +02:00
|
|
|
password.tf.forceActiveFocus()
|
2022-02-24 16:14:55 +01:00
|
|
|
}
|
|
|
|
|
}
|