qt: PayToEdit: fix input_qr_from_camera
closes https://github.com/spesmilo/electrum/issues/8342
probably regression from 1f4cedf56a
This commit is contained in:
@@ -129,6 +129,7 @@ class PayToEdit(Logger, GenericInputHandler):
|
||||
allow_multi=False,
|
||||
show_error=self.win.show_error,
|
||||
setText=self._on_input_btn,
|
||||
parent=self.win,
|
||||
)
|
||||
self.on_qr_from_screenshot_input_btn = partial(
|
||||
self.input_qr_from_screenshot,
|
||||
|
||||
@@ -49,6 +49,7 @@ def scan_qrcode(
|
||||
callback: Callable[[bool, str, Optional[str]], None],
|
||||
) -> None:
|
||||
"""Scans QR code using camera."""
|
||||
assert parent is None or isinstance(parent, QWidget), f"parent should be a QWidget, not {parent!r}"
|
||||
if sys.platform == 'darwin' or sys.platform in ('windows', 'win32'):
|
||||
_scan_qrcode_using_qtmultimedia(parent=parent, config=config, callback=callback)
|
||||
else: # desktop Linux and similar
|
||||
|
||||
@@ -27,10 +27,10 @@ import time
|
||||
import math
|
||||
import sys
|
||||
import os
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt5.QtMultimedia import QCameraInfo, QCamera, QCameraViewfinderSettings
|
||||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QCheckBox, QPushButton, QLabel
|
||||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QCheckBox, QPushButton, QLabel, QWidget
|
||||
from PyQt5.QtGui import QImage, QPixmap
|
||||
from PyQt5.QtCore import QSize, QRect, Qt, pyqtSignal, PYQT_VERSION
|
||||
|
||||
@@ -68,7 +68,7 @@ class QrReaderCameraDialog(Logger, MessageBoxMixin, QDialog):
|
||||
|
||||
qr_finished = pyqtSignal(bool, str, object)
|
||||
|
||||
def __init__(self, parent, *, config: SimpleConfig):
|
||||
def __init__(self, parent: Optional[QWidget], *, config: SimpleConfig):
|
||||
''' Note: make sure parent is a "top_level_window()" as per
|
||||
MessageBoxMixin API else bad things can happen on macOS. '''
|
||||
QDialog.__init__(self, parent=parent)
|
||||
|
||||
@@ -547,6 +547,7 @@ class GenericInputHandler:
|
||||
allow_multi: bool = False,
|
||||
show_error: Callable[[str], None],
|
||||
setText: Callable[[str], None] = None,
|
||||
parent: QWidget = None,
|
||||
) -> None:
|
||||
if setText is None:
|
||||
setText = self.setText
|
||||
@@ -564,7 +565,9 @@ class GenericInputHandler:
|
||||
setText(new_text)
|
||||
|
||||
from .qrreader import scan_qrcode
|
||||
scan_qrcode(parent=self, config=config, callback=cb)
|
||||
if parent is None:
|
||||
parent = self if isinstance(self, QWidget) else None
|
||||
scan_qrcode(parent=parent, config=config, callback=cb)
|
||||
|
||||
def input_qr_from_screenshot(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user