qt tray tooltip: don't include wallet balance
closes https://github.com/spesmilo/electrum/issues/5665
This commit is contained in:
@@ -539,12 +539,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
self.logger.info("using default geometry")
|
self.logger.info("using default geometry")
|
||||||
self.setGeometry(100, 100, 840, 400)
|
self.setGeometry(100, 100, 840, 400)
|
||||||
|
|
||||||
def watching_only_changed(self):
|
@classmethod
|
||||||
|
def get_app_name_and_version_str(cls) -> str:
|
||||||
name = "Electrum"
|
name = "Electrum"
|
||||||
if constants.net.TESTNET:
|
if constants.net.TESTNET:
|
||||||
name += " " + constants.net.NET_NAME.capitalize()
|
name += " " + constants.net.NET_NAME.capitalize()
|
||||||
title = '%s %s - %s' % (name, ELECTRUM_VERSION,
|
return f"{name} {ELECTRUM_VERSION}"
|
||||||
self.wallet.basename())
|
|
||||||
|
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', '?')]
|
extra = [self.wallet.db.get('wallet_type', '?')]
|
||||||
if self.wallet.is_watching_only():
|
if self.wallet.is_watching_only():
|
||||||
extra.append(_('watching only'))
|
extra.append(_('watching only'))
|
||||||
@@ -950,8 +954,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
if not self.wallet:
|
if not self.wallet:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
network_text = ""
|
||||||
|
balance_text = ""
|
||||||
|
|
||||||
if self.network is None:
|
if self.network is None:
|
||||||
text = _("Offline")
|
network_text = _("Offline")
|
||||||
icon = read_QIcon("status_disconnected.png")
|
icon = read_QIcon("status_disconnected.png")
|
||||||
|
|
||||||
elif self.network.is_connected():
|
elif self.network.is_connected():
|
||||||
@@ -963,25 +970,26 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
# Display the synchronizing message in that case.
|
# Display the synchronizing message in that case.
|
||||||
if not self.wallet.up_to_date or server_height == 0:
|
if not self.wallet.up_to_date or server_height == 0:
|
||||||
num_sent, num_answered = self.wallet.get_history_sync_state_details()
|
num_sent, num_answered = self.wallet.get_history_sync_state_details()
|
||||||
text = ("{} ({}/{})"
|
network_text = ("{} ({}/{})"
|
||||||
.format(_("Synchronizing..."), num_answered, num_sent))
|
.format(_("Synchronizing..."), num_answered, num_sent))
|
||||||
icon = read_QIcon("status_waiting.png")
|
icon = read_QIcon("status_waiting.png")
|
||||||
elif server_lag > 1:
|
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)
|
icon = read_QIcon("status_lagging%s.png"%fork_str)
|
||||||
else:
|
else:
|
||||||
|
network_text = _("Connected")
|
||||||
c, u, x = self.wallet.get_balance()
|
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:
|
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:
|
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():
|
if self.wallet.has_lightning():
|
||||||
l = self.wallet.lnworker.get_balance()
|
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
|
# append fiat balance and price
|
||||||
if self.fx.is_enabled():
|
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 ''
|
self.base_unit(), self.get_decimal_point()) or ''
|
||||||
if not self.network.proxy:
|
if not self.network.proxy:
|
||||||
icon = read_QIcon("status_connected%s.png"%fork_str)
|
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)
|
icon = read_QIcon("status_connected_proxy%s.png"%fork_str)
|
||||||
else:
|
else:
|
||||||
if self.network.proxy:
|
if self.network.proxy:
|
||||||
text = "{} ({})".format(_("Not connected"), _("proxy enabled"))
|
network_text = "{} ({})".format(_("Not connected"), _("proxy enabled"))
|
||||||
else:
|
else:
|
||||||
text = _("Not connected")
|
network_text = _("Not connected")
|
||||||
icon = read_QIcon("status_disconnected.png")
|
icon = read_QIcon("status_disconnected.png")
|
||||||
|
|
||||||
if self.tray:
|
if self.tray:
|
||||||
self.tray.setToolTip("%s (%s)" % (text, self.wallet.basename()))
|
# note: don't include balance in systray tooltip, as some OSes persist tooltips,
|
||||||
self.balance_label.setText(text)
|
# 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:
|
if self.status_button:
|
||||||
self.status_button.setIcon(icon)
|
self.status_button.setIcon(icon)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user