diff --git a/components/QRCodeScanner.qml b/components/QRCodeScanner.qml index 67d76238..a4d6927c 100644 --- a/components/QRCodeScanner.qml +++ b/components/QRCodeScanner.qml @@ -86,9 +86,14 @@ Rectangle { id : finder objectName: "QrFinder" onDecoded : { - root.qrcode_decoded(address, payment_id, amount, tx_description, recipient_name, extra_parameters) - root.state = "Stopped" - } + const parsed = walletManager.parse_uri_to_object(data); + if (!parsed.error) { + root.qrcode_decoded(parsed.address, parsed.payment_id, parsed.amount, parsed.tx_description, parsed.recipient_name, parsed.extra_parameters); + root.state = "Stopped"; + } else { + onNotifyError(parsed.error); + } + } onNotifyError : { if( warning ) messageDialog.icon = StandardIcon.Critical diff --git a/src/QR-Code-scanner/QrCodeScanner.cpp b/src/QR-Code-scanner/QrCodeScanner.cpp index 1a1c57b8..55e396fe 100644 --- a/src/QR-Code-scanner/QrCodeScanner.cpp +++ b/src/QR-Code-scanner/QrCodeScanner.cpp @@ -40,7 +40,7 @@ QrCodeScanner::QrCodeScanner(QObject *parent) m_probe = new QVideoProbe(this); m_thread = new QrScanThread(this); m_thread->start(); - QObject::connect(m_thread, SIGNAL(decoded(int,QString)), this, SLOT(processCode(int,QString))); + QObject::connect(m_thread, SIGNAL(decoded(int, QString)), this, SIGNAL(decoded(int, QString))); QObject::connect(m_thread, SIGNAL(notifyError(const QString &, bool)), this, SIGNAL(notifyError(const QString &, bool))); connect(m_probe, SIGNAL(videoFrameProbed(QVideoFrame)), this, SLOT(processFrame(QVideoFrame))); } @@ -48,37 +48,6 @@ void QrCodeScanner::setSource(QCamera *camera) { m_probe->setSource(camera); } -void QrCodeScanner::processCode(int type, const QString &data) -{ - if (! m_enabled) return; - qDebug() << "decoded - type: " << type << " data: " << data; - QString address, payment_id, tx_description, recipient_name, error; - QVector unknown_parameters; - uint64_t amount(0); - if( ! WalletManager::instance()->parse_uri(data, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error) ) - { - qDebug() << "Failed to parse_uri : " << error; - emit notifyError(error); - return; - } - QVariantMap parsed_unknown_parameters; - if(unknown_parameters.size() > 0) - { - qDebug() << "unknown parameters " << unknown_parameters; - foreach(const QString &item, unknown_parameters ) - { - QStringList parsed_item = item.split("="); - if(parsed_item.size() == 2) { - parsed_unknown_parameters.insert(parsed_item[0], parsed_item[1]); - } - } - emit notifyError(error, true); - } - qDebug() << "Parsed URI : " << address << " " << payment_id << " " << amount << " " << tx_description << " " << recipient_name << " " << error; - QString s_amount = WalletManager::displayAmount(amount); - qDebug() << "Amount passed " << s_amount ; - emit decoded(address, payment_id, s_amount, tx_description, recipient_name, parsed_unknown_parameters); -} void QrCodeScanner::processFrame(QVideoFrame frame) { if(frame.isValid()){ diff --git a/src/QR-Code-scanner/QrCodeScanner.h b/src/QR-Code-scanner/QrCodeScanner.h index adda1ee5..9420693d 100644 --- a/src/QR-Code-scanner/QrCodeScanner.h +++ b/src/QR-Code-scanner/QrCodeScanner.h @@ -51,13 +51,12 @@ public: void setEnabled(bool enabled); public Q_SLOTS: - void processCode(int type, const QString &data); void processFrame(QVideoFrame); Q_SIGNALS: void enabledChanged(); - void decoded(const QString &address, const QString &payment_id, const QString &amount, const QString &tx_description, const QString &recipient_name, const QVariantMap &extra_parameters); + void decoded(int type, const QString &data); void decode(int type, const QString &data); void notifyError(const QString &error, bool warning = false);