Debian Codegraph @

qml/Components/QRCode.qml

raw
1 /*
2 * This file is part of the 2FA Manager App for Ubuntu Touch
3 * Copyright (C) 2019 Joan CiberSheep
4 *
5 * This App is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 *
10 * This App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 import QtQuick 2.9
21 import "../js/qqr.js" as QRCodeBackend
22
23 Canvas {
24 id: canvas
25 // background colour to be used
26 property color background : "white"
27 // foreground colour to be used
28 property color foreground : "black"
29 // ECC level to be applied (e.g. L, M, Q, H)
30 property string level : "L"
31 // value to be encoded in the generated QR code
32 property string value : ""
33
34 onPaint : {
35 var qr = QRCodeBackend.get_qr()
36 qr.canvas({
37 background : canvas.background,
38 canvas : canvas,
39 value: canvas.value,
40 foreground : canvas.foreground,
41 level : canvas.level,
42 side : Math.min(canvas.width, canvas.height),
43 value : canvas.value
44 })
45 }
46 onHeightChanged : {
47 requestPaint()
48 }
49
50 onWidthChanged : {
51 requestPaint()
52 }
53
54 onBackgroundChanged : {
55 requestPaint()
56 }
57
58 onForegroundChanged : {
59 requestPaint()
60 }
61
62 onLevelChanged : {
63 requestPaint()
64 }
65
66 onValueChanged : {
67 requestPaint()
68 }
69 }