forked from JackV2020/thermostatPlusBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThermostatPlusBasicTile.qml
More file actions
223 lines (180 loc) · 7.43 KB
/
Copy pathThermostatPlusBasicTile.qml
File metadata and controls
223 lines (180 loc) · 7.43 KB
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
import QtQuick 2.1
import qb.components 1.0
Tile {
id : thermostatPlusBasicTile
// --------------------------------------------------------------------
property bool activeMe : false
property int buttonWidth : isNxt ? 150 : 120
property int buttonHeight : isNxt ? 30 : 24
property string activeColor : "lightgrey"
property string hoverColor : "lightgrey"
property string selectedColor : "green"
property string halfselectedColor : "lime" // for program button when programState == 2
property int fireHeightBig : isNxt ? 50 : 40
property int fireHeightSmall : fireHeightBig / 2
property int fireHeight1 : fireHeightSmall
property int fireWidth1 : isNxt ? 100 : 80
property int fireHeight2 : fireHeightBig
property int fireWidth2 : isNxt ? 100 : 80
property int fireHeight3 : fireHeightSmall
property int fireWidth3 : isNxt ? 100 : 80
property string tempStr
// ----------------------------------------------- only run when visible
onVisibleChanged: {
if (visible) {
app.setscheduleIndex()
switch(app.guiMode) {
case 'Settings' : { stage.openFullscreen(app.thermostatPlusBasicSettingsUrl) ; break }
case 'BackToControl' : { stage.openFullscreen(app.thermostatPlusBasicControlUrl) ; break }
default : { activeMe = true ; break }
}
} else {
activeMe = false
}
}
// ------------------------------------------------------------- Control
onClicked: {
stage.openFullscreen(app.thermostatPlusBasicControlUrl);
}
// --------------------------------------------------------------- Timer
Timer {
id : controlTimer
interval : ( (app.mode == 'Master' ) || (app.mode == 'Local' ) ) ? 5000 : (app.programState == 2 ) ? 60000 : 10000
running : activeMe
repeat : true
triggeredOnStart : true
onTriggered : {
app.runProgram()
refreshScreen()
}
}
// ---------------------------------------------------------------- Fire
Timer {
id : fireTimer
interval : 5000
running : ( activeMe && app.burnerInfo )
repeat : true
onTriggered : {
if (imgFire1.source == app.fireSmallTile ) {
imgFire1.source = app.fireBigTile
imgFire2.source = app.fireSmallTile
imgFire3.source = app.fireBigTile
} else {
imgFire1.source = app.fireSmallTile
imgFire2.source = app.fireBigTile
imgFire3.source = app.fireSmallTile
}
}
}
// ---------------------------------------------------------------- saveVariables
Timer {
id : saveVariablesTimer
interval : 10000
running : true
repeat : true
onTriggered : app.saveVariables()
}
// ---------------------------------------------------------------------
function refreshScreen() {
if ( (app.mode == 'Mirror' ) || (app.mode == 'Master' ) ) {
homeTemp.text = "." + app.currentTemp + "°."
} else {
homeTemp.text = app.currentTemp + "°"
}
if (app.programState == 1) {
targetTemp.text = app.activeStateText + " " + app.currentSetpoint + "°"
} else {
targetTemp.text = app.currentSetpoint + "°"
}
tempStr = app.temporaryLng[app.currentLng]
programMessage1.text = (app.programState == 2 && app.burnerInfo) ? tempStr + app.currentSetpoint : (app.nextState > -1 ) ? app.nextStateStr + " (" + app.nextSetpoint + "°) " + app.nextTime : ""
}
// -------------------------------------------------------- Fire picture
Image {
id : imgFire1
anchors {
bottom : imgFire2.bottom
right : imgFire2.left
rightMargin : -5
}
source : app.fireSmallTile
visible : app.burnerInfo
}
Image {
id : imgFire2
anchors {
bottom : homeTemp.top
horizontalCenter : parent.horizontalCenter
bottomMargin : isNxt ? -25 : -20
}
source : app.fireBigTile
visible : app.burnerInfo
}
Image {
id : imgFire3
anchors {
bottom : imgFire2.bottom
left : imgFire2.right
leftMargin : -5
}
source : app.fireSmallTile
visible : app.burnerInfo
}
// ---------------------------------------------------- Room temperature
Text {
id : homeTemp
text : ""
color : (typeof dimmableColors !== 'undefined') ? dimmableColors.clockTileColor : colors.clockTileColor
anchors {
horizontalCenter : parent.horizontalCenter
bottom : currentSetpoint.top
bottomMargin : isNxt ? -10 : -8
}
font.pixelSize : isNxt ? 100 : 80
font.family : qfont.italic.name
font.bold : true
}
// ----------------------------------------------------- currentSetpoint
Rectangle {
id : currentSetpoint
height : buttonHeight
width : buttonWidth * 1.5
anchors {
bottom : programMessage1.top
horizontalCenter : parent.horizontalCenter
}
border {
width : 1
color : "black"
}
radius : 5
color : (app.programState == 1) ? selectedColor : (app.programState == 2) ? halfselectedColor : activeColor
Text {
id : targetTemp
text : ""
color : (app.programState == 1) ? "white" : "black"
anchors {
verticalCenter : parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
font.family : qfont.italic.name
}
}
// --------------------------------------------------- Next Program text
// some text ; degree symbol ; more text
Text {
id : programMessage1
text : ""
anchors {
bottom : parent.bottom
horizontalCenter : currentSetpoint.horizontalCenter
}
font {
pixelSize : isNxt ? 20 : 16
family : qfont.italic.name
bold : true
}
color : dimState ? "white" : "red"
}
// ---------------------------------------------------------------------
}