-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathday-clock-24h.qml
189 lines (176 loc) · 5.69 KB
/
day-clock-24h.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
/*
* Copyright (C) 2018 - Timo Könnecke <[email protected]>
* 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/>.
*/
/*
* Based on kitt by velox/jgibbon regarding arcs and image embedding.
*/
import QtQuick 2.1
import QtGraphicalEffects 1.15
Item {
Canvas {
z: 1
id: twentyfourhourArc
anchors.fill: parent
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
var rot = 0.25 * (60 * (wallClock.time.getHours()+6) + wallClock.time.getMinutes())
ctx.reset()
ctx.beginPath()
ctx.lineWidth = parent.width/42
ctx.fillStyle = Qt.rgba(0, 0, 0, 0.5)
ctx.arc(parent.width/2, parent.height/2, width, 90*0.01745, rot*0.01745, false);
ctx.lineTo(parent.width/2, parent.height/2)
ctx.fill()
}
}
Image {
z: 2
id: backGround
source: "../watchfaces-img/day-clock-center.svg"
anchors {
centerIn: parent
}
width: parent.width/3
height: parent.height/3
Image {
z: 2
id: backStars
source: "../watchfaces-img/day-clock-center-stars.svg"
anchors {
centerIn: parent
}
width: parent.width
height: parent.height
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 0
verticalOffset: 0
radius: 12.0
samples: 15
color: "#ccffcc00"
}
}
}
Text {
z: 3
id: hourDisplay
property var offset: height*0.5
font.pixelSize: parent.height*0.22
font.family: "Vollkorn"
font.styleName:"Regular"
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.9
horizontalAlignment: Text.AlignHCenter
x: parent.width/14
y: parent.height/2.5-offset
text: if (use12H.value) {
wallClock.time.toLocaleString(Qt.locale(), "hh ap").slice(0, 2)}
else
wallClock.time.toLocaleString(Qt.locale(), "HH")
}
Text {
z: 3
id: minuteDisplay
property var offset: height*0.5
font.pixelSize: parent.height*0.22
font.family: "Vollkorn"
font.styleName:"Regular"
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.9
horizontalAlignment: Text.AlignHCenter
x: parent.width/14
y: parent.height/1.65-offset
text: wallClock.time.toLocaleString(Qt.locale(), "mm")
}
Text {
z: 4
id: dayDisplay
property var offset: height*0.5
font.pixelSize: parent.height*0.20
font.family: "Vollkorn"
font.styleName:"Regular"
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.5
x: parent.width*0.7
y: parent.height/2.5-offset
text: (Math.round((((0.25 * (60 * (wallClock.time.getHours()+6) + wallClock.time.getMinutes())-90)/360)*100) * 1) / 1)
}
Text {
z: 4
id: percentDisplay
property var offset: height*0.5
font.pixelSize: parent.height*0.20
font.family: "Vollkorn"
font.styleName:"Regular"
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.5
x: parent.width*0.73
y: parent.height/1.58-offset
text: "%"
}
Text {
z: 5
id: dayofweekDisplay
font.pixelSize: parent.height*0.10
font.family: "Vollkorn"
font.styleName:"Regular"
lineHeight: parent.height*0.0025
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.7
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
y: parent.height/9
text: wallClock.time.toLocaleString(Qt.locale(), "dddd")
}
Text {
z: 6
id: dateDisplay
font.pixelSize: parent.height*0.1
font.family: "Vollkorn"
font.styleName:"Regular"
lineHeight: parent.height*0.0025
color: "white"
style: Text.Outline; styleColor: "#80000000"
opacity: 0.8
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
y: parent.height/1.32
text: wallClock.time.toLocaleString(Qt.locale(), "yyyy MM dd")
}
Connections {
target: wallClock
function onTimeChanged() {
twentyfourhourArc.requestPaint()
}
}
Component.onCompleted: {
twentyfourhourArc.requestPaint()
}
}