~stefan-schwarzburg/qreator/touch-reorganized-colortheme

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
import QtQuick 2.0
import QtGraphicalEffects 1.0
import Ubuntu.Components 0.1

import "../js/qrcode.js" as QrCode

Item {
    id: container
    height: parent.height
    width: parent.width

    property var qrModules: [21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177]
    property string text: "Qreator"
    property int qrCodeVersion: 4
    property string qrErrorLevel: 'M'
    property real qrPixelSize: height / qrModules[qrCodeVersion - 1] 

    RectangularGlow {
        id: effect
        anchors.fill: qrcanvas
        glowRadius: 10
        spread: 0.2
        color: "#DD4814"
        cornerRadius: glowRadius
    }

    Canvas {
        id: qrcanvas
        width: container.width
        height: container.height
        antialiasing: true
        onPaint: drawQrCode(container.text)
    }
    

    function requestQrCodePaint(textme) {
        container.text = textme;
        qrcanvas.requestPaint();
    }

    function drawQrCode (textdata) {
        var ctx = qrcanvas.getContext('2d');
        var pixel_size = container.qrPixelSize;
        var QRCodeVersion = container.qrCodeVersion;
        var QRErrorCorrectLevel = container.qrErrorLevel;
        var qr = QrCode.qrcode(QRCodeVersion, QRErrorCorrectLevel);
        
        qr.addData(textdata);
        qr.make();

	// loop over pixels
	standardTheme.drawDots(qr, ctx, pixel_size)
    }

}