commit 74a822ae56d2309d7e69a090fe314007519eed98
parent 34ddaaa419889cb62fd81b2dbdc56c58e6d5469b
Author: ThomasV <thomasv@electrum.org>
Date: Thu, 18 Feb 2016 13:53:23 +0100
kivy: improve ref label and QR codes
Diffstat:
6 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv
@@ -127,12 +127,15 @@
<RefLabel@TopLabel>
font_size: '6pt'
- ref_text: ''
- text: self.ref_text
+ name: ''
+ data: ''
+ text: self.data
+ touched: False
padding: '10dp', '10dp'
on_touch_down:
touch = args[1]
- if self.collide_point(*touch.pos): app.on_ref_label(self.ref_text, touch)
+ if self.collide_point(*touch.pos): app.on_ref_label(self, touch)
+ else: self.touched = False
canvas.before:
Color:
rgb: .3, .3, .3
@@ -141,9 +144,8 @@
pos: self.pos
<TxHashLabel@RefLabel>
- tx_hash: ''
- ref_text: self.tx_hash
- text: ' '.join(map(''.join, zip(*[iter(self.tx_hash)]*4))) if self.tx_hash else ''
+ data: ''
+ text: ' '.join(map(''.join, zip(*[iter(self.data)]*4))) if self.data else ''
<InfoBubble>
size_hint: None, None
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -299,9 +299,9 @@ class ElectrumWindow(App):
popup.on_open = lambda: popup.ids.output_list.update(req.get('outputs', []))
popup.open()
- def qr_dialog(self, title, data):
+ def qr_dialog(self, title, data, show_text=False):
from uix.dialogs.qr_dialog import QRDialog
- popup = QRDialog(title, data)
+ popup = QRDialog(title, data, show_text)
popup.open()
def scan_qr(self, on_complete):
@@ -600,12 +600,14 @@ 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, text, touch):
- if touch.is_double_tap:
- self.qr_dialog(_('Share with QR Code'), text)
+ def on_ref_label(self, label, touch):
+ if label.touched:
+ label.touched = False
+ self.qr_dialog(label.name, label.data, True)
else:
- self._clipboard.copy(text)
- self.show_info(_('Text copied to clipboard'))
+ 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 set_send(self, address, amount, label, message):
self.send_payment(address, amount=amount, label=label, message=message)
diff --git a/gui/kivy/uix/dialogs/qr_dialog.py b/gui/kivy/uix/dialogs/qr_dialog.py
@@ -7,15 +7,18 @@ Builder.load_string('''
title: ''
data: ''
shaded: False
+ show_text: False
AnchorLayout:
anchor_x: 'center'
BoxLayout:
orientation: 'vertical'
size_hint: 1, 1
+ padding: '10dp'
+ spacing: '10dp'
QRCodeWidget:
id: qr
TopLabel:
- text: root.data
+ text: root.data if root.show_text else ''
Widget:
size_hint: 1, 0.2
BoxLayout:
@@ -33,10 +36,11 @@ Builder.load_string('''
''')
class QRDialog(Factory.Popup):
- def __init__(self, title, data):
+ def __init__(self, title, data, show_text):
Factory.Popup.__init__(self)
self.title = title
self.data = data
+ self.show_text = show_text
def on_open(self):
self.ids.qr.set_data(self.data)
diff --git a/gui/kivy/uix/dialogs/tx_dialog.py b/gui/kivy/uix/dialogs/tx_dialog.py
@@ -62,8 +62,8 @@ Builder.load_string('''
TopLabel:
text: _('Transaction ID') + ':' if root.tx_hash else ''
TxHashLabel:
- tx_hash: root.tx_hash
-
+ data: root.tx_hash
+ name: _('Transaction ID')
Widget:
size_hint: 1, 0.1
diff --git a/gui/kivy/uix/ui_screens/invoice.kv b/gui/kivy/uix/ui_screens/invoice.kv
@@ -53,8 +53,8 @@ Popup:
TopLabel:
text: _('Transaction ID') if popup.tx_hash else ''
TxHashLabel:
- tx_hash: popup.tx_hash
-
+ data: popup.tx_hash
+ name: _('Transaction ID')
Widget:
size_hint: 1, 0.1
diff --git a/gui/kivy/uix/ui_screens/status.kv b/gui/kivy/uix/ui_screens/status.kv
@@ -51,8 +51,8 @@ Popup:
TopLabel:
text: _('Master Public Key')
RefLabel:
- ref_text: app.wallet.get_master_public_key()
-
+ data: app.wallet.get_master_public_key()
+ name: _('Master Public Key')
TopLabel:
text: ''
id: seed_label