Browse Source

qt: addr/coins tab: show tooltip for "freeze address"

related https://github.com/spesmilo/electrum/issues/8698
master
SomberNight 2 years ago
parent
commit
affe3630b0
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/messages.py
  2. 13
      electrum/gui/qt/address_list.py
  3. 25
      electrum/gui/qt/utxo_list.py

3
electrum/gui/messages.py

@ -44,3 +44,6 @@ MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP = _(
"""This channel is with a non-trampoline node; it cannot be used if trampoline is enabled.
If you want to keep using this channel, you need to disable trampoline routing in your preferences."""
)
MSG_FREEZE_ADDRESS = _("When you freeze an address, the funds in that address will not be used for sending bitcoins.")
MSG_FREEZE_COIN = _("When you freeze a coin, it will not be used for sending bitcoins.")

13
electrum/gui/qt/address_list.py

@ -40,6 +40,7 @@ from electrum.simple_config import SimpleConfig
from .util import MONOSPACE_FONT, ColorScheme, webopen
from .my_treeview import MyTreeView, MySortModel
from ..messages import MSG_FREEZE_ADDRESS
if TYPE_CHECKING:
from .main_window import ElectrumWindow
@ -284,6 +285,7 @@ class AddressList(MyTreeView):
multi_select = len(selected) > 1
addrs = [self.item_from_index(item).text() for item in selected]
menu = QMenu()
menu.setToolTipsVisible(True)
if not multi_select:
idx = self.indexAt(position)
if not idx.isValid():
@ -311,14 +313,17 @@ class AddressList(MyTreeView):
menu.addAction(_("View on block explorer"), lambda: webopen(addr_URL))
if not self.wallet.is_frozen_address(addr):
menu.addAction(_("Freeze"), lambda: self.main_window.set_frozen_state_of_addresses([addr], True))
act = menu.addAction(_("Freeze"), lambda: self.main_window.set_frozen_state_of_addresses([addr], True))
else:
menu.addAction(_("Unfreeze"), lambda: self.main_window.set_frozen_state_of_addresses([addr], False))
act = menu.addAction(_("Unfreeze"), lambda: self.main_window.set_frozen_state_of_addresses([addr], False))
act.setToolTip(MSG_FREEZE_ADDRESS)
else:
# multiple items selected
menu.addAction(_("Freeze"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, True))
menu.addAction(_("Unfreeze"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, False))
act = menu.addAction(_("Freeze"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, True))
act.setToolTip(MSG_FREEZE_ADDRESS)
act = menu.addAction(_("Unfreeze"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, False))
act.setToolTip(MSG_FREEZE_ADDRESS)
coins = self.wallet.get_spendable_coins(addrs)
if coins:

25
electrum/gui/qt/utxo_list.py

@ -40,6 +40,7 @@ from electrum.util import profiler
from .util import ColorScheme, MONOSPACE_FONT, EnterButton
from .my_treeview import MyTreeView
from .new_channel_dialog import NewChannelDialog
from ..messages import MSG_FREEZE_ADDRESS, MSG_FREEZE_COIN
if TYPE_CHECKING:
from .main_window import ElectrumWindow
@ -317,28 +318,36 @@ class UTXOList(MyTreeView):
utxo = coins[0]
addr = utxo.address
menu_freeze = menu.addMenu(_("Freeze"))
menu_freeze.setToolTipsVisible(True)
if not self.wallet.is_frozen_coin(utxo):
menu_freeze.addAction(_("Freeze Coin"), lambda: self.main_window.set_frozen_state_of_coins([utxo], True))
act = menu_freeze.addAction(_("Freeze Coin"), lambda: self.main_window.set_frozen_state_of_coins([utxo], True))
else:
menu_freeze.addAction(_("Unfreeze Coin"), lambda: self.main_window.set_frozen_state_of_coins([utxo], False))
act = menu_freeze.addAction(_("Unfreeze Coin"), lambda: self.main_window.set_frozen_state_of_coins([utxo], False))
act.setToolTip(MSG_FREEZE_COIN)
if not self.wallet.is_frozen_address(addr):
menu_freeze.addAction(_("Freeze Address"), lambda: self.main_window.set_frozen_state_of_addresses([addr], True))
act = menu_freeze.addAction(_("Freeze Address"), lambda: self.main_window.set_frozen_state_of_addresses([addr], True))
else:
menu_freeze.addAction(_("Unfreeze Address"), lambda: self.main_window.set_frozen_state_of_addresses([addr], False))
act = menu_freeze.addAction(_("Unfreeze Address"), lambda: self.main_window.set_frozen_state_of_addresses([addr], False))
act.setToolTip(MSG_FREEZE_ADDRESS)
elif len(coins) > 1: # multiple items selected
menu.addSeparator()
addrs = [utxo.address for utxo in coins]
is_coin_frozen = [self.wallet.is_frozen_coin(utxo) for utxo in coins]
is_addr_frozen = [self.wallet.is_frozen_address(utxo.address) for utxo in coins]
menu_freeze = menu.addMenu(_("Freeze"))
menu_freeze.setToolTipsVisible(True)
if not all(is_coin_frozen):
menu_freeze.addAction(_("Freeze Coins"), lambda: self.main_window.set_frozen_state_of_coins(coins, True))
act = menu_freeze.addAction(_("Freeze Coins"), lambda: self.main_window.set_frozen_state_of_coins(coins, True))
act.setToolTip(MSG_FREEZE_COIN)
if any(is_coin_frozen):
menu_freeze.addAction(_("Unfreeze Coins"), lambda: self.main_window.set_frozen_state_of_coins(coins, False))
act = menu_freeze.addAction(_("Unfreeze Coins"), lambda: self.main_window.set_frozen_state_of_coins(coins, False))
act.setToolTip(MSG_FREEZE_COIN)
if not all(is_addr_frozen):
menu_freeze.addAction(_("Freeze Addresses"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, True))
act = menu_freeze.addAction(_("Freeze Addresses"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, True))
act.setToolTip(MSG_FREEZE_ADDRESS)
if any(is_addr_frozen):
menu_freeze.addAction(_("Unfreeze Addresses"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, False))
act = menu_freeze.addAction(_("Unfreeze Addresses"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, False))
act.setToolTip(MSG_FREEZE_ADDRESS)
menu.exec_(self.viewport().mapToGlobal(position))

Loading…
Cancel
Save