mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 16:28:14 +00:00
Make QtMultimedia dependency optional
This commit is contained in:
parent
12573652a0
commit
fb3a6182fc
6 changed files with 50 additions and 28 deletions
|
@ -131,4 +131,11 @@ Rectangle {
|
||||||
root.state = "Stopped"
|
root.state = "Stopped"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if( QtMultimedia.availableCameras.length == 0) {
|
||||||
|
console.log("No camera available. Disable qrScannerEnabled");
|
||||||
|
appWindow.qrScannerEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
21
main.cpp
21
main.cpp
|
@ -39,7 +39,6 @@
|
||||||
#include "WalletManager.h"
|
#include "WalletManager.h"
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
#include "QRCodeImageProvider.h"
|
#include "QRCodeImageProvider.h"
|
||||||
#include "QrCodeScanner.h"
|
|
||||||
#include "PendingTransaction.h"
|
#include "PendingTransaction.h"
|
||||||
#include "UnsignedTransaction.h"
|
#include "UnsignedTransaction.h"
|
||||||
#include "TranslationManager.h"
|
#include "TranslationManager.h"
|
||||||
|
@ -57,6 +56,10 @@
|
||||||
#include "daemon/DaemonManager.h"
|
#include "daemon/DaemonManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_SCANNER
|
||||||
|
#include "QrCodeScanner.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
// Send all message types to logger
|
// Send all message types to logger
|
||||||
|
@ -131,7 +134,9 @@ int main(int argc, char *argv[])
|
||||||
qRegisterMetaType<TransactionInfo::Direction>();
|
qRegisterMetaType<TransactionInfo::Direction>();
|
||||||
qRegisterMetaType<TransactionHistoryModel::TransactionInfoRole>();
|
qRegisterMetaType<TransactionHistoryModel::TransactionInfoRole>();
|
||||||
|
|
||||||
|
#ifdef WITH_SCANNER
|
||||||
qmlRegisterType<QrCodeScanner>("moneroComponents.QRCodeScanner", 1, 0, "QRCodeScanner");
|
qmlRegisterType<QrCodeScanner>("moneroComponents.QRCodeScanner", 1, 0, "QRCodeScanner");
|
||||||
|
#endif
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
@ -197,19 +202,27 @@ int main(int argc, char *argv[])
|
||||||
engine.rootContext()->setContextProperty("defaultAccountName", accountName);
|
engine.rootContext()->setContextProperty("defaultAccountName", accountName);
|
||||||
engine.rootContext()->setContextProperty("applicationDirectory", QApplication::applicationDirPath());
|
engine.rootContext()->setContextProperty("applicationDirectory", QApplication::applicationDirPath());
|
||||||
|
|
||||||
|
bool builtWithScanner = false;
|
||||||
|
#ifdef WITH_SCANNER
|
||||||
|
builtWithScanner = true;
|
||||||
|
#endif
|
||||||
|
engine.rootContext()->setContextProperty("builtWithScanner", builtWithScanner);
|
||||||
|
|
||||||
// Load main window (context properties needs to be defined obove this line)
|
// Load main window (context properties needs to be defined obove this line)
|
||||||
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
|
||||||
QObject *rootObject = engine.rootObjects().first();
|
QObject *rootObject = engine.rootObjects().first();
|
||||||
|
|
||||||
bool builtWithScanner = false;
|
|
||||||
#ifdef WITH_SCANNER
|
#ifdef WITH_SCANNER
|
||||||
builtWithScanner = true;
|
|
||||||
QObject *qmlCamera = rootObject->findChild<QObject*>("qrCameraQML");
|
QObject *qmlCamera = rootObject->findChild<QObject*>("qrCameraQML");
|
||||||
|
if( qmlCamera ){
|
||||||
|
qDebug() << "QrCodeScanner : object found";
|
||||||
QCamera *camera_ = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));
|
QCamera *camera_ = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));
|
||||||
QObject *qmlFinder = rootObject->findChild<QObject*>("QrFinder");
|
QObject *qmlFinder = rootObject->findChild<QObject*>("QrFinder");
|
||||||
qobject_cast<QrCodeScanner*>(qmlFinder)->setSource(camera_);
|
qobject_cast<QrCodeScanner*>(qmlFinder)->setSource(camera_);
|
||||||
|
} else {
|
||||||
|
qDebug() << "QrCodeScanner : something went wrong !";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
engine.rootContext()->setContextProperty("builtWithScanner", builtWithScanner);
|
|
||||||
|
|
||||||
QObject::connect(eventFilter, SIGNAL(sequencePressed(QVariant,QVariant)), rootObject, SLOT(sequencePressed(QVariant,QVariant)));
|
QObject::connect(eventFilter, SIGNAL(sequencePressed(QVariant,QVariant)), rootObject, SLOT(sequencePressed(QVariant,QVariant)));
|
||||||
QObject::connect(eventFilter, SIGNAL(sequenceReleased(QVariant,QVariant)), rootObject, SLOT(sequenceReleased(QVariant,QVariant)));
|
QObject::connect(eventFilter, SIGNAL(sequenceReleased(QVariant,QVariant)), rootObject, SLOT(sequenceReleased(QVariant,QVariant)));
|
||||||
|
|
21
main.qml
21
main.qml
|
@ -32,7 +32,6 @@ import QtQuick.Controls 1.1
|
||||||
import QtQuick.Controls.Styles 1.1
|
import QtQuick.Controls.Styles 1.1
|
||||||
import QtQuick.Dialogs 1.2
|
import QtQuick.Dialogs 1.2
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
import QtMultimedia 5.4
|
|
||||||
|
|
||||||
import moneroComponents.Wallet 1.0
|
import moneroComponents.Wallet 1.0
|
||||||
import moneroComponents.PendingTransaction 1.0
|
import moneroComponents.PendingTransaction 1.0
|
||||||
|
@ -65,9 +64,10 @@ ApplicationWindow {
|
||||||
property bool viewOnly: false
|
property bool viewOnly: false
|
||||||
property bool foundNewBlock: false
|
property bool foundNewBlock: false
|
||||||
property int timeToUnlock: 0
|
property int timeToUnlock: 0
|
||||||
property bool qrScannerEnabled: (typeof builtWithScanner != "undefined") && builtWithScanner && (QtMultimedia.availableCameras.length > 0)
|
property bool qrScannerEnabled: (typeof builtWithScanner != "undefined") && builtWithScanner
|
||||||
property int blocksToSync: 1
|
property int blocksToSync: 1
|
||||||
property var isMobile: (appWindow.width > 700) ? false : true
|
property var isMobile: (appWindow.width > 700) ? false : true
|
||||||
|
property var cameraUi
|
||||||
|
|
||||||
// true if wallet ever synchronized
|
// true if wallet ever synchronized
|
||||||
property bool walletInitialized : false
|
property bool walletInitialized : false
|
||||||
|
@ -809,6 +809,18 @@ ApplicationWindow {
|
||||||
// Connect app exit to qml window exit handling
|
// Connect app exit to qml window exit handling
|
||||||
mainApp.closing.connect(appWindow.close);
|
mainApp.closing.connect(appWindow.close);
|
||||||
|
|
||||||
|
if( appWindow.qrScannerEnabled ){
|
||||||
|
console.log("qrScannerEnabled : load component QRCodeScanner");
|
||||||
|
var component = Qt.createComponent("components/QRCodeScanner.qml");
|
||||||
|
if (component.status == Component.Ready) {
|
||||||
|
console.log("Camera component ready");
|
||||||
|
cameraUi = component.createObject(appWindow);
|
||||||
|
} else {
|
||||||
|
console.log("component not READY !!!");
|
||||||
|
appWindow.qrScannerEnabled = false;
|
||||||
|
}
|
||||||
|
} else console.log("qrScannerEnabled disabled");
|
||||||
|
|
||||||
if(!walletsFound()) {
|
if(!walletsFound()) {
|
||||||
rootItem.state = "wizard"
|
rootItem.state = "wizard"
|
||||||
} else {
|
} else {
|
||||||
|
@ -941,11 +953,6 @@ ApplicationWindow {
|
||||||
messageText: qsTr("Please wait...")
|
messageText: qsTr("Please wait...")
|
||||||
}
|
}
|
||||||
|
|
||||||
QRCodeScanner {
|
|
||||||
id: cameraUi
|
|
||||||
visible : false
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: rootItem
|
id: rootItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
QT += qml quick widgets multimedia
|
QT += qml quick widgets
|
||||||
|
|
||||||
WALLET_ROOT=$$PWD/monero
|
WALLET_ROOT=$$PWD/monero
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ QMAKE_DISTCLEAN += -r $$WALLET_ROOT
|
||||||
INCLUDEPATH += $$WALLET_ROOT/include \
|
INCLUDEPATH += $$WALLET_ROOT/include \
|
||||||
$$PWD/src/libwalletqt \
|
$$PWD/src/libwalletqt \
|
||||||
$$PWD/src/QR-Code-generator \
|
$$PWD/src/QR-Code-generator \
|
||||||
$$PWD/src/QR-Code-scanner \
|
|
||||||
$$PWD/src \
|
$$PWD/src \
|
||||||
$$WALLET_ROOT/src
|
$$WALLET_ROOT/src
|
||||||
|
|
||||||
|
@ -38,7 +37,6 @@ HEADERS += \
|
||||||
src/libwalletqt/AddressBook.h \
|
src/libwalletqt/AddressBook.h \
|
||||||
src/zxcvbn-c/zxcvbn.h \
|
src/zxcvbn-c/zxcvbn.h \
|
||||||
src/libwalletqt/UnsignedTransaction.h \
|
src/libwalletqt/UnsignedTransaction.h \
|
||||||
src/QR-Code-scanner/QrCodeScanner.h \
|
|
||||||
MainApp.h
|
MainApp.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
|
@ -62,7 +60,6 @@ SOURCES += main.cpp \
|
||||||
src/libwalletqt/AddressBook.cpp \
|
src/libwalletqt/AddressBook.cpp \
|
||||||
src/zxcvbn-c/zxcvbn.c \
|
src/zxcvbn-c/zxcvbn.c \
|
||||||
src/libwalletqt/UnsignedTransaction.cpp \
|
src/libwalletqt/UnsignedTransaction.cpp \
|
||||||
src/QR-Code-scanner/QrCodeScanner.cpp \
|
|
||||||
MainApp.cpp
|
MainApp.cpp
|
||||||
|
|
||||||
!ios {
|
!ios {
|
||||||
|
@ -125,9 +122,15 @@ ios {
|
||||||
CONFIG(WITH_SCANNER) {
|
CONFIG(WITH_SCANNER) {
|
||||||
if( greaterThan(QT_MINOR_VERSION, 5) ) {
|
if( greaterThan(QT_MINOR_VERSION, 5) ) {
|
||||||
message("using camera scanner")
|
message("using camera scanner")
|
||||||
|
QT += multimedia
|
||||||
DEFINES += "WITH_SCANNER"
|
DEFINES += "WITH_SCANNER"
|
||||||
HEADERS += src/QR-Code-scanner/QrScanThread.h
|
INCLUDEPATH += $$PWD/src/QR-Code-scanner
|
||||||
SOURCES += src/QR-Code-scanner/QrScanThread.cpp
|
HEADERS += \
|
||||||
|
src/QR-Code-scanner/QrScanThread.h \
|
||||||
|
src/QR-Code-scanner/QrCodeScanner.h
|
||||||
|
SOURCES += \
|
||||||
|
src/QR-Code-scanner/QrScanThread.cpp \
|
||||||
|
src/QR-Code-scanner/QrCodeScanner.cpp
|
||||||
android {
|
android {
|
||||||
INCLUDEPATH += $$PWD/../ZBar/include
|
INCLUDEPATH += $$PWD/../ZBar/include
|
||||||
LIBS += -lzbarjni -liconv
|
LIBS += -lzbarjni -liconv
|
||||||
|
|
|
@ -37,14 +37,12 @@ QrCodeScanner::QrCodeScanner(QObject *parent)
|
||||||
, m_processInterval(750)
|
, m_processInterval(750)
|
||||||
, m_enabled(true)
|
, m_enabled(true)
|
||||||
{
|
{
|
||||||
#ifdef WITH_SCANNER
|
|
||||||
m_probe = new QVideoProbe(this);
|
m_probe = new QVideoProbe(this);
|
||||||
m_thread = new QrScanThread(this);
|
m_thread = new QrScanThread(this);
|
||||||
m_thread->start();
|
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, SLOT(processCode(int,QString)));
|
||||||
QObject::connect(m_thread, SIGNAL(notifyError(const QString &, bool)), this, SIGNAL(notifyError(const QString &, bool)));
|
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)));
|
connect(m_probe, SIGNAL(videoFrameProbed(QVideoFrame)), this, SLOT(processFrame(QVideoFrame)));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void QrCodeScanner::setSource(QCamera *camera)
|
void QrCodeScanner::setSource(QCamera *camera)
|
||||||
{
|
{
|
||||||
|
@ -97,12 +95,10 @@ void QrCodeScanner::setEnabled(bool enabled)
|
||||||
}
|
}
|
||||||
emit enabledChanged();
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
#ifdef WITH_SCANNER
|
|
||||||
void QrCodeScanner::timerEvent(QTimerEvent *event)
|
void QrCodeScanner::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
if( (event->timerId() == m_processTimerId) ){
|
if( (event->timerId() == m_processTimerId) ){
|
||||||
m_thread->addFrame(m_curFrame);
|
m_thread->addFrame(m_curFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QVideoFrame>
|
#include <QVideoFrame>
|
||||||
#ifdef WITH_SCANNER
|
|
||||||
#include "QrScanThread.h"
|
#include "QrScanThread.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
class QVideoProbe;
|
class QVideoProbe;
|
||||||
class QCamera;
|
class QCamera;
|
||||||
|
@ -64,10 +62,8 @@ Q_SIGNALS:
|
||||||
void notifyError(const QString &error, bool warning = false);
|
void notifyError(const QString &error, bool warning = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef WITH_SCANNER
|
|
||||||
void timerEvent(QTimerEvent *);
|
void timerEvent(QTimerEvent *);
|
||||||
QrScanThread *m_thread;
|
QrScanThread *m_thread;
|
||||||
#endif
|
|
||||||
int m_processTimerId;
|
int m_processTimerId;
|
||||||
int m_processInterval;
|
int m_processInterval;
|
||||||
int m_enabled;
|
int m_enabled;
|
||||||
|
|
Loading…
Reference in a new issue