-
Notifications
You must be signed in to change notification settings - Fork 32
/
analog-silly-walks.qml
169 lines (158 loc) · 5.64 KB
/
analog-silly-walks.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
/*
* 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 {
id: root
property string currentColor: ""
property string userColor: ""
property string imgPath: "../watchfaces-img/analog-silly-walks-"
Repeater {
model: 12
Text {
z: 1
id: hourNumbers
font.pixelSize: root.height*0.15
font.family: "Varieté"
property var rotM: ((index * 5 ) - 15)/60
property var centerX: root.width/2-width/2
property var centerY: root.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*root.width*0.383
y: centerY+Math.sin(rotM * 2 * Math.PI)*root.width*0.383
color: "white"
text: index
opacity: (index === 0) ? 0 : 1
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourNumbers; color: "black" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Repeater {
model: 12
Text {
z: 0
id: hourNumbersShadow
font.pixelSize: root.height*0.155
font.family: "Varieté"
property var rotM: ((index * 5 ) - 15)/60
property var centerX: root.width/2-width/2
property var centerY: root.height/2-height/2
x: centerX+Math.cos(rotM * 2 * Math.PI)*root.width*0.370
y: centerY+Math.sin(rotM * 2 * Math.PI)*root.width*0.370
color: "black"
text: index
opacity: (index === 0) ? 0 : 1
state: currentColor
states: State { name: "black";
PropertyChanges { target: hourNumbersShadow; color: "white" }
}
transitions: Transition {
from: ""; to: "black"; reversible: true
ColorAnimation { duration: 300 }
}
}
}
Image {
id: backgound
z: 2
source: !displayAmbient ? imgPath + "bg.svg" : imgPath + "bg-white.svg"
anchors.horizontalCenter: root.horizontalCenter
anchors.verticalCenter: root.verticalCenter
width: root.width
height: root.height
}
Image {
id: hourSVG
z: 2
source: !displayAmbient ? imgPath + "hour.svg" : imgPath + "hour-white.svg"
anchors.horizontalCenter: root.horizontalCenter
anchors.verticalCenter: root.verticalCenter
width: root.width
height: root.height
transform: Rotation {
origin.x: root.width/2;
origin.y: root.height/2;
angle: (wallClock.time.getHours()*30) + (wallClock.time.getMinutes()*0.5)
}
}
Image {
id: minuteSVG
z: 3
source: !displayAmbient ? imgPath + "minute.svg" : imgPath + "minute-white.svg"
anchors.horizontalCenter: root.horizontalCenter
anchors.verticalCenter: root.verticalCenter
width: root.width
height: root.height
transform: Rotation {
origin.x: root.width/2;
origin.y: root.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: root.horizontalCenter
anchors.verticalCenter: root.verticalCenter
width: root.width
height: root.height
transform: Rotation {
origin.x: root.width/2;
origin.y: root.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"
}
}
}
}