forked from AsteroidOS/unofficial-watchfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalog-words.qml
179 lines (171 loc) · 8.07 KB
/
analog-words.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
/*
* Copyright (C) 2021 - Ed Beroset <github.com/beroset>
* 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.1
import QtGraphicalEffects 1.15
Item {
property string currentColor: ""
property string userColor: ""
property int hour: wallClock.time.toLocaleString(Qt.locale(), "h ap").slice(0, 2) === "12" ? 0 : wallClock.time.toLocaleString(Qt.locale(), "h ap").slice(0, 2)
property var colorOffset: ["#ff0000", "#ff8000", "#ffff00", "#80ff00", "#00ff00", "#00ff80", "#00ffff", "#0080ff", "#0000ff", "#8000ff", "#ff00ff", "#ff0080"]
property var wordsDE: ["zwölf", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf"]
property var wordsEN: ["twelve", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven"]
property var wordsFR: ["douze", "une", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze"]
property var wordsES: ["doce", "una", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once"]
property var wordsIT: ["dodici", "uno", "due", "tre", "quattro", "cinque", "sei", "sette", "otto", "nove", "dieci", "undici"]
property var wordsNL: ["twaalf", "één", "twee", "drie", "vier", "vijf", "zes", "zeven", "acht", "negen", "tien", "elf"]
property var wordsGR: ["δώδεκα", "ένα", "δύο", "τρία", "τέσσερα", "πέντε", "έξι", "επτά", "οκτώ", "εννέα", "δέκα", "έντεκα"]
property var wordsSV: ["tolv", "ett", "två", "tre", "fyra", "fem", "sex", "sju", "åtta", "nio", "tio", "elva"]
property var wordsSK: ["dvanajst", "ena", "dve", "tri", "štiri", "pet", "šest", "sedem", "osem", "devet", "deset", "enajst"]
property var wordsDA: ["tolv", "en", "et", "to", "tre", "fire", "fem", "seks", "syv", "otte", "ni", "ti", "elleve"]
property var wordsPT: ["doze", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze"]
property var wordsTR: ["on iki", "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz", "on", "onbir"]
property var wordsNB: ["tolv", "en", "to", "tre", "fire", "fem", "seks", "syv", "åtte", "ni", "ti", "elleve"]
Rectangle {
z: 2
id: circleBack
property var toggle: 1
antialiasing : true
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
color: "white"
width: parent.width * 0.3
height: parent.height * 0.3
radius: width * 0.5
MouseArea {
anchors.fill: parent
onDoubleClicked: {
if (circleBack.toggle === 1) {
currentColor = ""
circleBack.toggle = 0
} else {
currentColor = "black"
circleBack.toggle = 1
}
}
}
Text {
id: minuteDisplay
font.pixelSize: parent.height * 0.549
font.family: "Montserrat"
font.styleName: "Regular"
color: "black"
opacity: 1
anchors.centerIn: parent
text: wallClock.time.toLocaleString(Qt.locale(), "mm")
}
}
Repeater {
model: 12
Rectangle {
z: hour == index ? 1 : 0
id: backRectangles
antialiasing: true
width: hourText.paintedWidth + (hourText.x * 1.21)
height: parent.height * 0.138
color: hour == index ? "white" : colorOffset[index]
opacity: 1
radius: width * 0.5
transform: [
Rotation {
origin.x: backRectangles.height / 2;
origin.y: backRectangles.height / 2;
angle: ((index) * 30) - 90
},
Translate {
x: (parent.width - backRectangles.height) / 2
y: (parent.height - backRectangles.height) / 2
}
]
state: currentColor
states: State { name: "black";
PropertyChanges { target: backRectangles;
color: hour == index ? "white" : "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 500 }
}
Text {
id: hourText
property var heightFontOffest: (index > 0 && index < 7) ? -parent.height * 0.05 : parent.height * 0.05
font.pixelSize: parent.height * (hour == index ? 0.70 : 0.56)
font.family: "SourceSansPro"
font.styleName: hour == index ? "Semibold" : "Light"
font.letterSpacing: hour == index ? -parent.height * 0.02 : parent.height * 0.001
color: "black"
x: hour == index ? parent.height * 1.58 : parent.height * 1.94
y: ((parent.height - hourText.height) / 2) + heightFontOffest
text: Qt.locale().name.substring(0,2) === "de" ? wordsDE[index]:
Qt.locale().name.substring(0,2) === "fr" ? wordsFR[index]:
Qt.locale().name.substring(0,2) === "es" ? wordsES[index]:
Qt.locale().name.substring(0,2) === "it" ? wordsIT[index]:
Qt.locale().name.substring(0,2) === "nl" ? wordsNL[index]:
Qt.locale().name.substring(0,2) === "el" ? wordsGR[index]:
Qt.locale().name.substring(0,2) === "sv" ? wordsSV[index]:
Qt.locale().name.substring(0,2) === "sk" ? wordsSK[index]:
Qt.locale().name.substring(0,2) === "da" ? wordsDA[index]:
Qt.locale().name.substring(0,2) === "pt" ? wordsPT[index]:
Qt.locale().name.substring(0,2) === "tr" ? wordsTR[index]:
Qt.locale().name.substring(0,2) === "nb" ? wordsNB[index]:
wordsEN[index]
transform: Rotation {
origin.x: hourText.width / 2;
origin.y: hourText.height / 2;
/* flip text for readability for hours 1 through 6 */
angle: (index > 0 && index < 7) ? 0 : 180
}
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourText;
color: hour == index ? "black" : "white" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 500 }
}
}
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 3
verticalOffset: 3
radius: 12.0
samples: 17
color: "#50000000"
}
}
}
Connections {
target: compositor
function onDisplayAmbientEntered() {
if (currentColor == "") {
currentColor = "black"
userColor = ""
}
else
userColor = "black"
}
function onDisplayAmbientLeft() {
if (userColor == "") {
currentColor = ""
}
}
}
}