forked from keepassxreboot/keepassxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQrCode.h
77 lines (62 loc) · 2.33 KB
/
QrCode.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
/*
* Copyright (C) 2017 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_QRCODE_H
#define KEEPASSX_QRCODE_H
#include <QScopedPointer>
class QImage;
class QIODevice;
class QString;
class QByteArray;
struct QrCodePrivate;
class QrCode
{
public:
enum class ErrorCorrectionLevel : int
{
LOW = 0,
MEDIUM,
QUARTILE,
HIGH
};
// See: http://www.qrcode.com/en/about/version.html
// clang-format off
enum class Version : int
{
AUTO = 0,
V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20,
V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36, V37, V38, V39, V40
};
// clang-format on
// Uses QRcode_encodeString (can't contain NUL characters)
explicit QrCode(const QString& data,
const Version version = Version::AUTO,
const ErrorCorrectionLevel ecl = ErrorCorrectionLevel::HIGH,
const bool caseSensitive = true);
// Uses QRcode_encodeData (can contain NUL characters)
explicit QrCode(const QByteArray& data,
const Version version = Version::AUTO,
const ErrorCorrectionLevel ecl = ErrorCorrectionLevel::HIGH);
QrCode();
~QrCode();
bool isValid() const;
void writeSvg(QIODevice* outputDevice, const int dpi, const int margin = 4) const;
private:
void init(const QString& data, const Version version, const ErrorCorrectionLevel ecl, const bool caseSensitive);
void init(const QByteArray& data, const Version version, const ErrorCorrectionLevel ecl);
QScopedPointer<QrCodePrivate> d_ptr;
};
#endif // KEEPASSX_QRCODE_H