-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeAssistant.qml
299 lines (286 loc) · 9.86 KB
/
HomeAssistant.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
import QtQuick 1.1
import Components 1.0
import Components.Styles 1.0
import BtObjects 2.0
import "js/ha.js" as Utils
Page {
id: page
showBackButton: true
onBackClicked: tabView.activateTab(homePage)
headerLabel: "HomeAssistant" + trsl.empty
function aboutToShow() {
Utils.loadData(debug, status, pager, pagerText, badges, switches, buttons, images, flowEntities, flowLines, flowWrapper, badgeTimer, time, global)
badgeTimer.start()
}
function handleScreenOff() {
var shouldReturn = Utils.handleScreenOff()
if(!shouldReturn) {
badgeTimer.stop()
}
return shouldReturn;
}
Column {
anchors.top: backButton.bottom
anchors.left: parent.left
anchors.right: parent.right
Flow {
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
id: flowWrapper
Repeater {
id: flowLines
PathView {
visible: true
id: pathView
property variant lineColor: modelData.lineColor;
model: modelData.numberOfDots;
path: Path {
startX: modelData.startX
startY: modelData.startY
PathQuad { x: modelData.x; y:modelData.y; controlX: modelData.controlX; controlY:modelData.controlY}
}
delegate: Rectangle {
property variant modelData: flowLines.model[pathView.modelIndex]
width: 2; height: 2;
color: pathView.lineColor;
}
}
}
Repeater {
id: flowEntities
Rectangle {
anchors {
left: parent.left
top: parent.top
leftMargin: modelData.leftMargin
topMargin: modelData.topMargin
}
radius: 50
width: 100
height: 100
color: modelData.backgroundColor || "transparent"
border.color: modelData.borderColor || "transparent"
border.width: modelData.borderWidth || 2
UbuntuLightText {
text: modelData.labelText || ""
font.pixelSize: 14
font.bold: true
color: "grey"
anchors.top: parent.top
anchors.topMargin: modelData.labelTopMargin || - 20
anchors.horizontalCenter: parent.horizontalCenter
}
UbuntuLightText {
font.pixelSize: modelData.textSize || 16
font.bold: modelData.textBold || true
anchors.verticalCenter: modelData.extraMargin ? undefined : parent.verticalCenter
anchors.top: modelData.extraMargin ? parent.top : undefined
anchors.topMargin: modelData.extraMargin || undefined
anchors.horizontalCenter: parent.horizontalCenter
text: modelData.state
color: modelData.textColor || "black"
}
}
}
}
}
Flow {
anchors.left: parent.left
anchors.right: parent.right
Repeater {
id: badges
Rectangle {
width: 100; height: 50
border.width: 1
color: "grey"
UbuntuLightText {
font.pixelSize: 20
color: "white"
text: modelData.state
anchors {
top: parent.top
topMargin: 3
left: parent.left
leftMargin: 3
}
}
}
}
}
Flow {
anchors.left: parent.left
anchors.right: parent.right
spacing: 5
Repeater {
id: images
Image {
cache: false
visible: true
width: modelData.width
height: modelData.height
source: modelData.source
}
}
}
Flow {
anchors.left: parent.left
anchors.right: parent.right
spacing: 5
Repeater {
id: switches
Item {
width: 200; height: 50
UbuntuLightText {
font.pixelSize: 18
width: 50
color: "white"
text: modelData.name
anchors {
top: parent.top
topMargin: 3
left: parent.left
leftMargin: 3
}
}
BasicButton {
anchors {
top: parent.top
topMargin: 3
right: parent.right
rightMargin: 3
}
checkable: true
checked: modelData.state
style: CheckableButtonStyle {
defaultImage: "images/ringtones/switch-bg_btn.svg"
checkedImage: "images/ringtones/switch-bg_btn_p.svg"
defaultIconLeft: "images/ringtones/switch_btn.svg"
defaultIconRight: "images/ringtones/disable_icon.svg"
checkedIconLeft: "images/ringtones/enable_icon.svg"
checkedIconRight: "images/ringtones/switch_btn_p.svg"
}
onTouched: {
Utils.toggle(debug, status, modelData)
}
}
}
}
}
Flow {
anchors.left: parent.left
anchors.right: parent.right
spacing: 13
Repeater {
id: buttons
BasicButton {
style: LabelStyle {
defaultImage: "images/first_configuration/list_btn.svg"
pressedImage: "images/first_configuration/list_btn_p.svg"
description: modelData.name + trsl.empty
}
onTouched: {
Utils.toggle(debug, status, modelData)
}
}
}
}
}
Item {
Timer {
id: badgeTimer
interval: 2000; running: true; repeat: true
onTriggered: {
Utils.loadData(debug, status, pager, pagerText, badges, switches, buttons, images, flowEntities, flowLines, flowWrapper, badgeTimer, time, global)
}
}
UbuntuLightText {
id: status
text: ""
color: "white"
font.pixelSize: 16
anchors.left: parent.left
anchors.leftMargin: 10
}
UbuntuLightText {
id: time
color: "white"
font.pixelSize: 18
anchors.left: parent.left
anchors.leftMargin: (page.width / 2) + 220
}
}
Rectangle {
width: 300
height: 200
color: "black"
id: debugContainer
visible: false
anchors.bottom: debugButton.top
anchors.left: page.left
anchors.right: page.right
Text {
z: 1
id: debug
text: "// debug console"
color: "white"
font.pixelSize: 12
anchors.left: parent.left
anchors.leftMargin: 3
}
MouseArea {
anchors.fill: parent
onClicked: {
rect.color = "blue"
}
}
}
Rectangle {
width: 100
height: 40
color: "black"
id: pager
visible: false
anchors.bottom: page.bottom
anchors.left: page.left
Text {
z: 1
text: ""
color: "white"
id: pagerText
font.pixelSize: 18
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
Utils.handlePaging(debug, pagerText, badges, switches, buttons, images, flowEntities, flowLines, flowWrapper)
}
}
}
Rectangle {
width: 30
height: 30
color: "red"
id: debugButton
visible: Utils.showDebugConsole()
anchors.bottom: page.bottom
anchors.right: page.right
Text {
z: 1
text: "D"
color: "black"
font.pixelSize: 18
font.bold: true
anchors.left: parent.left
anchors.leftMargin: 3
}
MouseArea {
anchors.fill: parent
onClicked: {
debugContainer.visible = !debugContainer.visible
}
}
}
}