forked from oepi-loepi/toonTemp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToonTempTile6.qml
183 lines (164 loc) · 4.2 KB
/
ToonTempTile6.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
import QtQuick 2.1
import qb.components 1.0
Tile {
id: toonTempTile6
property int index: 5
property string toonTempStr : app.tempCurrent[index]
property string toonHumStr : app.humCurrent[index]
property string toonHidStr : app.hidCurrent[index]
property string sensorNamesStr : app.sensorNames[index]
property bool isDHT : app.dht[index]
property string unit : app.units[index]
onClicked: {
stage.openFullscreen(app.toonTempScreenUrl)
}
Component.onCompleted: {
app.temperaturesUpdated6.connect(updateTile);
}
function updateTile() {
toonTempStr = app.tempCurrent[index]
toonHumStr = app.humCurrent[index]
toonHidStr = app.hidCurrent[index]
sensorNamesStr = app.sensorNames[index]
unit = app.units[index]
isDHT = app.dht[index]
var textwidth
if(isNxt){
textwidth = ((parent.width/2) - (toonTempStr.length*32))/(1+(unit.length*4))
if(typeof textwidth == 'number'){
if (textwidth <32){
domunits.font.pixelSize = textwidth
}else{
domunits.font.pixelSize = 32
}
}
}else{
textwidth = ((parent.width/2) - (toonTempStr.length*25))/(1+(unit.length*4))
if(typeof textwidth == 'number'){
if (textwidth <25){
domunits.font.pixelSize = textwidth
}else{
domunits.font.pixelSize = 25
}
}
}
}
//IF NOT DHT SENSOR
Text {
id: toonTemp
text: toonTempStr
color: dimmableColors.clockTileColor
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
font.pixelSize: dimState ? qfont.clockFaceText : qfont.timeAndTemperatureText
font.family: qfont.regular.name
visible: !isDHT
}
Text {
id: degree1
text: unit
color: dimmableColors.clockTileColor
anchors {
top: toonTemp.top
left: toonTemp.right
leftMargin: isNxt ? 6 : 5
}
font.pixelSize: isNxt ? 32 : 25
font.family: qfont.regular.name
visible: !isDHT & (unit == "o")
}
Text {
id: domunits
text: unit
color: dimmableColors.clockTileColor
anchors {
//bottom: toonTemp.bottom
verticalCenter: toonTemp.verticalCenter
left: toonTemp.right
leftMargin: isNxt ? 16 : 5
}
font.pixelSize: isNxt ? 150/unit.length() : 25
font.family: qfont.regular.name
visible: !isDHT & (unit != "o")
}
//IF DHT SENSOR
Text {
id: toonTemp2
text: toonTempStr
color: dimmableColors.clockTileColor
anchors {
left: parent.left
leftMargin : isNxt? 8:6
top: parent.top
topMargin: isNxt? 8:6
}
horizontalAlignment: Text.AlignHCenter
font.pixelSize: isNxt? 36:29
font.family: qfont.regular.name
visible: isDHT
}
Text {
id: degree2
text: "o"
color: dimmableColors.clockTileColor
anchors {
top: toonTemp2.top
left: toonTemp2.right
leftMargin: isNxt ? 5 : 4
}
font.pixelSize: isNxt? 25:20
font.family: qfont.regular.name
visible: isDHT
}
Text {
id: humidity
text: toonHumStr + "%"
color: dimmableColors.clockTileColor
anchors {
right: parent.right
rightMargin : isNxt? 8:6
top: parent.top
topMargin: isNxt? 8:6
}
horizontalAlignment: Text.AlignHCenter
font.pixelSize: isNxt? 36:29
font.family: qfont.regular.name
visible: isDHT
}
Text {
id: hid
text: toonHidStr
color: dimmableColors.clockTileColor
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
font.pixelSize: dimState ? qfont.clockFaceText : qfont.timeAndTemperatureText
font.family: qfont.regular.name
visible: isDHT
}
Text {
id: degree3
text: "o"
color: dimmableColors.clockTileColor
anchors {
top: hid.top
left: hid.right
leftMargin: isNxt ? 6 : 5
}
font.pixelSize: isNxt ? 32 : 25
font.family: qfont.regular.name
visible: isDHT
}
Text {
id: txtBottom
text: sensorNamesStr
color: dimmableColors.clockTileColor
anchors {
horizontalCenter: parent.horizontalCenter
baseline: parent.bottom
baselineOffset: designElements.vMarginNeg16
}
horizontalAlignment: Text.AlignHCenter
font.pixelSize: qfont.tileTitle
font.family: qfont.regular.name
}
}