forked from AsteroidOS/unofficial-watchfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analog-silver-swerver.qml
569 lines (493 loc) · 19.6 KB
/
analog-silver-swerver.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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
/*
* Copyright (C) 2022 - Timo Könnecke <github.com/eLtMosen>
* 2022 - Darrel Griët <[email protected]>
* 2022 - Ed Beroset <github.com/beroset>
* 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.15
import QtQuick.Shapes 1.15
import QtGraphicalEffects 1.15
import Nemo.Mce 1.0
import org.asteroid.controls 1.0
import org.asteroid.utils 1.0
Item {
id: root
property string lowColor: !displayAmbient ? "#99b8bcc8" : "#55b8bcc8"
property string highColor: !displayAmbient ? "#E5E5E5" : "#aaE5E5E5"
property string accColor: !displayAmbient ? "#aeacb9" : "#aaaeacb9"
property string accColor2: !displayAmbient ? "#F55D3E" : "#88F55D3E"
property string imgPath: "../watchfaces-img/analog-silver-swerver-"
property real rad: .01745
anchors.fill: parent
MceBatteryLevel {
id: batteryChargePercentage
}
Item {
id: faceBox
anchors.fill: parent
Item {
id: nightstandMode
readonly property bool active: nightstand
property int batteryPercentChanged: batteryChargePercentage.percent
anchors.fill: parent
visible: nightstandMode.active
layer {
enabled: true
samples: 4
smooth: true
textureSize: Qt.size(nightstandMode.width * 2, nightstandMode.height * 2)
}
Shape {
id: chargeArc
property real angle: batteryChargePercentage.percent * 360 / 100
// radius of arc is scalefactor * height or width
property real arcStrokeWidth: 0.03
property real scalefactor: 0.3 - (arcStrokeWidth / 2)
property var chargecolor: Math.floor(batteryChargePercentage.percent / 33.35)
readonly property var colorArray: [ "red", "yellow", Qt.rgba(0.318, 1, 0.051, 0.9)]
anchors.fill: parent
ShapePath {
fillColor: "transparent"
strokeColor: chargeArc.colorArray[chargeArc.chargecolor]
strokeWidth: parent.height * chargeArc.arcStrokeWidth
capStyle: ShapePath.RoundCap
joinStyle: ShapePath.MiterJoin
startX: width / 2
startY: height * ( 0.5 - chargeArc.scalefactor)
PathAngleArc {
centerX: parent.width / 2
centerY: parent.height / 2
radiusX: chargeArc.scalefactor * parent.width
radiusY: chargeArc.scalefactor * parent.height
startAngle: -90
sweepAngle: chargeArc.angle
moveToStart: false
}
}
}
Text {
id: batteryDockPercent
anchors {
centerIn: parent
verticalCenterOffset: parent.width * 0.15
}
font {
pixelSize: parent.width * .15
family: "Noto Sans"
styleName: "Condensed Light"
}
visible: nightstandMode.active
color: chargeArc.colorArray[chargeArc.chargecolor]
style: Text.Outline; styleColor: "#80000000"
text: batteryChargePercentage.percent
}
}
MceBatteryState {
id: batteryChargeState
}
MceCableState {
id: mceCableState
}
Repeater {
model: 12
Text {
id: hourNumbers
property real rotM: ((index * 5 ) - 15) / 60
property real centerX: parent.width / 2 - width / 2
property real centerY: parent.height / 2 - height / 2
x: index % 6 ? centerX+Math.cos(rotM * 2 * Math.PI) * parent.width * .435 :
centerX+Math.cos(rotM * 2 * Math.PI) * parent.width * .4075
y: index % 6 ? centerY+Math.sin(rotM * 2 * Math.PI) * parent.width * .435 :
centerY+Math.sin(rotM * 2 * Math.PI) * parent.width * .4075
font {
pixelSize: index % 3 ? parent.height * .075 : parent.height * .15
family: "Noto Sans"
styleName: index % 3 ? "SemiCondensed SemiBold" : "SemiCondensed Medium"
}
color: "#ddffffff"
text: index === 0 ? 12 : index
LinearGradient {
anchors.fill: hourNumbers
source: hourNumbers
gradient: Gradient {
GradientStop { position: 0; color: "#CDCBD1" }
GradientStop { position: .4; color: "#B8BCC8" }
GradientStop { position: .6; color: "#E5E5E5" }
GradientStop { position: 1; color: "#E1E6E8" }
}
}
}
}
Item {
id: dayBox
property var day: wallClock.time.toLocaleString(Qt.locale(), "dd")
anchors {
centerIn: parent
verticalCenterOffset: -parent.width * .055
horizontalCenterOffset: -parent.width * .2125
}
width: parent.width * .3
height: width
visible: !nightstandMode.active
onDayChanged: dayArc.requestPaint()
Canvas {
id: dayArc
opacity: !displayAmbient ? 1 : .3
anchors.fill: parent
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
ctx.reset()
ctx.beginPath()
ctx.fillStyle = "#22ffffff"
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .45,
270 * rad,
360,
false);
ctx.strokeStyle = lowColor
ctx.lineWidth = root.height * .002
ctx.stroke()
ctx.fill()
ctx.closePath()
ctx.lineWidth = root.height * .005
ctx.lineCap="round"
ctx.strokeStyle = accColor
ctx.beginPath()
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .456,
169 * rad,
((wallClock.time.getDay() / 7 * 360) + 169) * rad,
false);
ctx.stroke()
ctx.closePath()
}
}
Repeater {
model: 7
visible: !displayAmbient
Text {
id: dayStrokes
property real rotM: ((index * 8.7) - 15) / 60
property real centerX: parent.width / 2 - width / 2
property real centerY: parent.height / 2 - height / 2
property bool currentDayHighlight: new Date(2017, 1, index).toLocaleString(Qt.locale(), "ddd") === wallClock.time.toLocaleString(Qt.locale(), "ddd")
x: centerX + Math.cos(rotM * 2 * Math.PI) * parent.width * .35
y: centerY + Math.sin(rotM * 2 * Math.PI) * parent.width * .35
antialiasing: true
font {
pixelSize: currentDayHighlight ? root.height * .036 : root.height * .03
letterSpacing: parent.width * .004
family: "Noto Sans"
styleName: currentDayHighlight ?
"Black" :
"SemiCondensed Bold"
}
color: currentDayHighlight ?
highColor :
lowColor
text: new Date(2017, 1, index).toLocaleString(Qt.locale(), "ddd").slice(0, 2).toUpperCase()
transform: Rotation {
origin.x: width / 2
origin.y: height / 2
angle: index * 52
}
}
}
Text {
id: dayDisplay
color: highColor
anchors {
centerIn: parent
verticalCenterOffset: -root.width * .003
}
font {
pixelSize: parent.height * .39
family: "Noto Sans"
styleName: "Condensed"
}
text: wallClock.time.toLocaleString(Qt.locale(), "dd").slice(0, 2).toUpperCase()
}
}
Item {
id: monthBox
property var month: wallClock.time.toLocaleString(Qt.locale(), "mm")
onMonthChanged: monthArc.requestPaint()
anchors {
centerIn: parent
verticalCenterOffset: -parent.width * .055
horizontalCenterOffset: parent.width * .2125
}
width: parent.width * .3
height: width
visible: !nightstandMode.active
Canvas {
id: monthArc
anchors.fill: parent
opacity: !displayAmbient ? 1 : .3
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
ctx.reset()
ctx.beginPath()
ctx.fillStyle = "#22ffffff"
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .45,
270 * rad,
360,
false);
ctx.strokeStyle = lowColor
ctx.lineWidth = root.height * .002
ctx.stroke()
ctx.fill()
ctx.closePath()
ctx.lineWidth = root.height * .005
ctx.lineCap="round"
ctx.strokeStyle = accColor
ctx.beginPath()
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .456,
270 * rad,
((wallClock.time.toLocaleString(Qt.locale(),"MM") / 12 * 360) + 270) * rad,
false);
ctx.stroke()
ctx.closePath()
}
}
Repeater {
model: 12
Text {
id: monthStrokes
property real rotM: ((index * 5) - 15) / 60
property real centerX: parent.width / 2 - width / 2
property real centerY: parent.height / 2 - height / 2
property bool currentMonthHighlight: Number(wallClock.time.toLocaleString(Qt.locale(), "MM")) === index ||
Number(wallClock.time.toLocaleString(Qt.locale(), "MM")) === index + 12
x: centerX + Math.cos(rotM * 2 * Math.PI) * parent.width * .35
y: centerY + Math.sin(rotM * 2 * Math.PI) * parent.width * .35
antialiasing: true
font {
pixelSize: currentMonthHighlight ?
root.height * .036 :
root.height * .03
letterSpacing: parent.width * .004
family: "Noto Sans"
styleName: currentMonthHighlight ?
"Black" :
"Condensed Bold"
}
color: currentMonthHighlight ?
highColor :
lowColor
text: index === 0 ? 12 : index
transform: Rotation {
origin.x: width / 2
origin.y: height / 2
angle: (index * 30)
}
}
}
Text {
id: monthDisplay
anchors.centerIn: parent
renderType: Text.NativeRendering
font {
pixelSize: parent.height * .28
family: "Noto Sans"
styleName:"ExtraCondensed Medium"
}
color: highColor
text: wallClock.time.toLocaleString(Qt.locale(), "MMM").slice(0, 3).toUpperCase()
}
}
Item {
id: batteryBox
property int value: batteryChargePercentage.percent
onValueChanged: batteryArc.requestPaint()
anchors {
centerIn: parent
verticalCenterOffset: parent.width * .1875
}
width: parent.width * .275
height: width
visible: !nightstandMode.active
Canvas {
id: batteryArc
anchors.fill: parent
opacity: !displayAmbient ? 1 : .3
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
ctx.reset()
ctx.beginPath()
ctx.fillStyle = "#22ffffff"
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .45,
270 * rad,
360,
false);
ctx.strokeStyle = lowColor
ctx.lineWidth = root.height * .002
ctx.stroke()
ctx.fill()
ctx.closePath()
ctx.lineWidth = root.height * .005
ctx.lineCap="round"
ctx.strokeStyle = batteryBox.value < 30 ?
accColor2 : "#2E933C"
ctx.beginPath()
ctx.arc(parent.width / 2,
parent.height / 2,
parent.width * .456,
270 * rad,
((batteryBox.value / 100 * 360) + 270) * rad,
false
);
ctx.stroke()
ctx.closePath()
}
}
Text {
id: batteryDisplay
anchors.centerIn: parent
renderType: Text.NativeRendering
font {
pixelSize: parent.height * .48
family: "Noto Sans"
styleName:"Condensed Light"
}
color: highColor
text: batteryBox.value
Text {
id: batteryPercent
anchors {
centerIn: batteryDisplay
verticalCenterOffset: parent.height * .34
}
renderType: Text.NativeRendering
font {
pixelSize: parent.height * .194
family: "Noto Sans"
styleName:"Bold"
}
lineHeightMode: Text.FixedHeight
lineHeight: parent.height * .94
horizontalAlignment: Text.AlignHCenter
color: !displayAmbient ?
highColor :
lowColor
text: "BAT<br>%"
}
}
}
// DropShadow on all faceBox items
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 2
verticalOffset: 2
radius: 10.0
samples: 21
color: Qt.rgba(0, 0, 0, .8)
}
}
Item {
id: handBox
anchors.fill: parent
Image {
id: hourSVG
source:imgPath + "hour.svg"
anchors.fill: parent
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: 2
verticalOffset: 2
radius: 5.0
samples: 11
color: Qt.rgba(0, 0, 0, .2)
}
}
Image {
id: minuteSVG
source: imgPath + "minute.svg"
anchors.fill: parent
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: 4
verticalOffset: 4
radius: 6.0
samples: 13
color: Qt.rgba(0, 0, 0, .3)
}
}
Image {
id: secondSVG
visible: !displayAmbient
source: imgPath + "second.svg"
anchors.fill: parent
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: 6
verticalOffset: 6
radius: 8.0
samples: 17
color: Qt.rgba(0, 0, 0, .3)
}
}
}
// DropShadow on all hands
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 2
verticalOffset: 2
radius: 8.0
samples: 17
color: Qt.rgba(0, 0, 0, .3)
}
}