-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqzxingnu.h
138 lines (108 loc) · 3.15 KB
/
qzxingnu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef QZXINGNU_H
#define QZXINGNU_H
#include <QImage>
#include <QObject>
#include <memory>
namespace QZXingNu {
Q_NAMESPACE
enum class BarcodeFormat {
/** Aztec 2D barcode format. */
AZTEC,
/** CODABAR 1D format. */
CODABAR,
/** Code 39 1D format. */
CODE_39,
/** Code 93 1D format. */
CODE_93,
/** Code 128 1D format. */
CODE_128,
/** Data Matrix 2D barcode format. */
DATA_MATRIX,
/** EAN-8 1D format. */
EAN_8,
/** EAN-13 1D format. */
EAN_13,
/** ITF (Interleaved Two of Five) 1D format. */
ITF,
/** MaxiCode 2D barcode format. */
MAXICODE,
/** PDF417 format. */
PDF_417,
/** QR Code 2D barcode format. */
QR_CODE,
/** RSS 14 */
RSS_14,
/** RSS EXPANDED */
RSS_EXPANDED,
/** UPC-A 1D format. */
UPC_A,
/** UPC-E 1D format. */
UPC_E,
/** UPC/EAN extension format. Not a stand-alone format. */
UPC_EAN_EXTENSION,
// Not valid value, used to count the number of formats, thus should be always the last
// listed here
FORMAT_COUNT,
};
Q_ENUM_NS(BarcodeFormat)
enum class DecodeStatus {
NoError = 0,
NotFound,
FormatError,
ChecksumError,
};
Q_ENUM_NS(DecodeStatus)
struct QZXingNuDecodeResult
{
Q_GADGET
Q_PROPERTY(DecodeStatus status MEMBER status)
Q_PROPERTY(BarcodeFormat format MEMBER format)
Q_PROPERTY(QString text MEMBER text)
Q_PROPERTY(QByteArray rawBytes MEMBER rawBytes)
Q_PROPERTY(QVector<QPointF> points MEMBER points)
Q_PROPERTY(bool valid MEMBER valid)
public:
DecodeStatus status;
BarcodeFormat format;
QString text;
QByteArray rawBytes;
QVector<QPointF> points;
bool valid;
};
class QZXingNu : public QObject
{
Q_OBJECT
Q_PROPERTY(QVector<int> formats READ formats WRITE setFormats NOTIFY formatsChanged)
Q_PROPERTY(bool tryHarder READ tryHarder WRITE setTryHarder NOTIFY tryHarderChanged)
Q_PROPERTY(bool tryRotate READ tryRotate WRITE setTryRotate NOTIFY tryRotateChanged)
Q_PROPERTY(QZXingNuDecodeResult decodeResult READ decodeResult NOTIFY decodeResultChanged)
QVector<int> m_formats;
bool m_tryHarder = false;
bool m_tryRotate = false;
QZXingNuDecodeResult m_decodeResult;
public:
explicit QZXingNu(QObject *parent = nullptr);
QVector<int> formats() const;
bool tryHarder() const;
bool tryRotate() const;
QZXingNuDecodeResult decodeResult() const;
signals:
void imageDecoded(QString data);
void formatsChanged(QVector<int> formats);
void tryHarderChanged(bool tryHarder);
void tryRotateChanged(bool tryRotate);
void decodeResultChanged(QZXingNuDecodeResult decodeResult);
void queueDecodeResult(QZXingNuDecodeResult result);
public slots:
QZXingNuDecodeResult decodeImage(const QImage &image);
void setFormats(QVector<int> formats);
void setTryHarder(bool tryHarder);
void setTryRotate(bool tryRotate);
protected:
void setDecodeResult(QZXingNuDecodeResult decodeResult);
};
} // namespace QZXingNu
Q_DECLARE_METATYPE(QZXingNu::BarcodeFormat)
Q_DECLARE_METATYPE(QZXingNu::DecodeStatus)
Q_DECLARE_METATYPE(QZXingNu::QZXingNuDecodeResult)
#endif // QZXINGNU_H