From 70084750ef81c5ed29edc3e42bb6ec6e829db9a7 Mon Sep 17 00:00:00 2001 From: f321x Date: Tue, 16 Dec 2025 15:59:02 +0100 Subject: [PATCH] qml: show wallet list as root if no wallet is loaded Shows Wallets.qml as root if no wallet is loaded and removes the logic for no loaded wallet from the WalletMainView as WalletMainView won't be shown anymore without a Daemon.currentWallet. --- .../gui/qml/components/WalletMainView.qml | 86 +++++-------------- electrum/gui/qml/components/Wallets.qml | 6 +- electrum/gui/qml/components/main.qml | 14 ++- electrum/gui/qml/qedaemon.py | 2 +- 4 files changed, 39 insertions(+), 69 deletions(-) diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index a9755ac81..c39cda5ed 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -11,10 +11,9 @@ import "controls" Item { id: mainView - property string title: Daemon.currentWallet ? Daemon.currentWallet.name : qsTr('no wallet loaded') + property string title: Daemon.currentWallet.name property var _sendDialog - property string _intentUri property string _request_amount property string _request_description @@ -188,7 +187,7 @@ Item { icon.source: '../../icons/wallet.png' action: Action { text: qsTr('Wallet details') - enabled: Daemon.currentWallet && app.stack.currentItem.objectName != 'WalletDetails' + enabled: app.stack.currentItem.objectName != 'WalletDetails' onTriggered: menu.openPage(Qt.resolvedUrl('WalletDetails.qml')) } } @@ -198,7 +197,7 @@ Item { action: Action { text: qsTr('Addresses/Coins'); onTriggered: menu.openPage(Qt.resolvedUrl('Addresses.qml')); - enabled: Daemon.currentWallet && app.stack.currentItem.objectName != 'Addresses' + enabled: app.stack.currentItem.objectName != 'Addresses' } } MenuItem { @@ -206,7 +205,7 @@ Item { icon.source: '../../icons/lightning.png' action: Action { text: qsTr('Channels'); - enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning && app.stack.currentItem.objectName != 'Channels' + enabled: Daemon.currentWallet.isLightning && app.stack.currentItem.objectName != 'Channels' onTriggered: menu.openPage(Qt.resolvedUrl('Channels.qml')) } } @@ -285,62 +284,16 @@ Item { History { id: history - visible: Daemon.currentWallet Layout.fillWidth: true Layout.fillHeight: true } - ColumnLayout { - Layout.alignment: Qt.AlignHCenter - Layout.fillHeight: true - spacing: 2*constants.paddingXLarge - visible: !Daemon.currentWallet - - Item { - Layout.fillHeight: true - } - Label { - Layout.alignment: Qt.AlignHCenter - text: qsTr('No wallet loaded') - font.pixelSize: constants.fontSizeXXLarge - } - - Pane { - Layout.alignment: Qt.AlignHCenter - padding: 0 - background: Rectangle { - color: Material.dialogColor - } - FlatButton { - text: qsTr('Open/Create Wallet') - icon.source: '../../icons/wallet.png' - onClicked: { - if (Daemon.availableWallets.rowCount() > 0) { - stack.push(Qt.resolvedUrl('Wallets.qml')) - } else { - var newww = app.newWalletWizard.createObject(app) - newww.walletCreated.connect(function() { - Daemon.availableWallets.reload() - // and load the new wallet - Daemon.loadWallet(newww.path, newww.wizard_data['password']) - }) - newww.open() - } - } - } - } - Item { - Layout.fillHeight: true - } - } - ButtonContainer { id: buttonContainer Layout.fillWidth: true FlatButton { id: receiveButton - visible: Daemon.currentWallet Layout.fillWidth: true Layout.preferredWidth: 1 icon.source: '../../icons/tab_receive.png' @@ -357,7 +310,6 @@ Item { } } FlatButton { - visible: Daemon.currentWallet Layout.fillWidth: true Layout.preferredWidth: 1 icon.source: '../../icons/tab_send.png' @@ -489,25 +441,22 @@ Item { } Connections { - target: AppController - function onUriReceived(uri) { - console.log('uri received: ' + uri) - if (!Daemon.currentWallet) { - console.log('No wallet open, deferring') - _intentUri = uri + target: Daemon + function onWalletLoaded() { + if (!Daemon.currentWallet) { // wallet got deleted + app.stack.replaceRoot('Wallets.qml') return } - piResolver.recipient = uri + infobanner.hide() // start hidden when switching wallets } } Connections { - target: Daemon - function onWalletLoaded() { - infobanner.hide() // start hidden when switching wallets - if (_intentUri) { - piResolver.recipient = _intentUri - _intentUri = '' + target: app + function onPendingIntentChanged() { + if (app.pendingIntent) { + piResolver.recipient = app.pendingIntent + app.pendingIntent = "" } } } @@ -819,5 +768,12 @@ Item { } } + Component.onCompleted: { + console.log("WalletMainView completed: ", Daemon.currentWallet.name) + if (app.pendingIntent) { + piResolver.recipient = app.pendingIntent + app.pendingIntent = "" + } + } } diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index f9c9f84e3..b38fdf78a 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/electrum/gui/qml/components/Wallets.qml @@ -143,7 +143,11 @@ Pane { target: Daemon function onWalletLoaded() { if (app.stack.currentItem.objectName == 'Wallets') - app.stack.pop() + if (app.stack.getRoot().objectName == 'Wallets') { + app.stack.replaceRoot('WalletMainView.qml') + } else { + app.stack.pop() + } } } diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index cfdbf4eeb..bf0b0c969 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -38,6 +38,8 @@ ApplicationWindow property alias keyboardFreeZone: _keyboardFreeZone property alias infobanner: _infobanner + property string pendingIntent: "" + property variant activeDialogs: [] property var _exceptionDialog @@ -120,7 +122,7 @@ ApplicationWindow header: ToolBar { id: toolbar - + // Add top margin for status bar on Android when using edge-to-edge topPadding: app.statusBarHeight @@ -269,7 +271,7 @@ ApplicationWindow Layout.fillWidth: true initialItem: Component { - WalletMainView {} + Wallets {} } function getRoot() { @@ -282,6 +284,10 @@ ApplicationWindow mainStackView.push(item) } } + function replaceRoot(item_url) { + mainStackView.clear() + mainStackView.push(Qt.resolvedUrl(item_url)) + } } // Add bottom padding for navigation bar on Android when UI is edge-to-edge @@ -698,6 +704,10 @@ ApplicationWindow if (obj != null) app.pluginobjects[name] = obj } + function onUriReceived(uri) { + console.log('uri received (main): ' + uri) + app.pendingIntent = uri + } } function pluginsComponentsByName(comp_name) { diff --git a/electrum/gui/qml/qedaemon.py b/electrum/gui/qml/qedaemon.py index 72e618b0c..acbe1a780 100644 --- a/electrum/gui/qml/qedaemon.py +++ b/electrum/gui/qml/qedaemon.py @@ -219,7 +219,7 @@ class QEDaemon(AuthMixin, QObject): except InvalidPassword: self.walletRequiresPassword.emit(self._name, self._path) except FileNotFoundError: - self.walletOpenError.emit(_('File not found')) + self.walletOpenError.emit(_('File not found') + f":\n{self._path}") except StorageReadWriteError: self.walletOpenError.emit(_('Could not read/write file')) except WalletFileException as e: