1
0

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.
This commit is contained in:
f321x
2025-12-16 15:59:02 +01:00
parent 02abc0e6cd
commit 70084750ef
4 changed files with 39 additions and 69 deletions

View File

@@ -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 = ""
}
}
}

View File

@@ -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()
}
}
}

View File

@@ -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) {

View File

@@ -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: