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

« back to all changes in this revision

Viewing changes to QrCodeCanvas.qml

  • Committer: David Planella
  • Date: 2013-02-16 14:27:12 UTC
  • Revision ID: david.planella@ubuntu.com-20130216142712-z57z68y58fkhmkwl
Added some major visual changes
- Added glow effect to Qr code
- Added Header component (as a workaround until the SDK's MainView
provides it automatically)
- Added proof-of-concept wifi code generator (not fully functional yet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import QtQuick 2.0
 
2
import QtGraphicalEffects 1.0
2
3
import Ubuntu.Components 0.1
3
4
import "js/qrcode.js" as QrCode
4
5
 
7
8
    height: parent.height
8
9
    width: parent.width
9
10
    property string text
10
 
        
 
11
 
 
12
    RectangularGlow {
 
13
        id: effect
 
14
        anchors.fill: qrcanvas
 
15
        glowRadius: 10
 
16
        spread: 0.2
 
17
        color: "#DD4814"
 
18
        cornerRadius: glowRadius
 
19
    }
 
20
 
11
21
    Canvas {
12
 
        id: canvas
 
22
        id: qrcanvas
13
23
        width: container.width
14
24
        height: container.height
15
25
        antialiasing: true
19
29
    
20
30
    function requestQrCodePaint(textme) {
21
31
        container.text = textme;
22
 
        //console.log(textme);
23
 
        canvas.requestPaint();
 
32
        qrcanvas.requestPaint();
24
33
    }
25
34
 
26
35
    function drawQrCode (textdata) {
27
 
        var ctx = canvas.getContext('2d');
 
36
        var ctx = qrcanvas.getContext('2d');
28
37
        
29
38
        var pixel_size = 8;
30
39
        // Determines the overall dimensions of the symbol (1..10)
52
61
        // FIXME: need to add constants (enum) for shape. See
53
62
        // http://www.misfitgeek.com/2011/10/using-enum-in-javascript/
54
63
        if (shape == 1) {
 
64
            // Square-shaped pixels
55
65
            context.fillRect (x, y, width, height);
56
66
        }
57
67
 
58
68
        if (shape == 2) {
 
69
            // Round-shaped pixels
59
70
            context.beginPath();
60
71
            context.arc(x + width/2, y + height/2, width/2, 0, 2 * Math.PI, false);
61
72
            context.fill();