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