forked from AsteroidOS/unofficial-watchfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalog-aviator.qml
371 lines (352 loc) · 11.7 KB
/
analog-aviator.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/*
* Copyright (C) 2021 - Timo Könnecke <github.com/eLtMosen>
*
* 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
import QtGraphicalEffects 1.15
Item {
property string currentColor: ""
property string userColor: ""
property string imgPath: "../watchfaces-img/analog-aviator-"
Image {
z: 0
id: asteroidLogo
source: "../watchfaces-img/asteroid-logo-white.svg"
antialiasing: true
anchors {
centerIn: parent
verticalCenterOffset: -parent.height * 0.324
}
width: parent.width/5.5
height: parent.height/5.5
opacity: 1
state: currentColor
states: State { name: "black"
PropertyChanges {
target: asteroidLogo
source: "../watchfaces-img/asteroid-logo-black.svg"
}
}
}
Text {
z: 1
id: asteroidSlogan
visible: !displayAmbient
font.pixelSize: parent.height * 0.048
font.family: "Raleway"
color: "#bbffffff"
horizontalAlignment: Text.AlignHCenter
anchors {
centerIn: parent
verticalCenterOffset: -parent.height * 0.146
}
text: "<b>AsteroidOS</b><br>Hack Your Wrist"
state: currentColor
states: State { name: "black";
PropertyChanges { target: asteroidSlogan; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
Text {
z: 0
id: dateDisplay
visible: !displayAmbient
font.pixelSize: parent.height * 0.052
font.family: "Raleway"
color: "#bbffffff"
horizontalAlignment: Text.AlignHCenter
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
verticalCenterOffset: parent.height*0.14
}
text: wallClock.time.toLocaleString(Qt.locale(), "<b>dd</b> MMMM<br>yyyy")
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.065
font.family: "PTSans"
font.styleName: "Regular"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: parent.height/3.8
horizontalCenter: parent.horizontalCenter
horizontalCenterOffset: parent.width/3.8
}
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.065
font.family: "PTSans"
font.styleName: "Regular"
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors {
verticalCenter: parent.verticalCenter
verticalCenterOffset: parent.height/3.8
horizontalCenter: parent.horizontalCenter
horizontalCenterOffset: -parent.width/3.8
}
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 }
}
}
Repeater {
model: 60
Rectangle {
z: 1
visible: index % 5
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.48
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.48
color: "#bbffffff"
width: parent.width*0.0055
height: parent.height*0.04
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.16
font.family: "Arkhip"
property var rotM: ((index * 15 ) - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2.6
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.35
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.35
color: "#ccffffff"
text: if (index === 0)
""
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: if ([0, 3, 6, 9].includes(index))
centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.48
else
centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.44
y: if ([0, 3, 6, 9].includes(index))
centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.48
else
centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.44
color: "#ccffffff"
width: parent.width*0.020
height: [0, 3, 6, 9].includes(index) ? parent.height*0.04 : parent.height*0.13
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 }
}
}
}
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 2
verticalOffset: 2
radius: 12.0
samples: 17
color: "#bb000000"
}
Image {
id: hourSVG
z: 2
source: !displayAmbient ? imgPath + "hour-ambient.svg" : imgPath + "hour-ambient.svg"
anchors {
centerIn: parent
}
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)
}
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 4
verticalOffset: 4
radius: 6.0
samples: 17
color: "#22000000"
}
state: currentColor
states: State { name: "black"
PropertyChanges {
target: hourSVG
source: imgPath + "hour.svg"
}
}
}
Image {
id: minuteSVG
z: 3
source: !displayAmbient ? imgPath + "minute-ambient.svg" : imgPath + "minute-ambient.svg"
anchors {
centerIn: parent
}
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)
}
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 6
verticalOffset: 6
radius: 8.0
samples: 17
color: "#22000000"
}
state: currentColor
states: State { name: "black"
PropertyChanges {
target: minuteSVG
source: imgPath + "minute.svg"
}
}
}
Image {
id: secondSVG
z: 4
property var toggle: 1
visible: !displayAmbient
source: imgPath + "second-ambient.svg"
anchors {
centerIn: parent
}
width: parent.width
height: parent.height
transform: Rotation {
origin.x: parent.width/2;
origin.y: parent.height/2;
angle: (wallClock.time.getSeconds()*6)
}
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 8
verticalOffset: 8
radius: 9.0
samples: 12
color: "#22000000"
}
MouseArea {
anchors.fill: parent
onDoubleClicked: {
if (secondSVG.toggle === 1) {
currentColor = "black"
secondSVG.toggle = 0
} else {
currentColor = ""
secondSVG.toggle = 1
}
}
}
state: currentColor
states: State { name: "black"
PropertyChanges {
target: secondSVG
source: imgPath + "second.svg"
}
}
}
Connections {
target: compositor
onDisplayAmbientEntered: if (currentColor == "black") {
currentColor = ""
userColor = "black"
}
else
userColor = ""
onDisplayAmbientLeft: if (userColor == "black") {
currentColor = "black"
}
}
}