Browse Source

qt tray tooltip: don't include wallet balance

closes https://github.com/spesmilo/electrum/issues/5665
patch-4
SomberNight 3 years ago
parent
commit
2f2821f9ee
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 43
      electrum/gui/qt/main_window.py

43
electrum/gui/qt/main_window.py

@ -539,12 +539,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.logger.info("using default geometry")
self.setGeometry(100, 100, 840, 400)
def watching_only_changed(self):
@classmethod
def get_app_name_and_version_str(cls) -> str:
name = "Electrum"
if constants.net.TESTNET:
name += " " + constants.net.NET_NAME.capitalize()
title = '%s %s - %s' % (name, ELECTRUM_VERSION,
self.wallet.basename())
return f"{name} {ELECTRUM_VERSION}"
def watching_only_changed(self):
name_and_version = self.get_app_name_and_version_str()
title = f"{name_and_version} - {self.wallet.basename()}"
extra = [self.wallet.db.get('wallet_type', '?')]
if self.wallet.is_watching_only():
extra.append(_('watching only'))
@ -950,8 +954,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
if not self.wallet:
return
network_text = ""
balance_text = ""
if self.network is None:
text = _("Offline")
network_text = _("Offline")
icon = read_QIcon("status_disconnected.png")
elif self.network.is_connected():
@ -963,25 +970,26 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
# Display the synchronizing message in that case.
if not self.wallet.up_to_date or server_height == 0:
num_sent, num_answered = self.wallet.get_history_sync_state_details()
text = ("{} ({}/{})"
.format(_("Synchronizing..."), num_answered, num_sent))
network_text = ("{} ({}/{})"
.format(_("Synchronizing..."), num_answered, num_sent))
icon = read_QIcon("status_waiting.png")
elif server_lag > 1:
text = _("Server is lagging ({} blocks)").format(server_lag)
network_text = _("Server is lagging ({} blocks)").format(server_lag)
icon = read_QIcon("status_lagging%s.png"%fork_str)
else:
network_text = _("Connected")
c, u, x = self.wallet.get_balance()
text = _("Balance") + ": %s "%(self.format_amount_and_units(c))
balance_text = _("Balance") + ": %s "%(self.format_amount_and_units(c))
if u:
text += " [%s unconfirmed]"%(self.format_amount(u, is_diff=True).strip())
balance_text += " [%s unconfirmed]"%(self.format_amount(u, is_diff=True).strip())
if x:
text += " [%s unmatured]"%(self.format_amount(x, is_diff=True).strip())
balance_text += " [%s unmatured]"%(self.format_amount(x, is_diff=True).strip())
if self.wallet.has_lightning():
l = self.wallet.lnworker.get_balance()
text += u' \U000026a1 %s'%(self.format_amount_and_units(l).strip())
balance_text += u' \U000026a1 %s'%(self.format_amount_and_units(l).strip())
# append fiat balance and price
if self.fx.is_enabled():
text += self.fx.get_fiat_status_text(c + u + x,
balance_text += self.fx.get_fiat_status_text(c + u + x,
self.base_unit(), self.get_decimal_point()) or ''
if not self.network.proxy:
icon = read_QIcon("status_connected%s.png"%fork_str)
@ -989,14 +997,17 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
icon = read_QIcon("status_connected_proxy%s.png"%fork_str)
else:
if self.network.proxy:
text = "{} ({})".format(_("Not connected"), _("proxy enabled"))
network_text = "{} ({})".format(_("Not connected"), _("proxy enabled"))
else:
text = _("Not connected")
network_text = _("Not connected")
icon = read_QIcon("status_disconnected.png")
if self.tray:
self.tray.setToolTip("%s (%s)" % (text, self.wallet.basename()))
self.balance_label.setText(text)
# note: don't include balance in systray tooltip, as some OSes persist tooltips,
# hence "leaking" the wallet balance (see #5665)
name_and_version = self.get_app_name_and_version_str()
self.tray.setToolTip(f"{name_and_version} ({network_text})")
self.balance_label.setText(balance_text or network_text)
if self.status_button:
self.status_button.setIcon(icon)

Loading…
Cancel
Save