mirror of
https://github.com/monero-project/monero-gui
synced 2024-11-24 11:17:15 +01:00
QrCodeScanner: parse extra parameters
This commit is contained in:
parent
6f95f8a754
commit
77335b300a
@ -44,7 +44,7 @@ Rectangle {
|
||||
color: "black"
|
||||
state: "Stopped"
|
||||
|
||||
signal qrcode_decoded(string address, string payment_id, string amount, string tx_description, string recipient_name)
|
||||
signal qrcode_decoded(string address, string payment_id, string amount, string tx_description, string recipient_name, var extra_parameters)
|
||||
|
||||
states: [
|
||||
State {
|
||||
@ -83,7 +83,7 @@ Rectangle {
|
||||
id : finder
|
||||
objectName: "QrFinder"
|
||||
onDecoded : {
|
||||
root.qrcode_decoded(address, payment_id, amount, tx_description, recipient_name)
|
||||
root.qrcode_decoded(address, payment_id, amount, tx_description, recipient_name, extra_parameters)
|
||||
root.state = "Stopped"
|
||||
}
|
||||
onNotifyError : {
|
||||
@ -126,7 +126,7 @@ Rectangle {
|
||||
|
||||
MessageDialog {
|
||||
id: messageDialog
|
||||
title: "Scanning QrCode"
|
||||
title: qsTr("QrCode Scanned") + translationManager.emptyString
|
||||
onAccepted: {
|
||||
root.state = "Stopped"
|
||||
}
|
||||
|
@ -61,15 +61,23 @@ void QrCodeScanner::processCode(int type, const QString &data)
|
||||
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::instance()->displayAmount(amount);
|
||||
qDebug() << "Amount passed " << s_amount ;
|
||||
emit decoded(address, payment_id, s_amount, tx_description, recipient_name);
|
||||
emit decoded(address, payment_id, s_amount, tx_description, recipient_name, parsed_unknown_parameters);
|
||||
}
|
||||
void QrCodeScanner::processFrame(QVideoFrame frame)
|
||||
{
|
||||
@ -102,3 +110,15 @@ void QrCodeScanner::timerEvent(QTimerEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
QrCodeScanner::~QrCodeScanner()
|
||||
{
|
||||
m_thread->stop();
|
||||
m_thread->quit();
|
||||
if(!m_thread->wait(5000))
|
||||
{
|
||||
m_thread->terminate();
|
||||
m_thread->wait();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class QrCodeScanner : public QObject
|
||||
|
||||
public:
|
||||
QrCodeScanner(QObject *parent = Q_NULLPTR);
|
||||
|
||||
~QrCodeScanner();
|
||||
void setSource(QCamera*);
|
||||
|
||||
bool enabled() const;
|
||||
@ -57,7 +57,7 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void enabledChanged();
|
||||
|
||||
void decoded(const QString &address, const QString &payment_id, const QString &amount, const QString &tx_description, const QString &recipient_name);
|
||||
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 decode(int type, const QString &data);
|
||||
void notifyError(const QString &error, bool warning = false);
|
||||
|
||||
|
@ -110,6 +110,7 @@ void QrScanThread::processVideoFrame(const QVideoFrame &frame)
|
||||
void QrScanThread::stop()
|
||||
{
|
||||
m_running = false;
|
||||
m_waitCondition.wakeOne();
|
||||
}
|
||||
|
||||
void QrScanThread::addFrame(const QVideoFrame &frame)
|
||||
@ -124,9 +125,10 @@ void QrScanThread::run()
|
||||
QVideoFrame frame;
|
||||
while(m_running) {
|
||||
QMutexLocker locker(&m_mutex);
|
||||
while(m_queue.isEmpty())
|
||||
while(m_queue.isEmpty() && m_running)
|
||||
m_waitCondition.wait(&m_mutex);
|
||||
processVideoFrame(m_queue.takeFirst());
|
||||
if(!m_queue.isEmpty())
|
||||
processVideoFrame(m_queue.takeFirst());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ class QrScanThread : public QThread, public zbar::Image::Handler
|
||||
public:
|
||||
QrScanThread(QObject *parent = Q_NULLPTR);
|
||||
void addFrame(const QVideoFrame &frame);
|
||||
virtual void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
void decoded(int type, const QString &data);
|
||||
@ -51,7 +52,6 @@ Q_SIGNALS:
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
virtual void stop();
|
||||
void processVideoFrame(const QVideoFrame &);
|
||||
void processQImage(const QImage &);
|
||||
void processZImage(zbar::Image &image);
|
||||
|
Loading…
Reference in New Issue
Block a user