tkivy: remove hidden state in RefLabel, use it for seed and private keys - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit ab5a02ba5051c94904af9e532f027f963e4c5f7b DIR parent e9c32bad1946d8ef07b8018f6578d7ed4782ca7a HTML Author: ThomasV <thomasv@electrum.org> Date: Fri, 23 Aug 2019 15:46:58 +0200 kivy: remove hidden state in RefLabel, use it for seed and private keys Diffstat: M electrum/gui/kivy/main.kv | 7 ++++--- M electrum/gui/kivy/main_window.py | 16 ++++++---------- M electrum/gui/kivy/uix/dialogs/addr… | 31 ++++++++++++++++--------------- M electrum/gui/kivy/uix/ui_screens/s… | 21 +++++++++++---------- 4 files changed, 37 insertions(+), 38 deletions(-) --- DIR diff --git a/electrum/gui/kivy/main.kv b/electrum/gui/kivy/main.kv t@@ -133,13 +133,14 @@ font_size: '6pt' name: '' data: '' - text: self.data + text: self.data if self.data else _('Tap to show') touched: False padding: '10dp', '10dp' on_touch_down: touch = args[1] - if self.collide_point(*touch.pos): app.on_ref_label(self, touch) - else: self.touched = False + touched = bool(self.collide_point(*touch.pos)) + if touched: app.on_ref_label(self) + if touched: self.touched = True canvas.before: Color: rgb: .3, .3, .3 DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py t@@ -856,14 +856,10 @@ class ElectrumWindow(App): self._orientation = 'landscape' if width > height else 'portrait' self._ui_mode = 'tablet' if min(width, height) > inch(3.51) else 'phone' - def on_ref_label(self, label, touch): - if label.touched: - label.touched = False - self.qr_dialog(label.name, label.data, True) - else: - label.touched = True - self._clipboard.copy(label.data) - Clock.schedule_once(lambda dt: self.show_info(_('Text copied to clipboard.\nTap again to display it as QR code.'))) + def on_ref_label(self, label): + if not label.data: + return + self.qr_dialog(label.name, label.data, True) def show_error(self, error, width='200dp', pos=None, arrow_pos=None, exit=False, icon='atlas://electrum/gui/kivy/theming/light/error', duration=0, t@@ -1064,9 +1060,9 @@ class ElectrumWindow(App): except: self.show_error("Invalid PIN") return - label.text = _('Seed') + ':\n' + seed + label.data = seed if passphrase: - label.text += '\n\n' + _('Passphrase') + ': ' + passphrase + label.data += '\n\n' + _('Passphrase') + ': ' + passphrase def password_dialog(self, wallet, msg, on_success, on_failure): from .uix.dialogs.password_dialog import PasswordDialog DIR diff --git a/electrum/gui/kivy/uix/dialogs/addresses.py b/electrum/gui/kivy/uix/dialogs/addresses.py t@@ -103,6 +103,7 @@ Builder.load_string(''' address: '' balance: '' status: '' + script_type: '' pk: '' BoxLayout: orientation: 'vertical' t@@ -113,26 +114,31 @@ Builder.load_string(''' size_hint_y: None padding: '10dp' spacing: '10dp' + TopLabel: + text: _('Address') + RefLabel: + data: root.address + name: _('Address') GridLayout: cols: 1 size_hint_y: None height: self.minimum_height spacing: '10dp' BoxLabel: - text: _('Address') - value: root.address - BoxLabel: text: _('Balance') value: root.balance BoxLabel: + text: _('Script type') + value: root.script_type + BoxLabel: text: _('Status') value: root.status TopLabel: text: _('Private Key') RefLabel: - id: pk_label - touched: True if not self.touched else True data: root.pk + name: _('Private key') + on_touched: if not self.data: root.do_export(self) Widget: size_hint: 1, 0.1 BoxLayout: t@@ -141,14 +147,8 @@ Builder.load_string(''' Button: size_hint: 0.5, None height: '48dp' - text: _('Hide key') if pk_label.data else _('Show key') - on_release: - setattr(pk_label, 'data', '') if pk_label.data else root.do_export(pk_label) - Button: - size_hint: 0.5, None - height: '48dp' - text: _('Use') - on_release: root.do_use() + text: _('Receive') + on_release: root.receive_at() Button: size_hint: 0.5, None height: '48dp' t@@ -162,14 +162,15 @@ class AddressPopup(Popup): def __init__(self, parent, address, balance, status, **kwargs): super(AddressPopup, self).__init__(**kwargs) - self.title = _('Address') + self.title = _('Address Details') self.parent_dialog = parent self.app = parent.app self.address = address self.status = status + self.script_type = self.app.wallet.get_txin_type(self.address) self.balance = self.app.format_amount_and_units(balance) - def do_use(self): + def receive_at(self): self.dismiss() self.parent_dialog.dismiss() self.app.switch_to('receive') DIR diff --git a/electrum/gui/kivy/uix/ui_screens/status.kv b/electrum/gui/kivy/uix/ui_screens/status.kv t@@ -59,11 +59,13 @@ Popup: RefLabel: data: app.wallet.get_master_public_key() or 'None' name: _('Master Public Key') - - - TopLabel: - id: seed_label - text: _('This wallet is watching-only') if root.watching_only else '' + TopLabel: + text: _('This wallet is watching-only') if root.watching_only else _('Seed') + RefLabel: + id: seed_label + data: '' + name: _('Seed') + on_touched: if not self.data and not root.watching_only: app.show_seed(seed_label) BoxLayout: size_hint: 1, None t@@ -71,14 +73,13 @@ Popup: Button: size_hint: 0.5, None height: '48dp' - text: '' if not root.has_seed else (_('Hide seed') if seed_label.text else _('Show seed')) - disabled: not root.has_seed + text: _('Delete') on_release: - setattr(seed_label, 'text', '') if seed_label.text else app.show_seed(seed_label) + root.dismiss() + app.delete_wallet() Button: size_hint: 0.5, None height: '48dp' - text: _('Delete') + text: _('Close') on_release: root.dismiss() - app.delete_wallet()