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

160 lines
3.9 KiB
QML
Raw Normal View History

import QtQuick 2.6
import QtQuick.Layouts 1.0
2022-08-17 11:49:57 +02:00
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
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
width: parent.width
height: parent.height
title: qsTr("Open Wallet")
2022-09-30 14:37:14 +02:00
iconSource: '../../../icons/wallet.png'
property string name
property string path
2022-08-17 11:49:57 +02:00
standardButtons: Dialog.Cancel
modal: true
parent: Overlay.overlay
Overlay.modal: Rectangle {
color: "#aa000000"
}
focus: true
property bool _unlockClicked: false
2022-08-17 11:49:57 +02:00
ColumnLayout {
width: parent.width
spacing: constants.paddingLarge
Label {
Layout.alignment: Qt.AlignHCenter
2022-08-17 11:49:57 +02:00
text: name
}
2022-08-17 11:49:57 +02:00
Item {
Layout.alignment: Qt.AlignHCenter
2022-08-17 11:49:57 +02:00
Layout.preferredWidth: passwordLayout.width
Layout.preferredHeight: notice.height
InfoTextArea {
id: notice
text: qsTr("Wallet requires password to unlock")
visible: wallet_db.needsPassword
iconStyle: InfoTextArea.IconStyle.Warn
width: parent.width
}
}
2022-07-26 20:36:43 +02:00
RowLayout {
2022-08-17 11:49:57 +02:00
id: passwordLayout
2022-07-26 20:36:43 +02:00
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width * 2/3
Label {
text: qsTr('Password')
visible: wallet_db.needsPassword
Layout.fillWidth: true
}
2022-07-26 20:36:43 +02:00
PasswordField {
id: password
visible: wallet_db.needsPassword
Layout.fillWidth: true
onTextChanged: {
unlockButton.enabled = true
_unlockClicked = false
}
onAccepted: {
unlock()
}
}
}
2022-08-17 11:49:57 +02:00
Label {
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
text: !wallet_db.validPassword && _unlockClicked ? qsTr("Invalid Password") : ''
color: constants.colorError
font.pixelSize: constants.fontSizeLarge
}
Button {
id: unlockButton
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
visible: wallet_db.needsPassword
text: qsTr("Unlock")
onClicked: {
unlock()
}
}
Label {
text: qsTr('Select HW device')
visible: wallet_db.needsHWDevice
}
ComboBox {
id: hw_device
model: ['','Not implemented']
visible: wallet_db.needsHWDevice
}
Label {
text: qsTr('Wallet requires splitting')
visible: wallet_db.requiresSplit
}
Button {
visible: wallet_db.requiresSplit
text: qsTr('Split wallet')
onClicked: wallet_db.doSplit()
}
2022-08-17 11:49:57 +02:00
BusyIndicator {
id: busy
running: false
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
}
}
function unlock() {
unlockButton.enabled = false
_unlockClicked = true
wallet_db.password = password.text
2022-07-12 16:49:07 +02:00
wallet_db.verify()
}
2022-08-17 11:49:57 +02:00
WalletDB {
id: wallet_db
path: openwalletdialog.path
onSplitFinished: {
// if wallet needed splitting, we close the pane and refresh the wallet list
Daemon.availableWallets.reload()
2022-08-17 11:49:57 +02:00
openwalletdialog.close()
}
onReadyChanged: {
if (ready) {
busy.running = true
2022-03-25 10:40:58 +01:00
Daemon.load_wallet(openwalletdialog.path, password.text)
2022-08-17 11:49:57 +02:00
openwalletdialog.close()
}
}
onInvalidPassword: {
2022-08-17 11:49:57 +02:00
password.tf.forceActiveFocus()
}
}
2022-08-17 11:49:57 +02:00
Component.onCompleted: {
2022-07-12 16:49:07 +02:00
wallet_db.verify()
}
}