Browse Source

qt wizard: fix scanning qr code when restoring from xpub

fixes #6342
bip39-recovery
SomberNight 5 years ago
parent
commit
1c9a6f5770
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/gui/qt/qrtextedit.py
  2. 13
      electrum/gui/qt/util.py

6
electrum/gui/qt/qrtextedit.py

@ -60,9 +60,9 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
def qr_input(self):
from electrum import qrscanner
main_window = get_parent_main_window(self)
assert main_window
config = main_window.config
window_or_wizard = get_parent_main_window(self, allow_wizard=True)
assert window_or_wizard
config = window_or_wizard.config
try:
data = qrscanner.scan_barcode(config.get_video_device())
except BaseException as e:

13
electrum/gui/qt/util.py

@ -30,6 +30,7 @@ from electrum.invoices import PR_UNPAID, PR_PAID, PR_EXPIRED, PR_INFLIGHT, PR_UN
if TYPE_CHECKING:
from .main_window import ElectrumWindow
from .installwizard import InstallWizard
if platform.system() == 'Windows':
@ -945,19 +946,23 @@ def export_meta_gui(electrum_window, title, exporter):
.format(title, str(filename)))
def get_parent_main_window(widget):
def get_parent_main_window(
widget, *, allow_wizard: bool = False,
) -> Union[None, 'ElectrumWindow', 'InstallWizard']:
"""Returns a reference to the ElectrumWindow this widget belongs to."""
from .main_window import ElectrumWindow
from .transaction_dialog import TxDialog
from .installwizard import InstallWizard
for _ in range(100):
if widget is None:
return None
if isinstance(widget, ElectrumWindow):
return widget
elif isinstance(widget, TxDialog):
if isinstance(widget, TxDialog):
return widget.main_window
else:
widget = widget.parentWidget()
if isinstance(widget, InstallWizard) and allow_wizard:
return widget
widget = widget.parentWidget()
return None

Loading…
Cancel
Save