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. """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.""" 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 .util import MONOSPACE_FONT, ColorScheme, webopen
from .my_treeview import MyTreeView, MySortModel from .my_treeview import MyTreeView, MySortModel
from ..messages import MSG_FREEZE_ADDRESS
if TYPE_CHECKING: if TYPE_CHECKING:
from .main_window import ElectrumWindow from .main_window import ElectrumWindow
@ -284,6 +285,7 @@ class AddressList(MyTreeView):
multi_select = len(selected) > 1 multi_select = len(selected) > 1
addrs = [self.item_from_index(item).text() for item in selected] addrs = [self.item_from_index(item).text() for item in selected]
menu = QMenu() menu = QMenu()
menu.setToolTipsVisible(True)
if not multi_select: if not multi_select:
idx = self.indexAt(position) idx = self.indexAt(position)
if not idx.isValid(): if not idx.isValid():
@ -311,14 +313,17 @@ class AddressList(MyTreeView):
menu.addAction(_("View on block explorer"), lambda: webopen(addr_URL)) menu.addAction(_("View on block explorer"), lambda: webopen(addr_URL))
if not self.wallet.is_frozen_address(addr): 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: 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: else:
# multiple items selected # multiple items selected
menu.addAction(_("Freeze"), lambda: self.main_window.set_frozen_state_of_addresses(addrs, True)) act = 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.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) coins = self.wallet.get_spendable_coins(addrs)
if coins: 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 .util import ColorScheme, MONOSPACE_FONT, EnterButton
from .my_treeview import MyTreeView from .my_treeview import MyTreeView
from .new_channel_dialog import NewChannelDialog from .new_channel_dialog import NewChannelDialog
from ..messages import MSG_FREEZE_ADDRESS, MSG_FREEZE_COIN
if TYPE_CHECKING: if TYPE_CHECKING:
from .main_window import ElectrumWindow from .main_window import ElectrumWindow
@ -317,28 +318,36 @@ class UTXOList(MyTreeView):
utxo = coins[0] utxo = coins[0]
addr = utxo.address addr = utxo.address
menu_freeze = menu.addMenu(_("Freeze")) menu_freeze = menu.addMenu(_("Freeze"))
menu_freeze.setToolTipsVisible(True)
if not self.wallet.is_frozen_coin(utxo): 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: 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): 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: 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 elif len(coins) > 1: # multiple items selected
menu.addSeparator() menu.addSeparator()
addrs = [utxo.address for utxo in coins] addrs = [utxo.address for utxo in coins]
is_coin_frozen = [self.wallet.is_frozen_coin(utxo) 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] is_addr_frozen = [self.wallet.is_frozen_address(utxo.address) for utxo in coins]
menu_freeze = menu.addMenu(_("Freeze")) menu_freeze = menu.addMenu(_("Freeze"))
menu_freeze.setToolTipsVisible(True)
if not all(is_coin_frozen): 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): 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): 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): 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)) menu.exec_(self.viewport().mapToGlobal(position))

Loading…
Cancel
Save