Skip to content

Commit

Permalink
Refactor into staticmethod _get_schnorr_sigil
Browse files Browse the repository at this point in the history
  • Loading branch information
gasull committed Apr 8, 2021
1 parent e997f76 commit 92bb4e9
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions electroncash_gui/qt/transaction_dialog.py
Expand Up @@ -50,21 +50,6 @@

dialogs = [] # Otherwise python randomly garbage collects the dialogs...

should_use_freetype = False
if sys.platform in {"cygwin", "win32"}:
config = get_config()
if config is None:
should_use_freetype = False
else:
should_use_freetype = bool(config.get("windows_qt_use_freetype"))

if should_use_freetype:
# NB: on Qt for Windows the 'ⓢ' symbol looks aliased and bad. So we do this
# for windows.
SCHNORR_SIGIL = "(S)"
else:
# On Linux & macOS it looks fine so we go with the more fancy unicode
SCHNORR_SIGIL = "ⓢ"

def show_transaction(tx, parent, desc=None, prompt_if_unsaved=False):
d = TxDialog(tx, parent, desc, prompt_if_unsaved)
Expand Down Expand Up @@ -554,7 +539,10 @@ def add_io(self, vbox):
# it makes no sense to enable this checkbox if the network is offline
chk.setHidden(True)

self.schnorr_label = QLabel(_('{} = Schnorr signed').format(SCHNORR_SIGIL))
schnorr_sigil = TxDialog._get_schnorr_sigil()
self.schnorr_label = QLabel(
_('{} = Schnorr signed').format(schnorr_sigil)
)
self.schnorr_label.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
f = self.schnorr_label.font()
f.setPointSize(f.pointSize()-1) # make it a little smaller
Expand Down Expand Up @@ -680,7 +668,8 @@ def format_amount(amt):
cursor.insertText(format_amount(x['value']), ext)
if self.tx.is_schnorr_signed(i):
# Schnorr
cursor.insertText(' {}'.format(SCHNORR_SIGIL), ext)
schnorr_sigil = TxDialog._get_schnorr_sigil()
cursor.insertText(' {}'.format(schnorr_sigil), ext)
has_schnorr = True
cursor.insertBlock()

Expand Down Expand Up @@ -911,3 +900,20 @@ def on_context_menu_for_outputs(self, pos):
menu.addAction(_("Copy Selected Text"), lambda: self._copy_to_clipboard(None, o_text))
menu.addAction(_("Select All"), o_text.selectAll)
menu.exec_(global_pos)

@staticmethod
def _get_schnorr_sigil() -> str:
"""Get the right symbol for the platform"""
should_use_freetype = False
if sys.platform in {"cygwin", "win32"}:
config = get_config()
if config is not None:
windows_qt_use_freetype = config.get("windows_qt_use_freetype")
should_use_freetype = bool(windows_qt_use_freetype)

if should_use_freetype:
# On Qt for Windows the 'ⓢ' symbol looks aliased and bad. So we
# do this for windows.
return "(S)"
# On Linux & macOS it looks fine so we go with the more fancy unicode
return "ⓢ"

0 comments on commit 92bb4e9

Please sign in to comment.