QZXing.h Example File
appdemos/qtws/QZXing/QZXing.h
#ifndef QZXING_H
#define QZXING_H
#include "QZXing_global.h"
#include <QObject>
#include <QImage>
#if QT_VERSION >= 0x050000
class QQmlEngine;
#endif
namespace zxing {
class MultiFormatReader;
}
class ImageHandler;
class
#ifndef DISABLE_LIBRARY_FEATURES
QZXINGSHARED_EXPORT
#endif
QZXing : public QObject {
Q_OBJECT
Q_ENUMS(DecoderFormat)
Q_PROPERTY(int processingTime READ getProcessTimeOfLastDecoding)
Q_PROPERTY(uint enabledDecoders READ getEnabledFormats WRITE setDecoder NOTIFY enabledFormatsChanged)
Q_PROPERTY(bool tryHarder READ getTryHarder WRITE setTryHarder)
public:
enum DecoderFormat {
DecoderFormat_None = 0,
DecoderFormat_Aztec = 1 << 1,
DecoderFormat_CODABAR = 1 << 2,
DecoderFormat_CODE_39 = 1 << 3,
DecoderFormat_CODE_93 = 1 << 4,
DecoderFormat_CODE_128 = 1 << 5,
DecoderFormat_DATA_MATRIX = 1 << 6,
DecoderFormat_EAN_8 = 1 << 7,
DecoderFormat_EAN_13 = 1 << 8,
DecoderFormat_ITF = 1 << 9,
DecoderFormat_MAXICODE = 1 << 10,
DecoderFormat_PDF_417 = 1 << 11,
DecoderFormat_QR_CODE = 1 << 12,
DecoderFormat_RSS_14 = 1 << 13,
DecoderFormat_RSS_EXPANDED = 1 << 14,
DecoderFormat_UPC_A = 1 << 15,
DecoderFormat_UPC_E = 1 << 16,
DecoderFormat_UPC_EAN_EXTENSION = 1 << 17,
DecoderFormat_CODE_128_GS1 = 1 << 18
} ;
typedef unsigned int DecoderFormatType;
QZXing(QObject *parent = NULL);
~QZXing();
QZXing(DecoderFormat decodeHints, QObject *parent = NULL);
#ifdef QZXING_QML
static void registerQMLTypes();
static void registerQMLImageProvider(QQmlEngine& view);
#endif //QZXING_QML
void setTryHarder(bool tryHarder);
bool getTryHarder();
static QString decoderFormatToString(int fmt);
Q_INVOKABLE QString foundedFormat() const;
Q_INVOKABLE QString charSet() const;
public slots:
QString decodeImage(const QImage &image, int maxWidth = -1, int maxHeight = -1, bool smoothTransformation = false);
QString decodeImageFromFile(const QString& imageFilePath, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation = false);
QString decodeImageQML(QObject *item);
QString decodeSubImageQML(QObject *item,
const int offsetX = 0, const int offsetY = 0,
const int width = 0, const int height = 0);
QString decodeImageQML(const QUrl &imageUrl);
QString decodeSubImageQML(const QUrl &imageUrl,
const int offsetX = 0, const int offsetY = 0,
const int width = 0, const int height = 0);
QImage encodeData(const QString& data);
int getProcessTimeOfLastDecoding();
uint getEnabledFormats() const;
void setDecoder(const uint &hint);
signals:
void decodingStarted();
void decodingFinished(bool succeeded);
void enabledFormatsChanged();
void tagFound(QString tag);
void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet) const;
void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet, const QRectF &rect) const;
void error(QString msg);
private:
zxing::MultiFormatReader *decoder;
DecoderFormatType enabledDecoders;
ImageHandler *imageHandler;
int processingTime;
QString foundedFmt;
QString charSet_;
bool tryHarder_;
bool isThreaded;
};
#endif // QZXING_H