-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasyenergyScreen.qml
215 lines (194 loc) · 5.5 KB
/
EasyenergyScreen.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
import QtQuick 1.1
import qb.components 1.0
Screen {
id: easyenergyScreen
screenTitleIconUrl: "./drawables/easyenergyIcon.png"
screenTitle: "EasyEnergy"
// calculate height of bar or text value
function calculateHeight(maxHeight,tariff) {
var h = (app.settings.scaleGraph) ? 10 + (maxHeight - 30 - 10) * ((tariff-app.minTariffValue)/(app.maxTariffValue-app.minTariffValue)) : (maxHeight - 10) * (tariff/app.maxTariffValue)
return h
}
Rectangle {
id: mainRectangle
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
right: parent.right
leftMargin: 20
rightMargin: 20
}
color: colors.addDeviceBackgroundRectangle
}
StandardButton {
id: btnConfigScreen
width: 150
text: "Instellingen"
anchors.top : mainRectangle.top
anchors.right : mainRectangle.right
anchors.rightMargin : 10
anchors.topMargin : 10
onClicked: {
if (app.easyenergySettings) {
app.easyenergySettings.show();
}
}
}
Text {
id: tileTitle
anchors {
baseline: mainRectangle.top
baselineOffset: 30
horizontalCenter: mainRectangle.horizontalCenter
}
font {
family: qfont.regular.name
pixelSize: qfont.tileTitle
}
color: colors.tileTitleColor
text: "Huidig tarief"
}
Text {
id: txtTariff
text: "\u20AC" + app.normalizeTariff(app.currentTariffUsage)
color: app.currentTextColor()
anchors {
top: tileTitle.bottom
topMargin: 0
horizontalCenter: mainRectangle.horizontalCenter
}
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 30
font.family: qfont.regular.name
}
Row {
id: easyenergyScreenRow
anchors.bottom: mainRectangle.bottom
anchors.bottomMargin: 10
anchors.left: mainRectangle.left
anchors.leftMargin: 60
anchors.right: mainRectangle.right
anchors.rightMargin: 60
height: isNxt ? 340 : 250
Repeater {
id: easyenergyRowRepeater
model: app.datapoints
Item {
height: easyenergyScreenRow.height
width: (app.datapoints > 0) ? easyenergyScreenRow.width / app.datapoints : 0
Rectangle {
id: easyenergyHourBars
anchors.bottom: parent.bottom
anchors.bottomMargin: 30
anchors.horizontalCenter: parent.horizontalCenter
color: ((index + app.startHour) === app.currentHour) ? "#0099ff" : "#ff6600"
height: calculateHeight(easyenergyScreenRow.height,app.tariffValues[index])
width: (easyenergyScreenRow.width / app.datapoints - 5) // two pixels smaller than the parent item to keep gaps between the bars
}
Text {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: (index + app.startHour) % 24
font.pointSize: 12
color: colors.tileTextColor
visible: !((index + app.startHour) % 3) //show each 3 hours an x-index
}
}
}
}
Rectangle {
id: easyenergyQ3Line
anchors.bottom: easyenergyScreenRow.bottom
anchors.left: easyenergyScreenRow.left
width: easyenergyScreenRow.width
height: 2
opacity: 0.5
color: "#ff0000"
anchors.bottomMargin: 30 + calculateHeight(easyenergyScreenRow.height,app.tariffQ3)
border.width: 0
}
Text {
id: q3TariffValue
text: "\u20AC" + app.normalizeTariff(app.tariffQ3)
color: colors.tileTitleColor
anchors.left: mainRectangle.left
anchors.leftMargin: 5
anchors.verticalCenterOffset: 0
anchors.verticalCenter: easyenergyQ3Line.verticalCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
Rectangle {
id: easyenergyQ1Line
anchors.bottom: easyenergyScreenRow.bottom
anchors.left: easyenergyScreenRow.left
width: easyenergyScreenRow.width
height: 2
opacity: 0.5
color: "#00ff00"
anchors.bottomMargin: 30 + calculateHeight(easyenergyScreenRow.height,app.tariffQ1)
border.width: 0
}
Text {
id: q1TariffValue
text: "\u20AC" + app.normalizeTariff(app.tariffQ1)
color: colors.tileTitleColor
anchors.left: mainRectangle.left
anchors.leftMargin: 5
anchors.verticalCenterOffset: 0
anchors.verticalCenter: easyenergyQ1Line.verticalCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
Text {
id: maxTariffValueTxt
text: "\u20AC" + app.normalizeTariff(app.maxTariffValue)
color: colors.tileTitleColor
anchors.right: mainRectangle.right
anchors.rightMargin: 5
anchors.bottom: easyenergyScreenRow.bottom
anchors.bottomMargin: 22 + calculateHeight(easyenergyScreenRow.height,app.maxTariffValue)
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
Text {
id: minTariffValueTxt
text: "\u20AC" + app.normalizeTariff(app.minTariffValue)
color: colors.tileTitleColor
anchors.right: mainRectangle.right
anchors.rightMargin: 5
anchors.bottom: easyenergyScreenRow.bottom
anchors.bottomMargin: 22 + calculateHeight(easyenergyScreenRow.height,app.minTariffValue)
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
Text {
id: minMaxTxt
text: "Min/Max"
color: colors.tileTitleColor
anchors.right: mainRectangle.right
anchors.rightMargin: 5
anchors.bottom: easyenergyScreenRow.bottom
anchors.bottomMargin: 0
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
Text {
id: laagHoogTxt
text: "Laag/Hoog"
color: colors.tileTitleColor
anchors.left: mainRectangle.left
anchors.leftMargin: 5
anchors.bottom: easyenergyScreenRow.bottom
anchors.bottomMargin: 0
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
font.family: qfont.regular.name
}
}