diff --git a/electrum/gui/qml/components/QRScan.qml b/electrum/gui/qml/components/QRScan.qml index b0d369deb..b681a92ec 100644 --- a/electrum/gui/qml/components/QRScan.qml +++ b/electrum/gui/qml/components/QRScan.qml @@ -2,6 +2,8 @@ import QtQuick 2.12 import QtQuick.Controls 2.0 import QtMultimedia 5.6 +import org.electrum 1.0 + Item { id: scanner @@ -71,19 +73,19 @@ Item { } Connections { - target: QR + target: qr function onDataChanged() { - console.log(QR.data) + console.log(qr.data) scanner.active = false - scanner.scanData = QR.data + scanner.scanData = qr.data still.source = scanner.url var sx = still.width/still.sourceSize.width var sy = still.height/still.sourceSize.height - r.createObject(scanner, {cx: QR.points[0].x * sx, cy: QR.points[0].y * sy, color: 'yellow'}) - r.createObject(scanner, {cx: QR.points[1].x * sx, cy: QR.points[1].y * sy, color: 'yellow'}) - r.createObject(scanner, {cx: QR.points[2].x * sx, cy: QR.points[2].y * sy, color: 'yellow'}) - r.createObject(scanner, {cx: QR.points[3].x * sx, cy: QR.points[3].y * sy, color: 'yellow'}) + r.createObject(scanner, {cx: qr.points[0].x * sx, cy: qr.points[0].y * sy, color: 'yellow'}) + r.createObject(scanner, {cx: qr.points[1].x * sx, cy: qr.points[1].y * sy, color: 'yellow'}) + r.createObject(scanner, {cx: qr.points[2].x * sx, cy: qr.points[2].y * sy, color: 'yellow'}) + r.createObject(scanner, {cx: qr.points[3].x * sx, cy: qr.points[3].y * sy, color: 'yellow'}) foundAnimation.start() } @@ -123,12 +125,12 @@ Item { repeat: true running: scanner.active onTriggered: { - if (QR.busy) + if (qr.busy) return vo.grabToImage(function(result) { if (result.image !== undefined) { scanner.url = result.url - QR.scanImage(result.image) + qr.scanImage(result.image) } else { console.log('image grab returned null') } @@ -136,6 +138,10 @@ Item { } } + QRParser { + id: qr + } + Component.onCompleted: { console.log('Scan page initialized') QtMultimedia.availableCameras.forEach(function(item) { diff --git a/electrum/gui/qml/qeapp.py b/electrum/gui/qml/qeapp.py index 850573523..6645ea7e7 100644 --- a/electrum/gui/qml/qeapp.py +++ b/electrum/gui/qml/qeapp.py @@ -10,7 +10,7 @@ from .qeconfig import QEConfig from .qedaemon import QEDaemon, QEWalletListModel from .qenetwork import QENetwork from .qewallet import QEWallet -from .qeqr import QEQR, QEQRImageProvider +from .qeqr import QEQRParser, QEQRImageProvider from .qewalletdb import QEWalletDB from .qebitcoin import QEBitcoin @@ -32,6 +32,7 @@ class ElectrumQmlApplication(QGuiApplication): qmlRegisterType(QEWallet, 'org.electrum', 1, 0, 'Wallet') qmlRegisterType(QEWalletDB, 'org.electrum', 1, 0, 'WalletDB') qmlRegisterType(QEBitcoin, 'org.electrum', 1, 0, 'Bitcoin') + qmlRegisterType(QEQRParser, 'org.electrum', 1, 0, 'QRParser') self.engine = QQmlApplicationEngine(parent=self) self.engine.addImportPath('./qml') @@ -50,11 +51,9 @@ class ElectrumQmlApplication(QGuiApplication): self._singletons['config'] = QEConfig(config) self._singletons['network'] = QENetwork(daemon.network) self._singletons['daemon'] = QEDaemon(daemon) - self._singletons['qr'] = QEQR() self.context.setContextProperty('Config', self._singletons['config']) self.context.setContextProperty('Network', self._singletons['network']) self.context.setContextProperty('Daemon', self._singletons['daemon']) - self.context.setContextProperty('QR', self._singletons['qr']) self.context.setContextProperty('FixedFont', self.fixedFont) qInstallMessageHandler(self.message_handler) diff --git a/electrum/gui/qml/qeqr.py b/electrum/gui/qml/qeqr.py index cbc177c33..b32ca1c92 100644 --- a/electrum/gui/qml/qeqr.py +++ b/electrum/gui/qml/qeqr.py @@ -13,7 +13,7 @@ from electrum.qrreader import get_qr_reader from electrum.i18n import _ -class QEQR(QObject): +class QEQRParser(QObject): def __init__(self, text=None, parent=None): super().__init__(parent) self._text = text @@ -131,5 +131,5 @@ class QEQRImageProvider(QQuickImageProvider): qr.make(fit=True) pimg = qr.make_image(fill_color='black', back_color='white') #image_factory=StyledPilImage, module_drawer=CircleModuleDrawer()) - qimg = ImageQt.ImageQt(pimg) - return qimg, qimg.size() + self.qimg = ImageQt.ImageQt(pimg) + return self.qimg, self.qimg.size()