mirror of
https://github.com/status-im/qzxing.git
synced 2025-01-12 20:14:28 +00:00
Use the Image Provider in the encoder.
Support static function to register the image provider to the QQuickView.
This commit is contained in:
parent
3184ce6b8e
commit
81b63588ae
20
src/QZXing.h
20
src/QZXing.h
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user