mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-16 12:58:31 +00:00
Removed qzxing_qml tag from the defaults
Automatically add qzxing_qml if qzxing_multimedia tag is used Refactorings to wrap QML dependant code in QZXING_QML scopes update README.md to reflect the above changes changes triggered from #26
This commit is contained in:
parent
f581e879de
commit
2207c3c248
14
README.md
14
README.md
@ -35,16 +35,18 @@ Project file config tags are now introduced to be able to control the dependenci
|
||||
The core part requires only "core" and "gui" Qt modules. Though for backward compatibility "quick" Qt module is also required.
|
||||
The 3 level of dependencies are:
|
||||
|
||||
###QZXing with QML (default)
|
||||
By including QZXing.pri or by building QZXing.pro, apart from the core functionality for C++ it will also include the QML functionality.
|
||||
###QZXing (core)
|
||||
By including QZXing.pri or by building QZXing.pro you get the core functionality of QZXing which requires only QtCore and QtGui (because of QImage).
|
||||
|
||||
###QZXing (no QML, only core)
|
||||
If an application is not going to use QML functionality, it is now possible to ditch the dependency to it. This can be done by adding the folloing line to the .pro file of its project:
|
||||
Warning! The initial default configuration till 20/03/2017 was including qzxing_qml. This tag could not be removed once added, so it was needed to be removed from the defaults.
|
||||
|
||||
###QZXing + QML
|
||||
If an application is going to use QML functionality, it is now possible to add the dependency to it. This can be done by adding the folloing line to the .pro file of its project:
|
||||
|
||||
CONFIG -= qzxing_qml
|
||||
CONFIG += qzxing_qml
|
||||
|
||||
###QZXing + QZXingFilter
|
||||
QZXing includes QZXingFilter, a QAbstractVideoFilter implementation to provide a mean of providing live feed to the decoding library.
|
||||
QZXing includes QZXingFilter, a QAbstractVideoFilter implementation to provide a mean of providing live feed to the decoding library. It automatically includes QML implementation as well.
|
||||
This option requires "multimedia" Qt module this is why it is considered as a separate configuration. It can be used by adding the folloing line to the .pro file of a project:
|
||||
|
||||
CONFIG += qzxing_multimedia
|
||||
|
@ -5,7 +5,6 @@
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <QAndroidJniObject>
|
||||
#include <QtAndroid>
|
||||
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
Application::Application()
|
||||
|
@ -2,9 +2,6 @@
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickItemGrabResult>
|
||||
#include <QQuickWindow>
|
||||
#include <QThread>
|
||||
#include <QTime>
|
||||
|
||||
@ -13,6 +10,12 @@
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#endif // QT_VERSION < Qt 5.0
|
||||
|
||||
#if defined(QZXING_QML)
|
||||
#include <QQuickItem>
|
||||
#include <QQuickItemGrabResult>
|
||||
#include <QQuickWindow>
|
||||
#endif //QZXING_QML
|
||||
|
||||
ImageHandler::ImageHandler(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
@ -20,6 +23,8 @@ ImageHandler::ImageHandler(QObject *parent) :
|
||||
|
||||
QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, int width, int height)
|
||||
{
|
||||
QImage img;
|
||||
#if defined(QZXING_QML)
|
||||
#if QT_VERSION >= 0x050000
|
||||
QQuickItem *item = qobject_cast<QQuickItem *>(imageObj);
|
||||
|
||||
@ -46,7 +51,7 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
||||
qApp->processEvents();
|
||||
QThread::yieldCurrentThread();
|
||||
}
|
||||
QImage img = result->image();
|
||||
img = result->image();
|
||||
#else
|
||||
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
||||
|
||||
@ -55,12 +60,13 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32);
|
||||
img = QImage(item->boundingRect().size().toSize(), QImage::Format_RGB32);
|
||||
img.fill(QColor(255, 255, 255).rgb());
|
||||
QPainter painter(&img);
|
||||
QStyleOptionGraphicsItem styleOption;
|
||||
item->paint(&painter, &styleOption);
|
||||
#endif
|
||||
#endif //defined(QZXING_QML)
|
||||
|
||||
if (offsetX < 0)
|
||||
offsetX = 0;
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include <zxing/common/detector/WhiteRectangleDetector.h>
|
||||
#include <QColor>
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickImageProvider>
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x040700 && QT_VERSION < 0x050000
|
||||
#include <QtDeclarative>
|
||||
#elif QT_VERSION >= 0x050000
|
||||
@ -31,6 +26,9 @@
|
||||
#endif //QZXING_MULTIMEDIA
|
||||
|
||||
#ifdef QZXING_QML
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickImageProvider>
|
||||
#include "QZXingImageProvider.h"
|
||||
#endif //QZXING_QML
|
||||
|
||||
@ -379,6 +377,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
||||
if (codec)
|
||||
string = codec->toUnicode(res->getText()->getText().c_str());
|
||||
}
|
||||
|
||||
emit tagFound(string);
|
||||
emit tagFoundAdvanced(string, foundedFmt, charSet_);
|
||||
|
||||
@ -448,6 +447,8 @@ QString QZXing::decodeSubImageQML(const QUrl &imageUrl,
|
||||
const int offsetX, const int offsetY,
|
||||
const int width, const int height)
|
||||
{
|
||||
#ifdef QZXING_QML
|
||||
|
||||
QString imagePath = imageUrl.path();
|
||||
imagePath = imagePath.trimmed();
|
||||
QImage img;
|
||||
@ -471,6 +472,9 @@ QString QZXing::decodeSubImageQML(const QUrl &imageUrl,
|
||||
if (offsetX || offsetY || width || height)
|
||||
img = img.copy(offsetX, offsetY, width, height);
|
||||
return decodeImage(img);
|
||||
#else
|
||||
return decodeImage(QImage());
|
||||
#endif //QZXING_QML
|
||||
}
|
||||
|
||||
QImage QZXing::encodeData(const QString& data)
|
||||
@ -488,7 +492,9 @@ QImage QZXing::encodeData(const QString& data)
|
||||
qRgb(255,255,255));
|
||||
|
||||
image = image.scaled(240, 240);
|
||||
#ifdef QZXING_QML
|
||||
QZXingImageProvider::getInstance()->storeImage(image);
|
||||
#endif //QZXING_QML
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
@ -14,9 +14,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
QT += core gui
|
||||
|
||||
CONFIG += qzxing_qml
|
||||
QT += core
|
||||
|
||||
DEFINES += QZXING_LIBRARY \
|
||||
ZXING_ICONV_CONST \
|
||||
@ -261,7 +259,22 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
|
||||
$$PWD/zxing/zxing/EncodeHint.cpp \
|
||||
$$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp
|
||||
|
||||
qzxing_multimedia {
|
||||
QT += multimedia
|
||||
|
||||
CONFIG += qzxing_qml
|
||||
|
||||
DEFINES += QZXING_MULTIMEDIA
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/QZXingFilter.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/QZXingFilter.cpp
|
||||
}
|
||||
|
||||
qzxing_qml {
|
||||
QT += gui
|
||||
|
||||
greaterThan(QT_VERSION, 4.7): lessThan(QT_VERSION, 5.0): QT += declarative
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += quick
|
||||
@ -275,18 +288,6 @@ qzxing_qml {
|
||||
$$PWD/QZXingImageProvider.cpp
|
||||
}
|
||||
|
||||
qzxing_multimedia {
|
||||
QT += multimedia
|
||||
|
||||
DEFINES += QZXING_MULTIMEDIA
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/QZXingFilter.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/QZXingFilter.cpp
|
||||
}
|
||||
|
||||
symbian {
|
||||
TARGET.UID3 = 0xE618743C
|
||||
TARGET.EPOCALLOWDLLDATA = 1
|
||||
|
@ -1,5 +1,4 @@
|
||||
CONFIG += gnu++11
|
||||
CONFIG -= qzxing_qml
|
||||
QMAKE_CXXFLAGS += -std=gnu++11
|
||||
|
||||
TARGET = QZXingTests
|
||||
|
Loading…
x
Reference in New Issue
Block a user