kivy: scan_qr_non_android: handle user closing window
handle user closing window without scanning a qr code (i.e. cancelling scan)
This commit is contained in:
@@ -444,7 +444,7 @@ class ElectrumWindow(App, Logger):
|
|||||||
self.show_error("invoice error:" + pr.error)
|
self.show_error("invoice error:" + pr.error)
|
||||||
self.send_screen.do_clear()
|
self.send_screen.do_clear()
|
||||||
|
|
||||||
def on_qr(self, data):
|
def on_qr(self, data: str):
|
||||||
from electrum.bitcoin import is_address
|
from electrum.bitcoin import is_address
|
||||||
data = data.strip()
|
data = data.strip()
|
||||||
if is_address(data):
|
if is_address(data):
|
||||||
@@ -548,7 +548,8 @@ class ElectrumWindow(App, Logger):
|
|||||||
try:
|
try:
|
||||||
video_dev = self.electrum_config.get_video_device()
|
video_dev = self.electrum_config.get_video_device()
|
||||||
data = qrscanner.scan_barcode(video_dev)
|
data = qrscanner.scan_barcode(video_dev)
|
||||||
on_complete(data)
|
if data is not None:
|
||||||
|
on_complete(data)
|
||||||
except UserFacingException as e:
|
except UserFacingException as e:
|
||||||
self.show_error(e)
|
self.show_error(e)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from .util import UserFacingException
|
from .util import UserFacingException
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
@@ -53,7 +54,7 @@ except BaseException as e1:
|
|||||||
_logger.error(f"failed to load zbar. exceptions: {[e1,e2]!r}")
|
_logger.error(f"failed to load zbar. exceptions: {[e1,e2]!r}")
|
||||||
|
|
||||||
|
|
||||||
def scan_barcode_ctypes(device='', timeout=-1, display=True, threaded=False):
|
def scan_barcode_ctypes(device='', timeout=-1, display=True, threaded=False) -> Optional[str]:
|
||||||
if libzbar is None:
|
if libzbar is None:
|
||||||
raise UserFacingException("Cannot start QR scanner: zbar not available.")
|
raise UserFacingException("Cannot start QR scanner: zbar not available.")
|
||||||
libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p
|
libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p
|
||||||
|
|||||||
Reference in New Issue
Block a user