LockScreen.qml 3.54 KB
Newer Older
Aaron J. Seigo's avatar
Aaron J. Seigo committed
1
import QtQuick 2.0
Aaron J. Seigo's avatar
Aaron J. Seigo committed
2
3
import org.kde.plasma.core 2.0 as PlasmaCore
import "../components"
Aaron J. Seigo's avatar
Aaron J. Seigo committed
4

Aaron J. Seigo's avatar
Aaron J. Seigo committed
5
Leaves {
6
7
    id: lockscreen

Aaron J. Seigo's avatar
Aaron J. Seigo committed
8
9
10
11
12
    PlasmaCore.Svg {
        id: symbolsSvg
        imagePath:  Qt.resolvedUrl("images/symbols.svgz")
    }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
13
    MouseArea {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
14
        anchors.fill: parent
Aaron J. Seigo's avatar
Aaron J. Seigo committed
15
        onPressed: {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
16
            stripe.opacity = 1;
Aaron J. Seigo's avatar
Aaron J. Seigo committed
17
        }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
18
19
    }

Aaron J. Seigo's avatar
time    
Aaron J. Seigo committed
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
    PlasmaCore.DataSource {
        id: dataSource
        engine: "time"
        connectedSources: "Local"
        interval: 30000

        onDataChanged: {
            var date = new Date(data["Local"]["DateTime"]);
            hour.text = date.getHours();
            minute.text = date.getMinutes();
        }

        Component.onCompleted: {
            onDataChanged();
        }
    }

    Text {
        id: hour

        onTextChanged: {
            if (text.length < 2) {
                minute.text = "0" + text;
            }
        }

        anchors {
            top: parent.top
            left: parent.left
            right: parent.right
            bottom: stripe.top
        }
        color: "white" // FIXME: base on wallpaper?
        text: "00"
        font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
        horizontalAlignment: Qt.AlignCenter
        verticalAlignment: Qt.AlignVCenter
    }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
59
60
    SatelliteStripe {
        id: stripe
Aaron J. Seigo's avatar
Aaron J. Seigo committed
61
62
        opacity: 0

63
        function lockKeyPressed(id) {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
64
            hideTimer.stop();
65
66
            console.log(id);
        }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
67

68
        function lockKeyReleased(id) {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
69
            hideTimer.start();
70
71
72
            console.log(id);
        }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
73
74
        Behavior on opacity {
            NumberAnimation {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
75
                duration: 500
Aaron J. Seigo's avatar
Aaron J. Seigo committed
76
77
78
                easing.type: Easing.InOutQuad
            }
        }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
79

Aaron J. Seigo's avatar
Aaron J. Seigo committed
80
81
82
        MouseArea {
            anchors.fill: parent
            onPressed: {
83
84
85
86
87
                if (stripe.opacity < 1) {
                    stripe.opacity = 1;
                    return;
                }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
88
89
                stripe.lockKeyPressed(stripe.childAt(mouseX, mouseY).value);
            }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
90

Aaron J. Seigo's avatar
Aaron J. Seigo committed
91
            onReleased: {
92
93
94
95
                if (stripe.opacity < 1) {
                    return;
                }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
96
97
                stripe.lockKeyReleased(stripe.childAt(mouseX, mouseY).value);
            }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
98
99

//             onPositionChanged: {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
100
//                 hideTimer.restart();
Aaron J. Seigo's avatar
Aaron J. Seigo committed
101
//             }
Aaron J. Seigo's avatar
Aaron J. Seigo committed
102
103
        }

Aaron J. Seigo's avatar
Aaron J. Seigo committed
104
105
106
107
108
109
110
        Timer {
            id: hideTimer
            interval: 1000
            running: parent.opacity == 1
            onTriggered: parent.opacity = 0
        }

111
        LockKey {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
112
            id: square
113
            value: 1
Aaron J. Seigo's avatar
Aaron J. Seigo committed
114
            anchors.left: parent.left
Aaron J. Seigo's avatar
Aaron J. Seigo committed
115
116
117
            elementId: "square"
        }

118
        LockKey {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
119
            id: circle
120
            value: 2
Aaron J. Seigo's avatar
Aaron J. Seigo committed
121
122
123
124
125
            anchors.left: square.right

            elementId: "circle"
        }

126
        LockKey {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
127
            id: ex
128
            value: 3
Aaron J. Seigo's avatar
Aaron J. Seigo committed
129
130
131
132
133
134
            anchors.left: circle.right

            elementId: "ex"

        }

135
        LockKey {
Aaron J. Seigo's avatar
Aaron J. Seigo committed
136
            id: triangle
137
            value: 4
Aaron J. Seigo's avatar
Aaron J. Seigo committed
138
139
140
141
            anchors.left: ex.right

            elementId: "triangle"
        }
142
    }
Aaron J. Seigo's avatar
time    
Aaron J. Seigo committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166


    Text {
        id: minute

        onTextChanged: {
            if (text.length < 2) {
                minute.text = "0" + text;
            }
        }

        anchors {
            top: stripe.bottom
            left: parent.left
            right: parent.right
            bottom: parent.bottom
        }
        color: "white" // FIXME: base on wallpaper?
        text: "00"
        font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
        horizontalAlignment: Qt.AlignCenter
        verticalAlignment: Qt.AlignVCenter
    }

167
}