kivy: improve ref label and QR codes
This commit is contained in:
@@ -127,12 +127,15 @@
|
|||||||
|
|
||||||
<RefLabel@TopLabel>
|
<RefLabel@TopLabel>
|
||||||
font_size: '6pt'
|
font_size: '6pt'
|
||||||
ref_text: ''
|
name: ''
|
||||||
text: self.ref_text
|
data: ''
|
||||||
|
text: self.data
|
||||||
|
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.ref_text, touch)
|
if self.collide_point(*touch.pos): app.on_ref_label(self, touch)
|
||||||
|
else: self.touched = False
|
||||||
canvas.before:
|
canvas.before:
|
||||||
Color:
|
Color:
|
||||||
rgb: .3, .3, .3
|
rgb: .3, .3, .3
|
||||||
@@ -141,9 +144,8 @@
|
|||||||
pos: self.pos
|
pos: self.pos
|
||||||
|
|
||||||
<TxHashLabel@RefLabel>
|
<TxHashLabel@RefLabel>
|
||||||
tx_hash: ''
|
data: ''
|
||||||
ref_text: self.tx_hash
|
text: ' '.join(map(''.join, zip(*[iter(self.data)]*4))) if self.data else ''
|
||||||
text: ' '.join(map(''.join, zip(*[iter(self.tx_hash)]*4))) if self.tx_hash else ''
|
|
||||||
|
|
||||||
<InfoBubble>
|
<InfoBubble>
|
||||||
size_hint: None, None
|
size_hint: None, None
|
||||||
|
|||||||
@@ -299,9 +299,9 @@ class ElectrumWindow(App):
|
|||||||
popup.on_open = lambda: popup.ids.output_list.update(req.get('outputs', []))
|
popup.on_open = lambda: popup.ids.output_list.update(req.get('outputs', []))
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
def qr_dialog(self, title, data):
|
def qr_dialog(self, title, data, show_text=False):
|
||||||
from uix.dialogs.qr_dialog import QRDialog
|
from uix.dialogs.qr_dialog import QRDialog
|
||||||
popup = QRDialog(title, data)
|
popup = QRDialog(title, data, show_text)
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
||||||
def scan_qr(self, on_complete):
|
def scan_qr(self, on_complete):
|
||||||
@@ -600,12 +600,14 @@ 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, text, touch):
|
def on_ref_label(self, label, touch):
|
||||||
if touch.is_double_tap:
|
if label.touched:
|
||||||
self.qr_dialog(_('Share with QR Code'), text)
|
label.touched = False
|
||||||
|
self.qr_dialog(label.name, label.data, True)
|
||||||
else:
|
else:
|
||||||
self._clipboard.copy(text)
|
label.touched = True
|
||||||
self.show_info(_('Text copied to clipboard'))
|
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):
|
def set_send(self, address, amount, label, message):
|
||||||
self.send_payment(address, amount=amount, label=label, message=message)
|
self.send_payment(address, amount=amount, label=label, message=message)
|
||||||
|
|||||||
@@ -7,15 +7,18 @@ Builder.load_string('''
|
|||||||
title: ''
|
title: ''
|
||||||
data: ''
|
data: ''
|
||||||
shaded: False
|
shaded: False
|
||||||
|
show_text: False
|
||||||
AnchorLayout:
|
AnchorLayout:
|
||||||
anchor_x: 'center'
|
anchor_x: 'center'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
|
padding: '10dp'
|
||||||
|
spacing: '10dp'
|
||||||
QRCodeWidget:
|
QRCodeWidget:
|
||||||
id: qr
|
id: qr
|
||||||
TopLabel:
|
TopLabel:
|
||||||
text: root.data
|
text: root.data if root.show_text else ''
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.2
|
size_hint: 1, 0.2
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
@@ -33,10 +36,11 @@ Builder.load_string('''
|
|||||||
''')
|
''')
|
||||||
|
|
||||||
class QRDialog(Factory.Popup):
|
class QRDialog(Factory.Popup):
|
||||||
def __init__(self, title, data):
|
def __init__(self, title, data, show_text):
|
||||||
Factory.Popup.__init__(self)
|
Factory.Popup.__init__(self)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.data = data
|
self.data = data
|
||||||
|
self.show_text = show_text
|
||||||
|
|
||||||
def on_open(self):
|
def on_open(self):
|
||||||
self.ids.qr.set_data(self.data)
|
self.ids.qr.set_data(self.data)
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ Builder.load_string('''
|
|||||||
TopLabel:
|
TopLabel:
|
||||||
text: _('Transaction ID') + ':' if root.tx_hash else ''
|
text: _('Transaction ID') + ':' if root.tx_hash else ''
|
||||||
TxHashLabel:
|
TxHashLabel:
|
||||||
tx_hash: root.tx_hash
|
data: root.tx_hash
|
||||||
|
name: _('Transaction ID')
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ Popup:
|
|||||||
TopLabel:
|
TopLabel:
|
||||||
text: _('Transaction ID') if popup.tx_hash else ''
|
text: _('Transaction ID') if popup.tx_hash else ''
|
||||||
TxHashLabel:
|
TxHashLabel:
|
||||||
tx_hash: popup.tx_hash
|
data: popup.tx_hash
|
||||||
|
name: _('Transaction ID')
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ Popup:
|
|||||||
TopLabel:
|
TopLabel:
|
||||||
text: _('Master Public Key')
|
text: _('Master Public Key')
|
||||||
RefLabel:
|
RefLabel:
|
||||||
ref_text: app.wallet.get_master_public_key()
|
data: app.wallet.get_master_public_key()
|
||||||
|
name: _('Master Public Key')
|
||||||
TopLabel:
|
TopLabel:
|
||||||
text: ''
|
text: ''
|
||||||
id: seed_label
|
id: seed_label
|
||||||
|
|||||||
Reference in New Issue
Block a user