-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathanalog-red-handed.qml
331 lines (314 loc) · 11.3 KB
/
analog-red-handed.qml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
/*
* Copyright (C) 2021 - Timo Könnecke <github.com/eLtMosen>
* 2016 - Sylvia van Os <[email protected]>
* 2015 - Florent Revest <[email protected]>
* 2012 - Vasiliy Sorokin <[email protected]>
* Aleksey Mikhailichenko <[email protected]>
* Arto Jalkanen <[email protected]>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* 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/>.
*/
import QtQuick 2.9
Item {
property string currentColor: ""
property string userColor: ""
property string imgPath: "../watchfaces-img/analog-red-handed-"
Text {
z: 0
id: digitalDisplay
visible: !displayAmbient
font.pixelSize: parent.height*0.05
font.family: "PTSans"
font.styleName: "Bold"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
verticalCenterOffset: -parent.width/4.9
}
text: if (use12H.value) {
wallClock.time.toLocaleString(Qt.locale(), "hh ap").slice(0, 2) + wallClock.time.toLocaleString(Qt.locale(), ":mm") }
else
wallClock.time.toLocaleString(Qt.locale(), "HH:mm")
state: currentColor
states: State { name: "black";
PropertyChanges { target: digitalDisplay; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
Text {
z: 0
id: dateDisplay
visible: !displayAmbient
font.pixelSize: parent.height*0.05
font.family: "PTSans"
font.styleName: "Bold"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
verticalCenterOffset: -parent.width/7
}
text: wallClock.time.toLocaleString(Qt.locale(), "dd MMM").toUpperCase()
state: currentColor
states: State { name: "black";
PropertyChanges { target: dateDisplay; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
Text {
z: 0
id: apDisplay
property int day: wallClock.time.toLocaleString(Qt.locale(), "d")
property int month: wallClock.time.toLocaleString(Qt.locale(), "M")
font.pixelSize: parent.height*0.07
font.family: "PTSans"
font.styleName: "Bold"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
horizontalCenterOffset: parent.width/5.5
}
text: wallClock.time.toLocaleString(Qt.locale(), "ap").toUpperCase()
state: currentColor
states: State { name: "black";
PropertyChanges { target: apDisplay; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
Text {
z: 0
id: dowDisplay
font.pixelSize: parent.height*0.07
font.family: "PTSans"
font.styleName: "Bold"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
horizontalCenterOffset: -parent.width/5.5
}
text: wallClock.time.toLocaleString(Qt.locale(), "ddd").slice(0, 2).toUpperCase()
state: currentColor
states: State { name: "black";
PropertyChanges { target: dowDisplay; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
Image {
z: 0
id: logoAsteroid
source: "../watchfaces-img/asteroid-logo.svg"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: parent.height*0.18
width: parent.width/9
height: parent.height/9
}
Repeater {
model: 12
Rectangle {
z: 1
id: hourDots
antialiasing : true
property var rotM: ((index * 5 ) - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.29
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.29
color: "white"
width: parent.width*0.032
height: parent.height*0.032
radius: width*0.5
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourDots; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Repeater {
model: 60
Rectangle {
z: 1
id: minuteStrokes
antialiasing : true
property var rotM: ((index) - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.29
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.29
color: "white"
width: parent.width*0.004
height: parent.height*0.02
transform: Rotation { origin.x: width/2; origin.y: height/2; angle: (index)*6}
state: currentColor
states: State { name: "black";
PropertyChanges { target: minuteStrokes; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Repeater {
model: 4
Text {
z: 1
id: hourNumbers
font.pixelSize: parent.height*0.14
font.family: "RussoOne"
property var rotM: ((index * 15 ) - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.4
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.4
color: "white"
text: if (index === 0)
12
else
index*3
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourNumbers; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Repeater {
model: 12
Rectangle {
z: 1
id: hourStrokes
antialiasing : true
property var rotM: ((index * 5 ) - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.4
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.4
color: "white"
opacity: if ([0, 3, 6, 9].includes(index))
0
else
1
width: parent.width*0.014
height: parent.height*0.1
radius: width*0.5
transform: Rotation { origin.x: width/2; origin.y: height/2; angle: (index*5)*6}
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourStrokes; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Image {
id: hourSVG
z: 2
source: !displayAmbient ? imgPath + "hour.svg" : imgPath + "hour-ambient.svg"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height
transform: Rotation {
origin.x: parent.width/2;
origin.y: parent.height/2;
angle: (wallClock.time.getHours()*30) + (wallClock.time.getMinutes()*0.5)
}
}
Image {
id: minuteSVG
z: 3
source: !displayAmbient ? imgPath + "minute.svg" : imgPath + "minute-ambient.svg"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height
transform: Rotation {
origin.x: parent.width/2;
origin.y: parent.height/2;
angle: (wallClock.time.getMinutes()*6)+(wallClock.time.getSeconds()*6/60)
}
}
Image {
id: secondSVG
z: 4
property var toggle: 1
visible: !displayAmbient
source: imgPath + "second.svg"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height
transform: Rotation {
origin.x: parent.width/2;
origin.y: parent.height/2;
angle: (wallClock.time.getSeconds()*6)
}
MouseArea {
anchors.fill: parent
onDoubleClicked: {
if (secondSVG.toggle === 1) {
currentColor = "black"
secondSVG.toggle = 0
} else {
currentColor = ""
secondSVG.toggle = 1
}
}
}
}
Connections {
target: compositor
function onDisplayAmbientEntered() { if (currentColor == "black") {
currentColor = ""
userColor = "black"
}
else
userColor = ""
}
function onDisplayAmbientLeft() { if (userColor == "black") {
currentColor = "black"
}
}
}
}