Files
pallectrum/electrum/gui/qml/components/controls/ElDialog.qml
Sander van Grieken 7ca9b735d5 daemon: refactor load_wallet to not just return None, but raise specific exceptions.
The following exceptions should be expected:
FileNotFoundError: given wallet path does not exist
StorageReadWriteError: given file is not readable/writable or containing folder is not writable
InvalidPassword: wallet requires a password but no password or an invalid password was given
WalletFileException: any internal wallet data issue. specific subclasses can be caught separately:
-  WalletRequiresSplit: wallet needs splitting (split_data passed in Exception)
-  WalletRequiresUpgrade: wallet needs upgrade, and no upgrade=True was passed to load_wallet
-  WalletUnfinished: wallet file contains an action and needs additional information to finalize. (WalletDB passed in exception)

Removed qml/qewalletdb.py

This patch also fixes load_wallet calls in electrum/scripts and adds a qml workaround for dialogs opening and closing so
fast that the dialog opened==true property change is missed (which we need to manage the dialog/page stack)
2023-10-10 17:42:07 +02:00

111 lines
3.0 KiB
QML

import QtQuick 2.15
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
Dialog {
id: abstractdialog
property bool allowClose: true
property string iconSource
property bool resizeWithKeyboard: true
property bool _result: false
// workaround: remember opened state, to inhibit closed -> closed event
property bool _wasOpened: false
// called to finally close dialog after checks by onClosing handler in main.qml
function doClose() {
doReject()
}
// avoid potential multiple signals, only emit once
function doAccept() {
if (_result)
return
_result = true
accept()
}
// avoid potential multiple signals, only emit once
function doReject() {
if (_result)
return
_result = true
reject()
}
parent: resizeWithKeyboard ? Overlay.overlay.children[0] : Overlay.overlay
modal: true
Overlay.modal: Rectangle {
color: "#aa000000"
}
closePolicy: allowClose
? Popup.CloseOnEscape | Popup.CloseOnPressOutside
: Popup.NoAutoClose
onOpenedChanged: {
if (opened) {
app.activeDialogs.push(abstractdialog)
_wasOpened = true
} else {
if (!_wasOpened)
return
if (app.activeDialogs.indexOf(abstractdialog) < 0) {
console.log('dialog should exist in activeDialogs!')
app.activeDialogs.pop()
return
}
app.activeDialogs.splice(app.activeDialogs.indexOf(abstractdialog),1)
}
}
header: ColumnLayout {
spacing: 0
RowLayout {
spacing: 0
Image {
visible: iconSource
source: iconSource
Layout.preferredWidth: constants.iconSizeXLarge
Layout.preferredHeight: constants.iconSizeXLarge
Layout.leftMargin: constants.paddingMedium
Layout.topMargin: constants.paddingMedium
Layout.bottomMargin: constants.paddingMedium
}
Label {
text: title
wrapMode: Text.Wrap
elide: Label.ElideRight
Layout.fillWidth: true
leftPadding: constants.paddingXLarge
topPadding: constants.paddingXLarge
bottomPadding: constants.paddingXLarge
rightPadding: constants.paddingXLarge
font.bold: true
font.pixelSize: constants.fontSizeMedium
}
}
Rectangle {
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXXSmall
Layout.rightMargin: constants.paddingXXSmall
height: 1
color: Qt.rgba(0,0,0,0.5)
}
}
background: Rectangle {
id: bg
color: Material.dialogColor
TapHandler {
onTapped: bg.forceActiveFocus()
}
}
}