From 5889c92e817f79b330107425bd5329c38e5ae4a1 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 15 Jun 2022 11:39:46 +0200 Subject: [PATCH] improve network status display and states of items when no wallet loaded --- electrum/gui/qml/components/NetworkStats.qml | 10 ++++++---- electrum/gui/qml/components/Preferences.qml | 3 +-- electrum/gui/qml/components/WalletMainView.qml | 2 +- electrum/gui/qml/components/main.qml | 18 +++++------------- electrum/gui/qml/qenetwork.py | 8 ++++---- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/electrum/gui/qml/components/NetworkStats.qml b/electrum/gui/qml/components/NetworkStats.qml index f23e2c4ca..abf42a7de 100644 --- a/electrum/gui/qml/components/NetworkStats.qml +++ b/electrum/gui/qml/components/NetworkStats.qml @@ -49,10 +49,12 @@ Pane { Layout.preferredWidth: constants.iconSizeSmall Layout.preferredHeight: constants.iconSizeSmall source: Network.status == 'connecting' || Network.status == 'disconnected' - ? '../../icons/status_disconnected.png' : - Daemon.currentWallet.isUptodate - ? '../../icons/status_connected.png' - : '../../icons/status_lagging.png' + ? '../../icons/status_disconnected.png' + : Network.status == 'connected' + ? Daemon.currentWallet && !Daemon.currentWallet.isUptodate + ? '../../icons/status_lagging.png' + : '../../icons/status_connected.png' + : '../../icons/status_connected.png' } Label { text: Network.status diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 702ee379c..e64ec97cc 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -108,14 +108,13 @@ Pane { Label { text: qsTr('Lightning Routing') - enabled: Daemon.currentWallet.isLightning } ComboBox { id: lnRoutingType valueRole: 'key' textRole: 'label' - enabled: Daemon.currentWallet.isLightning && false + enabled: Daemon.currentWallet != null && Daemon.currentWallet.isLightning && false model: ListModel { ListElement { key: 'gossip'; label: qsTr('Gossip') } ListElement { key: 'trampoline'; label: qsTr('Trampoline') } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index a7d339ae1..342221e6c 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -39,7 +39,7 @@ Item { icon.color: 'transparent' action: Action { text: qsTr('Channels'); - enabled: Daemon.currentWallet.isLightning + enabled: Daemon.currentWallet != null && Daemon.currentWallet.isLightning onTriggered: menu.openPage(Qt.resolvedUrl('Channels.qml')) icon.source: '../../icons/lightning.png' } diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index 5d438d24a..4e6a56723 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -53,16 +53,6 @@ ApplicationWindow visible: Network.isTestNet width: column.width height: column.height - MouseArea { - anchors.fill: parent - onClicked: { - var dialog = app.messageDialog.createObject(app, {'text': - 'Electrum is currently on ' + Network.networkName + '' - }) - dialog.open() - } - - } ColumnLayout { id: column @@ -96,9 +86,11 @@ ApplicationWindow Layout.preferredHeight: constants.iconSizeSmall source: Network.status == 'connecting' || Network.status == 'disconnected' ? '../../icons/status_disconnected.png' - : Daemon.currentWallet.isUptodate - ? '../../icons/status_connected.png' - : '../../icons/status_lagging.png' + : Network.status == 'connected' + ? Daemon.currentWallet && !Daemon.currentWallet.isUptodate + ? '../../icons/status_lagging.png' + : '../../icons/status_connected.png' + : '../../icons/status_connected.png' } Rectangle { diff --git a/electrum/gui/qml/qenetwork.py b/electrum/gui/qml/qenetwork.py index 3522185e9..73bad2856 100644 --- a/electrum/gui/qml/qenetwork.py +++ b/electrum/gui/qml/qenetwork.py @@ -60,11 +60,11 @@ class QENetwork(QObject): self._logger.debug('fee histogram updated') self.feeHistogramUpdated.emit() - @pyqtProperty(int,notify=heightChanged) + @pyqtProperty(int, notify=heightChanged) def height(self): return self._height - @pyqtProperty('QString',notify=defaultServerChanged) + @pyqtProperty('QString', notify=defaultServerChanged) def server(self): return str(self.network.get_parameters().server) @@ -79,7 +79,7 @@ class QENetwork(QObject): net_params = net_params._replace(server=server) self.network.run_from_another_thread(self.network.set_parameters(net_params)) - @pyqtProperty('QString',notify=statusChanged) + @pyqtProperty('QString', notify=statusChanged) def status(self): return self._status @@ -105,7 +105,7 @@ class QENetwork(QObject): self.network.run_from_another_thread(self.network.set_parameters(net_params)) self.proxyChanged.emit() - @pyqtProperty('QVariant',notify=feeHistogramUpdated) + @pyqtProperty('QVariant', notify=feeHistogramUpdated) def feeHistogram(self): return self.network.get_status_value('fee_histogram')