Use the Image Provider in the encoder.

Support static function to register the image provider to the QQuickView.
This commit is contained in:
favoritas37 2016-06-16 01:15:44 +03:00
parent 3184ce6b8e
commit 81b63588ae
3 changed files with 21 additions and 7 deletions

View File

@ -9,8 +9,12 @@
#include <QtDeclarative>
#elif QT_VERSION >= 0x050000
#include <QtQml/qqml.h>
#include <QQuickView>
#include <QQmlEngine>
#endif
#include <qzxingimageprovider.h>
// forward declaration
namespace zxing {
class MultiFormatReader;
@ -27,10 +31,10 @@ class ImageHandler;
* Regarding DecoderFormat, by default all of those are enabled (except DataMatrix will is still not supported)
*/
class
#ifndef DISABLE_LIBRARY_FEATURES
QZXINGSHARED_EXPORT
#endif
QZXing : public QObject {
#ifndef DISABLE_LIBRARY_FEATURES
QZXINGSHARED_EXPORT
#endif
QZXing : public QObject {
Q_OBJECT
Q_ENUMS(DecoderFormat)
@ -75,6 +79,14 @@ public:
}
#endif
#if QT_VERSION >= 0x050000
static void registerQMLImageProvider(const QQuickView& view)
{
QQmlEngine *engine = view.engine();
engine->addImageProvider(QLatin1String("QZXing"), QZXingImageProvider::getInstance());
}
#endif
void setTryHarder(bool tryHarder);
bool getTryHarder();
static QString decoderFormatToString(int fmt);

View File

@ -133,7 +133,8 @@ HEADERS += $$PWD/QZXing_global.h \
$$PWD/zxing/zxing/EncodeHint.h \
$$PWD/zxing/zxing/UnsupportedEncodingException.h \
$$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h \
$$PWD/zxing/zxing/common/Types.h
$$PWD/zxing/zxing/common/Types.h \
$$PWD/QZXingImageProvider.h
SOURCES += $$PWD/CameraImageWrapper.cpp \
$$PWD/qzxing.cpp \
@ -244,7 +245,8 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
$$PWD/zxing/zxing/qrcode/encoder/MatrixUtil.cpp \
$$PWD/zxing/zxing/qrcode/encoder/QRCode.cpp \
$$PWD/zxing/zxing/EncodeHint.cpp \
$$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp
$$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp \
$$PWD/QZXingImageProvider.cpp
symbian {
TARGET.UID3 = 0xE618743C

View File

@ -350,7 +350,7 @@ QImage QZXing::encodeData(const QString& data)
qRgb(255,255,255));
image = image.scaled(240, 240);
// bool success = image.save("tmp.bmp","BMP");
QZXingImageProvider::getInstance()->storeImage(image);
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
}