Abstract and enable qrscanner dialog for send screen.
This commit is contained in:
@@ -9,12 +9,7 @@ class NewContactDialog(Factory.AnimatedPopup):
|
||||
|
||||
def load_qr_scanner(self):
|
||||
self.dismiss()
|
||||
dlg = Cache.get('electrum_widgets', 'QrScannerDialog')
|
||||
if not dlg:
|
||||
dlg = Factory.QrScannerDialog()
|
||||
Cache.append('electrum_widgets', 'QrScannerDialog', dlg)
|
||||
dlg.bind(on_complete=self.on_complete)
|
||||
dlg.open()
|
||||
App.get_running_app().scan_qr(on_complete=self.on_complete)
|
||||
|
||||
def on_complete(self, instance, uri):
|
||||
self.new_contact(uri=uri)
|
||||
|
||||
@@ -4,9 +4,9 @@ from kivy.lang import Builder
|
||||
|
||||
Factory.register('QRScanner', module='electrum_gui.kivy.qr_scanner')
|
||||
|
||||
class QrScannerDialog(Factory.AnimaterPopup):
|
||||
class QrScannerDialog(Factory.AnimatedPopup):
|
||||
|
||||
__events__('on_complete', )
|
||||
__events__ = ('on_complete', )
|
||||
|
||||
def on_symbols(self, instance, value):
|
||||
instance.stop()
|
||||
@@ -18,6 +18,11 @@ class QrScannerDialog(Factory.AnimaterPopup):
|
||||
#message = uir.get('message', '')
|
||||
self.dispatch('on_omplete', uri)
|
||||
|
||||
def on_complete(self):
|
||||
''' Default Handler for on_complete event.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
Builder.load_string('''
|
||||
<QrScannerDialog>
|
||||
@@ -27,7 +32,7 @@ Builder.load_string('''
|
||||
title_size: '24sp'
|
||||
border: 7, 7, 7, 7
|
||||
size_hint: None, None
|
||||
size: '320dp', '270dp'
|
||||
size: '340dp', '290dp'
|
||||
pos_hint: {'center_y': .53}
|
||||
separator_color: .89, .89, .89, 1
|
||||
separator_height: '1.2dp'
|
||||
|
||||
@@ -101,12 +101,13 @@ class MainScreen(Factory.Screen):
|
||||
|
||||
class ScreenSend(CScreen):
|
||||
|
||||
def scan_qr(self):
|
||||
pop = Factory.QrScannerDialog(on_complete=self.set_qr_data)
|
||||
pop.open()
|
||||
|
||||
def set_qr_data(self, uri):
|
||||
self.ids.payto_e
|
||||
self.ids.payto_e.text = uri.get('address')
|
||||
self.ids.message_e.text = uri.get('message')
|
||||
self.ids.amount_e.text = uri.get('amount')
|
||||
#label = uri.get('label')
|
||||
#if label:
|
||||
# TODO: update label, add to contacts
|
||||
|
||||
|
||||
class ScreenReceive(CScreen):
|
||||
|
||||
@@ -336,7 +336,7 @@
|
||||
pos_hint: {'center_y': .5}
|
||||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
on_release: root.scan_qr()
|
||||
on_release: app.scan_qr(on_complete=root.set_qr_data)
|
||||
CardSeparator
|
||||
opacity: message_selection.opacity
|
||||
color: blue_bottom.foreground_color
|
||||
|
||||
Reference in New Issue
Block a user