From 32d00b298262271a09b4f0903806c6b512e52f59 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 23 Feb 2023 20:46:56 +0100 Subject: [PATCH] qml: wallet loading indicator as modal dialog, unclosable --- .../qml/components/LoadingWalletDialog.qml | 41 +++++++++++++++++++ .../gui/qml/components/OpenWalletDialog.qml | 3 +- electrum/gui/qml/components/Wallets.qml | 15 +++++-- electrum/gui/qml/components/main.qml | 39 +++++++----------- electrum/gui/qml/qewallet.py | 13 ------ 5 files changed, 69 insertions(+), 42 deletions(-) create mode 100644 electrum/gui/qml/components/LoadingWalletDialog.qml diff --git a/electrum/gui/qml/components/LoadingWalletDialog.qml b/electrum/gui/qml/components/LoadingWalletDialog.qml new file mode 100644 index 000000000..4d0595e1e --- /dev/null +++ b/electrum/gui/qml/components/LoadingWalletDialog.qml @@ -0,0 +1,41 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.0 + +import org.electrum 1.0 + +ElDialog { + id: dialog + + title: qsTr('Loading Wallet') + iconSource: Qt.resolvedUrl('../../icons/wallet.png') + + modal: true + parent: Overlay.overlay + Overlay.modal: Rectangle { + color: "#aa000000" + } + + x: Math.floor((parent.width - implicitWidth) / 2) + y: Math.floor((parent.height - implicitHeight) / 2) + // anchors.centerIn: parent // this strangely pixelates the spinner + + ColumnLayout { + width: parent.width + + BusyIndicator { + Layout.alignment: Qt.AlignHCenter + + running: Daemon.loading + } + } + + Connections { + target: Daemon + function onLoadingChanged() { + if (!Daemon.loading) + dialog.close() + } + } +} diff --git a/electrum/gui/qml/components/OpenWalletDialog.qml b/electrum/gui/qml/components/OpenWalletDialog.qml index 3c9424646..0d58565d0 100644 --- a/electrum/gui/qml/components/OpenWalletDialog.qml +++ b/electrum/gui/qml/components/OpenWalletDialog.qml @@ -45,7 +45,7 @@ ElDialog { InfoTextArea { id: notice text: qsTr("Wallet %1 requires password to unlock").arg(name) - // visible: false //wallet_db.needsPassword + visible: wallet_db.needsPassword iconStyle: InfoTextArea.IconStyle.Warn Layout.fillWidth: true } @@ -96,7 +96,6 @@ ElDialog { FlatButton { id: unlockButton - // Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true visible: wallet_db.needsPassword icon.source: '../../icons/unlock.png' diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index 5d69d039d..e9d384265 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/electrum/gui/qml/components/Wallets.qml @@ -20,7 +20,6 @@ Pane { Daemon.availableWallets.reload() // and load the new wallet Daemon.load_wallet(dialog.path, dialog.wizard_data['password']) - app.stack.pop() }) } @@ -57,8 +56,10 @@ Pane { height: row.height onClicked: { - Daemon.load_wallet(model.path) - app.stack.pop() + if (Daemon.currentWallet.name != model.name) + Daemon.load_wallet(model.path) + else + app.stack.pop() } RowLayout { @@ -120,4 +121,12 @@ Pane { } } + Connections { + target: Daemon + function onWalletLoaded() { + if (app.stack.currentItem.objectName == 'Wallets') + app.stack.pop() + } + } + } diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index d0a90ee35..484ec7209 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -171,30 +171,6 @@ ApplicationWindow } } - Pane { - id: walletLoadingPane - parent: Overlay.overlay - anchors.fill: parent - background: Rectangle { color: Material.dialogColor } - visible: Daemon.loading - - ColumnLayout { - anchors.centerIn: parent - spacing: 2 * constants.paddingXLarge - - Label { - Layout.alignment: Qt.AlignHCenter - text: qsTr('Opening wallet...') - font.pixelSize: constants.fontSizeXXLarge - } - - BusyIndicator { - Layout.alignment: Qt.AlignHCenter - running: Daemon.loading - } - } - } - Timer { id: coverTimer interval: 10 @@ -283,6 +259,14 @@ ApplicationWindow } } + property alias loadingWalletDialog: _loadingWalletDialog + Component { + id: _loadingWalletDialog + LoadingWalletDialog { + onClosed: destroy() + } + } + property alias channelOpenProgressDialog: _channelOpenProgressDialog ChannelOpenProgressDialog { id: _channelOpenProgressDialog @@ -409,6 +393,13 @@ ApplicationWindow function onAuthRequired(method) { handleAuthRequired(Daemon, method) } + function onLoadingChanged() { + if (!Daemon.loading) + return + console.log('wallet loading') + var dialog = loadingWalletDialog.createObject(app, { allowClose: false } ) + dialog.open() + } } Connections { diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 7794a070b..e6f2f1b64 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -126,19 +126,6 @@ class QEWallet(AuthMixin, QObject, QtEventListener): self.synchronizing = True # start in sync state - # @pyqtSlot() - # def qt_init(self): - # self.notification_timer = QTimer(self) - # self.notification_timer.setSingleShot(False) - # self.notification_timer.setInterval(500) # msec - # self.notification_timer.timeout.connect(self.notify_transactions) - # - # self.sync_progress_timer = QTimer(self) - # self.sync_progress_timer.setSingleShot(False) - # self.sync_progress_timer.setInterval(2000) - # self.sync_progress_timer.timeout.connect(self.update_sync_progress) - - @pyqtProperty(bool, notify=isUptodateChanged) def isUptodate(self): return self._isUpToDate