kivy: qr dialog

This commit is contained in:
ThomasV 2016-02-12 15:21:03 +01:00
parent cc526a8734
commit f2b0b7945d
5 changed files with 53 additions and 8 deletions

View File

@ -267,6 +267,11 @@ class ElectrumWindow(App):
self.switch_to('receive')
self.receive_screen.screen.address = addr
def qr_dialog(self, title, data):
from uix.dialogs.qr_dialog import QRDialog
popup = QRDialog(title, data)
popup.open()
def scan_qr(self, on_complete):
if platform != 'android':
return

View File

@ -0,0 +1,36 @@
from kivy.factory import Factory
from kivy.lang import Builder
Builder.load_string('''
<QRDialog@Popup>
id: popup
title: ''
shaded: False
AnchorLayout:
anchor_x: 'center'
BoxLayout:
orientation: 'vertical'
size_hint: 1, 1
QRCodeWidget:
id: qr
Widget:
size_hint: 1, 0.2
BoxLayout:
size_hint: 1, None
height: '48dp'
Widget:
size_hint: 1, None
height: '48dp'
Button:
size_hint: 1, None
height: '48dp'
text: _('Close')
on_release:
popup.dismiss()
''')
class QRDialog(Factory.Popup):
def __init__(self, title, data):
Factory.Popup.__init__(self)
self.title = title
self.ids.qr.set_data(data)

View File

@ -111,7 +111,7 @@ class QRCodeWidget(FloatLayout):
def _upd_texture(self, buff):
texture = self._qrtexture
texture.blit_buffer(buff, colorfmt='rgb', bufferfmt='ubyte')
img =self.ids.qrimage
img = self.ids.qrimage
img.anim_delay = -1
img.texture = texture
img.canvas.ask_update()

View File

@ -133,12 +133,12 @@ class HistoryScreen(CScreen):
label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
date = timestamp_to_datetime(timestamp)
rate = run_hook('history_rate', date)
if self.app.fiat_unit:
s = run_hook('historical_value_str', value, date)
quote_text = "..." if s is None else s + ' ' + self.app.fiat_unit
else:
quote_text = ''
quote_text = ''
if self.app.fiat_unit and date:
rate = run_hook('history_rate', date)
if rate:
s = run_hook('value_str', value, rate)
quote_text = '' if s is None else s + ' ' + self.app.fiat_unit
yield (conf, icon, time_str, label, value, tx_hash, quote_text)
def update(self, see_all=False):
@ -273,7 +273,10 @@ class SendScreen(CScreen):
self.app.show_error(str(e))
return
if not tx.is_complete():
self.app.show_info("Transaction is not complete")
from electrum.bitcoin import base_encode
text = str(tx).decode('hex')
text = base_encode(text, base=43)
self.app.qr_dialog(_("Unsigned Transaction"), text)
return
# broadcast
ok, txid = self.app.wallet.sendtx(tx)

View File

@ -388,6 +388,7 @@ class FxPlugin(BasePlugin, ThreadJob):
def requires_settings(self):
return True
@hook
def value_str(self, satoshis, rate):
if satoshis is None: # Can happen with incomplete history
return _("Unknown")