2014-02-16 12:46:57 +00:00
|
|
|
#ifndef QZXING_H
|
|
|
|
#define QZXING_H
|
|
|
|
|
2014-07-01 14:09:14 +00:00
|
|
|
#include "qzxing_global.h"
|
2014-02-16 12:46:57 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QImage>
|
2014-07-01 14:09:14 +00:00
|
|
|
#include <QVariantHash>
|
|
|
|
#include <QtQuick>
|
2014-02-16 12:46:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A class containing a very very small subset of the ZXing library.
|
|
|
|
* Created for ease of use.
|
|
|
|
*
|
|
|
|
* Anyone interested in using more technical stuff
|
|
|
|
* from the ZXing library is welcomed to add/edit on free will.
|
|
|
|
*
|
|
|
|
* Regarding DecoderFormat, by default all of those are enabled (except DataMatrix will is still not supported)
|
|
|
|
*/
|
2014-07-01 14:09:14 +00:00
|
|
|
class QZXing : public QObject
|
|
|
|
{
|
2014-02-16 12:46:57 +00:00
|
|
|
Q_OBJECT
|
|
|
|
Q_ENUMS(DecoderFormat)
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum DecoderFormat {
|
2014-07-01 14:09:14 +00:00
|
|
|
DecoderFormat_None = 0,
|
|
|
|
DecoderFormat_QR_CODE = 1,
|
|
|
|
DecoderFormat_DATA_MATRIX = 2,
|
|
|
|
DecoderFormat_UPC_E = 4,
|
|
|
|
DecoderFormat_UPC_A = 8,
|
|
|
|
DecoderFormat_EAN_8 = 16,
|
|
|
|
DecoderFormat_EAN_13 = 32,
|
|
|
|
DecoderFormat_CODE_128 = 64,
|
|
|
|
DecoderFormat_CODE_39 = 128,
|
|
|
|
DecoderFormat_ITF = 256,
|
|
|
|
DecoderFormat_Aztec = 512
|
|
|
|
} ;
|
2014-02-16 12:46:57 +00:00
|
|
|
typedef unsigned int DecoderFormatType;
|
|
|
|
|
2014-07-01 14:09:14 +00:00
|
|
|
public:
|
2014-02-16 12:46:57 +00:00
|
|
|
QZXing(QObject *parent = NULL);
|
2014-07-01 14:09:14 +00:00
|
|
|
virtual ~QZXing();
|
2014-02-16 12:46:57 +00:00
|
|
|
|
2014-07-01 14:09:14 +00:00
|
|
|
/**
|
|
|
|
* Set the enabled decoders.
|
|
|
|
* As argument it is possible to pass conjuction of decoders by using logic OR.
|
|
|
|
* e.x. setDecoder ( DecoderFormat_QR_CODE | DecoderFormat_EAN_13 | DecoderFormat_CODE_39 )
|
|
|
|
*/
|
|
|
|
void setDecoder(DecoderFormatType hint);
|
2014-02-16 12:46:57 +00:00
|
|
|
|
|
|
|
#if QT_VERSION >= 0x040700
|
2014-07-01 14:09:14 +00:00
|
|
|
static void registerQMLTypes()
|
|
|
|
{
|
|
|
|
qmlRegisterType<QZXing>("harbour.sailotp.QZXing", 2, 2, "QZXing");
|
|
|
|
}
|
2014-02-16 12:46:57 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-01 14:09:14 +00:00
|
|
|
|
2014-02-16 12:46:57 +00:00
|
|
|
public slots:
|
|
|
|
/**
|
|
|
|
* The decoding function. Will try to decode the given image based on the enabled decoders.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-01 14:09:14 +00:00
|
|
|
QString decodeImage(QImage image);
|
|
|
|
QVariantHash decodeImageEx(QImage image);
|
2014-02-16 12:46:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The decoding function accessible from QML
|
|
|
|
*/
|
2014-07-01 14:09:14 +00:00
|
|
|
QString decodeImageQML(const QUrl &imageUrl);
|
|
|
|
|
|
|
|
|
|
|
|
QString decodeImageFromFile(QString imageFilePath);
|
2014-02-16 12:46:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The decoding function accessible from QML. Able to set the decoding
|
|
|
|
* of a portion of the image.
|
|
|
|
*/
|
2014-07-01 14:09:14 +00:00
|
|
|
QString decodeSubImageQML(const QUrl &imageUrl,
|
2014-02-16 12:46:57 +00:00
|
|
|
const double offsetX = 0 , const double offsetY = 0,
|
|
|
|
const double width = 0, const double height = 0);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void decodingStarted();
|
|
|
|
void decodingFinished(bool succeeded);
|
|
|
|
void tagFound(QString tag);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void* decoder;
|
2014-07-01 14:09:14 +00:00
|
|
|
DecoderFormatType supportedFormats;
|
2014-02-16 12:46:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QZXING_H
|
|
|
|
|