Skip to content

Commit

Permalink
qml: display network status and history server status separately. Als…
Browse files Browse the repository at this point in the history
…o, show network fees on full screen width
  • Loading branch information
ecdsa committed Mar 17, 2023
1 parent 49683d6 commit fcbd25c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
37 changes: 15 additions & 22 deletions electrum/gui/qml/components/NetworkOverview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,48 @@ Pane {
id: contentLayout
width: parent.width
columns: 2

Heading {
Layout.columnSpan: 2
text: qsTr('On-chain')
}

Label {
text: qsTr('Network:');
color: Material.accentColor
}
Label {
text: Network.networkName
}

Label {
text: qsTr('Server:');
color: Material.accentColor
}
Label {
text: Network.server
}

Label {
text: qsTr('Local Height:');
text: qsTr('Status:');
color: Material.accentColor
}
Label {
text: Network.height
text: Network.status
}

Label {
text: qsTr('Status:');
text: qsTr('Server:');
color: Material.accentColor
}

RowLayout {
OnchainNetworkStatusIndicator {}

Label {
text: Network.status
text: Network.server
}
OnchainNetworkStatusIndicator {}
}

Label {
text: qsTr('Network fees:');
text: qsTr('Local Height:');
color: Material.accentColor
}
Label {
text: Network.height
}
Heading {
Layout.columnSpan: 2
text: qsTr('Mempool fees')
}
Item {
id: histogramRoot
Layout.columnSpan: 2
Layout.fillWidth: true
implicitHeight: histogramLayout.height

Expand Down Expand Up @@ -189,7 +182,7 @@ Pane {

Heading {
Layout.columnSpan: 2
text: qsTr('Network')
text: qsTr('Proxy')
}

Label {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Image {
sourceSize.width: constants.iconSizeMedium
sourceSize.height: constants.iconSizeMedium

property bool connected: Network.status == 'connected'
property bool connected: Network.server_status == 'connected'
property bool lagging: connected && Network.isLagging
property bool fork: connected && Network.chaintips > 1
property bool syncing: connected && Daemon.currentWallet && Daemon.currentWallet.synchronizing
Expand Down
20 changes: 15 additions & 5 deletions electrum/gui/qml/qenetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class QENetwork(QObject, QtEventListener):
dataChanged = pyqtSignal()

_height = 0
_status = ""
_server_status = ""
_network_status = ""
_chaintips = 1
_islagging = False
_fee_histogram = []
Expand Down Expand Up @@ -71,9 +72,14 @@ def on_event_proxy_set(self, *args):

@event_listener
def on_event_status(self, *args):
self._logger.debug('status updated: %s' % self.network.connection_status)
if self._status != self.network.connection_status:
self._status = self.network.connection_status
network_status = self.network.get_status()
if self._network_status != network_status:
self._network_status = network_status
self.statusChanged.emit()
server_status = self.network.connection_status
self._logger.debug('server_status updated: %s' % server_status)
if self._server_status != server_status:
self._server_status = server_status
self.statusChanged.emit()
chains = len(self.network.get_blockchains())
if chains != self._chaintips:
Expand Down Expand Up @@ -166,7 +172,11 @@ def server(self, server):

@pyqtProperty(str, notify=statusChanged)
def status(self):
return self._status
return self._network_status

@pyqtProperty(str, notify=statusChanged)
def server_status(self):
return self._server_status

@pyqtProperty(int, notify=chaintipsChanged)
def chaintips(self):
Expand Down
4 changes: 1 addition & 3 deletions electrum/gui/qt/network_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ def update(self):

height_str = "%d "%(self.network.get_local_height()) + _('blocks')
self.height_label.setText(height_str)
n = len(self.network.get_interfaces())
status = _("Connected to {0} nodes.").format(n) if n > 1 else _("Connected to {0} node.").format(n) if n == 1 else _("Not connected")
self.status_label.setText(status)
self.status_label.setText(self.network.get_status())
chains = self.network.get_blockchains()
if len(chains) > 1:
chain = self.network.blockchain()
Expand Down
4 changes: 4 additions & 0 deletions electrum/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def get_interfaces(self) -> List[ServerAddr]:
with self.interfaces_lock:
return list(self.interfaces)

def get_status(self):
n = len(self.get_interfaces())
return _("Connected to {0} nodes.").format(n) if n > 1 else _("Connected to {0} node.").format(n) if n == 1 else _("Not connected")

def get_fee_estimates(self):
from statistics import median
from .simple_config import FEE_ETA_TARGETS
Expand Down

0 comments on commit fcbd25c

Please sign in to comment.