forked from AsteroidOS/unofficial-watchfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkitt.qml
192 lines (169 loc) · 5.79 KB
/
kitt.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
/*
* 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 Nemo.Mce 1.0
import org.asteroid.controls 1.0
import org.asteroid.utils 1.0
import QtSensors 5.3
Item {
id: watchFace
property var time: wallClock.time //new Date() //
property string imgPath: "../watchfaces-img/"
FontLoader { id: localFont
name:'Digital-7 Mono'
}
Image {
id: backgroundImage
sourceSize.height: width
sourceSize.width: width
anchors.fill: parent
source: imgPath + "kitt-bg.svg"
}
Item {
id: lcdArea
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: parent.height * 0.22
height: parent.height * 0.26
width: parent.width * 0.68
Text {
id: dateDisplay
font { family: localFont.name; pixelSize:parent.width*0.1;capitalization: Font.Capitalize }
color: "black"
style: Text.Outline; styleColor: Qt.rgba(255,255,255,0.5)
opacity: 0.9
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: parent.height*0.05
text: watchFace.time.toLocaleString(Qt.locale(), "<b>ddd</b> d MMM")
}
Item {
id: timeRow
width: parent.width * 0.9
height: parent.width * 0.8
anchors.topMargin: parent.width * 0.02
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
Text {
id: timeDisplay
anchors.left: parent.left
anchors.top: parent.top
font { family: localFont.name; pixelSize:parent.width*0.35;capitalization: Font.Capitalize }
color: "black"
style: Text.Outline; styleColor: Qt.rgba(255,255,255,0.5)
opacity: 0.9
horizontalAlignment: Text.AlignHCenter
text: if (use12H.value)
wallClock.time.toLocaleString(Qt.locale(), "hh:mm ap").slice(0, 5)
else
wallClock.time.toLocaleString(Qt.locale(), "HH:mm")
}
Text {
id: secondsDisplay
anchors.topMargin: parent.width * 0.01
anchors.right: parent.right
anchors.top: parent.top
text: wallClock.time.toLocaleString(Qt.locale(), "ss")
font { family: localFont.name; pixelSize:timeDisplay.font.pixelSize * 0.5; capitalization: Font.Capitalize }
color: timeDisplay.color
style: timeDisplay.style
styleColor: timeDisplay.styleColor
}
}
}
Item {
id: chargingIndicatorArea
x: parent.width * 0.165
y: parent.width * 0.056
width: parent.width * 0.289
height: parent.width * 0.115
Rectangle {
color: batteryChargePercentage.percent < 50 ? 'red': 'green'
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: parent.bottom
width: batteryChargePercentage.percent * parent.width/100
opacity: 0.5
}
Icon {
id: batteryIcon
name: "ios-battery-charging"
width: parent.height * 0.6
height: width
anchors.right: parent.left
anchors.verticalCenter: parent.verticalCenter
opacity: 0.4
rotation: 270
visible: batteryChargeState.value == MceBatteryState.Charging
}
}
Image {
id: compassRotateImage
x: parent.width * 0.037
y: parent.width * 0.65
width: parent.width * 0.36
height: width
sourceSize.height: parent.width
sourceSize.width: parent.width
fillMode: Image.PreserveAspectFit
source: imgPath + "kitt-compass.svg"
}
Image {
id: connectedImage
x: parent.width * 0.17
y: parent.width * 0.53
width: parent.width * 0.19
height: width * 0.308
sourceSize.height: width
sourceSize.width: height
fillMode: Image.PreserveAspectFit
source: imgPath + "kitt-connected.svg"
opacity: btStatus.connected ? 1 : btStatus.powered? 0.5 : 0.1
}
Image {
id: buttonImage
x: parent.width * 0.64
y: parent.width * 0.668
width: parent.width*0.298
height: parent.width * 0.32
sourceSize.height: height
sourceSize.width: width
fillMode: Image.PreserveAspectFit
source: imgPath + "kitt-button.svg"
}
Image {
id: foregroundImage
anchors.fill: parent
sourceSize.height: width
sourceSize.width: width
source: imgPath + "kitt-fg.svg"
}
BluetoothStatus {
id: btStatus
}
MceBatteryLevel {
id: batteryChargePercentage
}
MceBatteryState {
id: batteryChargeState
}
Compass {
active: true
onReadingChanged: {
compassRotateImage.rotation = -reading.azimuth
}
}
}