Browse Source

kivy: remove hidden state in RefLabel, use it for seed and private keys

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 5 years ago
parent
commit
ab5a02ba50
  1. 7
      electrum/gui/kivy/main.kv
  2. 14
      electrum/gui/kivy/main_window.py
  3. 31
      electrum/gui/kivy/uix/dialogs/addresses.py
  4. 17
      electrum/gui/kivy/uix/ui_screens/status.kv

7
electrum/gui/kivy/main.kv

@ -133,13 +133,14 @@
font_size: '6pt' font_size: '6pt'
name: '' name: ''
data: '' data: ''
text: self.data text: self.data if self.data else _('Tap to show')
touched: False touched: False
padding: '10dp', '10dp' padding: '10dp', '10dp'
on_touch_down: on_touch_down:
touch = args[1] touch = args[1]
if self.collide_point(*touch.pos): app.on_ref_label(self, touch) touched = bool(self.collide_point(*touch.pos))
else: self.touched = False if touched: app.on_ref_label(self)
if touched: self.touched = True
canvas.before: canvas.before:
Color: Color:
rgb: .3, .3, .3 rgb: .3, .3, .3

14
electrum/gui/kivy/main_window.py

@ -856,14 +856,10 @@ class ElectrumWindow(App):
self._orientation = 'landscape' if width > height else 'portrait' self._orientation = 'landscape' if width > height else 'portrait'
self._ui_mode = 'tablet' if min(width, height) > inch(3.51) else 'phone' self._ui_mode = 'tablet' if min(width, height) > inch(3.51) else 'phone'
def on_ref_label(self, label, touch): def on_ref_label(self, label):
if label.touched: if not label.data:
label.touched = False return
self.qr_dialog(label.name, label.data, True) 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 show_error(self, error, width='200dp', pos=None, arrow_pos=None, def show_error(self, error, width='200dp', pos=None, arrow_pos=None,
exit=False, icon='atlas://electrum/gui/kivy/theming/light/error', duration=0, exit=False, icon='atlas://electrum/gui/kivy/theming/light/error', duration=0,
@ -1064,9 +1060,9 @@ class ElectrumWindow(App):
except: except:
self.show_error("Invalid PIN") self.show_error("Invalid PIN")
return return
label.text = _('Seed') + ':\n' + seed label.data = seed
if passphrase: if passphrase:
label.text += '\n\n' + _('Passphrase') + ': ' + passphrase label.data += '\n\n' + _('Passphrase') + ': ' + passphrase
def password_dialog(self, wallet, msg, on_success, on_failure): def password_dialog(self, wallet, msg, on_success, on_failure):
from .uix.dialogs.password_dialog import PasswordDialog from .uix.dialogs.password_dialog import PasswordDialog

31
electrum/gui/kivy/uix/dialogs/addresses.py

@ -103,6 +103,7 @@ Builder.load_string('''
address: '' address: ''
balance: '' balance: ''
status: '' status: ''
script_type: ''
pk: '' pk: ''
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
@ -113,26 +114,31 @@ Builder.load_string('''
size_hint_y: None size_hint_y: None
padding: '10dp' padding: '10dp'
spacing: '10dp' spacing: '10dp'
TopLabel:
text: _('Address')
RefLabel:
data: root.address
name: _('Address')
GridLayout: GridLayout:
cols: 1 cols: 1
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
spacing: '10dp' spacing: '10dp'
BoxLabel:
text: _('Address')
value: root.address
BoxLabel: BoxLabel:
text: _('Balance') text: _('Balance')
value: root.balance value: root.balance
BoxLabel:
text: _('Script type')
value: root.script_type
BoxLabel: BoxLabel:
text: _('Status') text: _('Status')
value: root.status value: root.status
TopLabel: TopLabel:
text: _('Private Key') text: _('Private Key')
RefLabel: RefLabel:
id: pk_label
touched: True if not self.touched else True
data: root.pk data: root.pk
name: _('Private key')
on_touched: if not self.data: root.do_export(self)
Widget: Widget:
size_hint: 1, 0.1 size_hint: 1, 0.1
BoxLayout: BoxLayout:
@ -141,14 +147,8 @@ Builder.load_string('''
Button: Button:
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
text: _('Hide key') if pk_label.data else _('Show key') text: _('Receive')
on_release: on_release: root.receive_at()
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()
Button: Button:
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
@ -162,14 +162,15 @@ class AddressPopup(Popup):
def __init__(self, parent, address, balance, status, **kwargs): def __init__(self, parent, address, balance, status, **kwargs):
super(AddressPopup, self).__init__(**kwargs) super(AddressPopup, self).__init__(**kwargs)
self.title = _('Address') self.title = _('Address Details')
self.parent_dialog = parent self.parent_dialog = parent
self.app = parent.app self.app = parent.app
self.address = address self.address = address
self.status = status self.status = status
self.script_type = self.app.wallet.get_txin_type(self.address)
self.balance = self.app.format_amount_and_units(balance) self.balance = self.app.format_amount_and_units(balance)
def do_use(self): def receive_at(self):
self.dismiss() self.dismiss()
self.parent_dialog.dismiss() self.parent_dialog.dismiss()
self.app.switch_to('receive') self.app.switch_to('receive')

17
electrum/gui/kivy/uix/ui_screens/status.kv

@ -59,11 +59,13 @@ Popup:
RefLabel: RefLabel:
data: app.wallet.get_master_public_key() or 'None' data: app.wallet.get_master_public_key() or 'None'
name: _('Master Public Key') name: _('Master Public Key')
TopLabel: TopLabel:
text: _('This wallet is watching-only') if root.watching_only else _('Seed')
RefLabel:
id: seed_label id: seed_label
text: _('This wallet is watching-only') if root.watching_only else '' data: ''
name: _('Seed')
on_touched: if not self.data and not root.watching_only: app.show_seed(seed_label)
BoxLayout: BoxLayout:
size_hint: 1, None size_hint: 1, None
@ -71,14 +73,13 @@ Popup:
Button: Button:
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
text: '' if not root.has_seed else (_('Hide seed') if seed_label.text else _('Show seed')) text: _('Delete')
disabled: not root.has_seed
on_release: on_release:
setattr(seed_label, 'text', '') if seed_label.text else app.show_seed(seed_label) root.dismiss()
app.delete_wallet()
Button: Button:
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
text: _('Delete') text: _('Close')
on_release: on_release:
root.dismiss() root.dismiss()
app.delete_wallet()

Loading…
Cancel
Save