From c0ce0296f8b6f73e1ed790b740785852865ff63b Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 14 Mar 2023 10:06:31 +0100 Subject: [PATCH] qml: show channel backups together with channels in Channels, remove Channel backups button from WalletDetails, filter backups to bottom, add backups section header --- electrum/gui/qml/components/Channels.qml | 33 +++++++++++++++++-- electrum/gui/qml/components/WalletDetails.qml | 10 ------ electrum/gui/qml/qechannellistmodel.py | 2 +- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/electrum/gui/qml/components/Channels.qml b/electrum/gui/qml/components/Channels.qml index 4bb7305ed..c75661bed 100644 --- a/electrum/gui/qml/components/Channels.qml +++ b/electrum/gui/qml/components/Channels.qml @@ -78,7 +78,22 @@ Pane { Layout.preferredWidth: parent.width Layout.fillHeight: true clip: true - model: Daemon.currentWallet.channelModel.filterModelNoBackups() + model: Daemon.currentWallet.channelModel + + section.property: 'is_backup' + section.criteria: ViewSection.FullString + section.delegate: RowLayout { + width: ListView.view.width + required property string section + Label { + visible: section == 'true' + text: qsTr('Channel backups') + Layout.alignment: Qt.AlignHCenter + Layout.topMargin: constants.paddingLarge + font.pixelSize: constants.fontSizeSmall + color: Material.accentColor + } + } delegate: ChannelDelegate { onClicked: { @@ -102,7 +117,6 @@ Pane { } } - ButtonContainer { Layout.fillWidth: true FlatButton { @@ -158,4 +172,19 @@ Pane { } } + Component { + id: importChannelBackupDialog + ImportChannelBackupDialog { + onClosed: destroy() + } + } + + Connections { + target: Daemon.currentWallet + function onImportChannelBackupFailed(message) { + var dialog = app.messageDialog.createObject(root, { text: message }) + dialog.open() + } + } + } diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index 100ee77a9..80acb6227 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -527,16 +527,6 @@ Pane { visible: Daemon.currentWallet && Daemon.currentWallet.canHaveLightning && !Daemon.currentWallet.isLightning icon.source: '../../icons/lightning.png' } - FlatButton { - Layout.fillWidth: true - Layout.preferredWidth: 1 - text: qsTr('Channel backups') - visible: Daemon.currentWallet && Daemon.currentWallet.isLightning - icon.source: '../../icons/lightning.png' - onClicked: { - app.stack.push(Qt.resolvedUrl('ChannelBackups.qml')) - } - } } } diff --git a/electrum/gui/qml/qechannellistmodel.py b/electrum/gui/qml/qechannellistmodel.py index c25f1dd4d..6cd4459e9 100644 --- a/electrum/gui/qml/qechannellistmodel.py +++ b/electrum/gui/qml/qechannellistmodel.py @@ -119,7 +119,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener): # sort, for now simply by state def chan_sort_score(c): - return c['state_code'] + return c['state_code'] + (10 if c['is_backup'] else 0) channels.sort(key=chan_sort_score) self.clear()