-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDeviceEnvironmental.qml
1118 lines (940 loc) · 46.1 KB
/
DeviceEnvironmental.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick
import QtQuick.Controls
import ThemeEngine 1.0
import DeviceUtils 1.0
import "qrc:/js/UtilsDeviceSensors.js" as UtilsDeviceSensors
Loader {
id: deviceEnvironmental
property var currentDevice: null
////////
function loadDevice(clickedDevice) {
// set device
if (typeof clickedDevice === "undefined" || !clickedDevice) return
if (!clickedDevice.isEnvironmentalSensor) return
if (clickedDevice === currentDevice) return
currentDevice = clickedDevice
// load screen
deviceEnvironmental.active = true
deviceEnvironmental.item.loadDevice()
// change screen
appContent.state = "DeviceEnvironmental"
}
////////
function backAction() {
if (deviceEnvironmental.status === Loader.Ready)
deviceEnvironmental.item.backAction()
}
////////////////////////////////////////////////////////////////////////////
active: false
asynchronous: false
sourceComponent: Item {
id: itemDeviceEnvironmental
implicitWidth: 480
implicitHeight: 720
focus: parent.focus
// 1: single column (single column view or portrait tablet)
// 2: wide mode (wide view)
property int uiMode: (singleColumn || (isTablet && screenOrientation === Qt.PortraitOrientation)) ? 1 : 2
property bool isAirMonitor: false
property bool isWeatherStation: false
property bool isGeigerCounter: false
property string primary: "voc"
property string cccc: headerUnicolor ? Theme.colorHeaderContent : "white"
property var historyChart: chartEnvLoader.item
property int itemCount_AirMonitor: 3
property int itemCount_GeigerCounter: 2
property int itemCount_WeatherStation: 3
////////
Connections {
target: currentDevice
function onSensorUpdated() { updateHeader() }
function onSensorsUpdated() { updateHeader() }
function onCapabilitiesUpdated() { updateHeader() }
function onStatusUpdated() { updateHeader() }
function onDataUpdated() {
updateHeader()
updateData()
}
function onRefreshUpdated() {
updateHeader()
updateData()
updateGraph()
}
function onHistoryUpdated() {
updateHeader()
updateGraph()
}
}
Connections {
target: settingsManager
function onTempUnitChanged() {
updateData()
}
function onAppLanguageChanged() {
updateData()
updateStatusText()
}
}
Connections {
target: appHeader
// desktop only
function onDeviceDataButtonClicked() {
appHeader.setActiveDeviceData()
}
function onDeviceSettingsButtonClicked() {
appHeader.setActiveDeviceSettings()
}
// mobile only
function onRightMenuClicked() {
//
}
}
Timer {
interval: 60000; running: true; repeat: true;
onTriggered: updateStatusText()
}
////////
Keys.onPressed: (event) => {
if (event.key === Qt.Key_F5) {
event.accepted = true
deviceManager.updateDevice(currentDevice.deviceAddress)
} else if (event.key === Qt.Key_Backspace) {
event.accepted = true
appWindow.backAction()
}
}
onPrimaryChanged: {
currentDevice.setSetting("primary", primary)
loadIndicator()
if (chartEnvLoader.status === Loader.Ready) historyChart.updateGraph()
}
////////
function backAction() {
if (textInputLocation.focus) {
textInputLocation.focus = false
return
}
if (isHistoryMode()) {
resetHistoryMode()
return
}
appContent.state = "DeviceList"
}
function isHistoryMode() {
return false
}
function resetHistoryMode() {
return
}
////////
function loadDevice() {
//console.log("DeviceEnvironmental // loadDevice() >> " + currentDevice)
if (currentDevice.hasSetting("primary")) {
primary = currentDevice.getSetting("primary")
} else {
if (currentDevice.hasVocSensor) primary = "voc"
else if (currentDevice.hasCo2Sensor) primary = "co2"
else if (currentDevice.hasPM10Sensor) primary = "pm10"
else if (currentDevice.hasPM25Sensor) primary = "pm25"
else if (currentDevice.hasHchoSensor) primary = "hcho"
else if (currentDevice.hasGeigerCounter) primary = "nuclear"
else primary = "hygrometer"
}
// Update device type
if (currentDevice.hasPM1Sensor || currentDevice.hasPM25Sensor || currentDevice.hasPM10Sensor ||
currentDevice.hasO2Sensor || currentDevice.hasO3Sensor ||
currentDevice.hasCoSensor || currentDevice.hasCo2Sensor ||
currentDevice.hasNo2Sensor || currentDevice.hasSo2Sensor ||
currentDevice.hasVocSensor || currentDevice.hasHchoSensor) {
isAirMonitor = true
} else {
isAirMonitor = false
}
isGeigerCounter = currentDevice.hasGeigerCounter
if (currentDevice.hasTemperatureSensor || currentDevice.hasHumiditySensor ||
currentDevice.hasPressureSensor ||
currentDevice.hasLuminositySensor || currentDevice.hasUvSensor ||
currentDevice.hasSoundSensor ||
currentDevice.hasWaterLevelSensor ||
currentDevice.hasWindDirectionSensor || currentDevice.hasWindSpeedSensor) {
isWeatherStation = true
} else {
isWeatherStation = false
}
// Update sizes
itemCount_AirMonitor = 0
if (currentDevice.hasPM1Sensor) itemCount_AirMonitor++
if (currentDevice.hasPM25Sensor) itemCount_AirMonitor++
if (currentDevice.hasPM10Sensor) itemCount_AirMonitor++
if (currentDevice.hasVocSensor) itemCount_AirMonitor++
if (currentDevice.hasHchoSensor) itemCount_AirMonitor++
if (currentDevice.hasCo2Sensor) itemCount_AirMonitor++
if (itemCount_AirMonitor > 3) itemCount_AirMonitor = 3
airFlow.updateSize()
itemCount_WeatherStation = 0
if (currentDevice.hasTemperatureSensor) itemCount_WeatherStation++
if (currentDevice.hasHumiditySensor) itemCount_WeatherStation++
if (currentDevice.hasPressureSensor) itemCount_WeatherStation++
if (currentDevice.hasSoundSensor) itemCount_WeatherStation++
if (currentDevice.hasLuminositySensor) itemCount_WeatherStation++
if (currentDevice.hasUvSensor) itemCount_WeatherStation++
weatherFlow.updateSize()
// Force graph reload
chartEnvLoader.source = ""
//
loadIndicator()
loadGraph()
//
updateHeader()
updateData()
}
function loadIndicator() {
if (typeof currentDevice === "undefined" || !currentDevice) return
if (!currentDevice.isEnvironmentalSensor) return
//console.log("DeviceEnvironmental // loadIndicator()")
if (primary === "voc") {
indicatorAirQuality.legend = qsTr("VOC")
indicatorAirQuality.limitMin = 500
indicatorAirQuality.limitMax = 1000
indicatorAirQuality.valueMin = 0
indicatorAirQuality.valueMax = 1500
indicatorAirQuality.value = currentDevice.voc
} else if (primary === "hcho") {
indicatorAirQuality.legend = qsTr("HCHO")
indicatorAirQuality.limitMin = 250
indicatorAirQuality.limitMax = 750
indicatorAirQuality.valueMin = 0
indicatorAirQuality.valueMax = 1000
indicatorAirQuality.value = currentDevice.hcho
} else if (primary === "co2") {
indicatorAirQuality.legend = (currentDevice.haseCo2Sensor ? qsTr("eCO₂") : qsTr("CO₂"))
indicatorAirQuality.limitMin = 1000
indicatorAirQuality.limitMax = 2000
indicatorAirQuality.valueMin = 0
indicatorAirQuality.valueMax = 3000
indicatorAirQuality.value = currentDevice.co2
} else if (primary === "pm25") {
indicatorAirQuality.legend = qsTr("PM2.5")
indicatorAirQuality.limitMin = 60
indicatorAirQuality.limitMax = 120
indicatorAirQuality.valueMin = 0
indicatorAirQuality.valueMax = 240
indicatorAirQuality.value = currentDevice.pm25
} else if (primary === "pm10") {
indicatorAirQuality.legend = qsTr("PM10")
indicatorAirQuality.limitMin = 100
indicatorAirQuality.limitMax = 350
indicatorAirQuality.valueMin = 0
indicatorAirQuality.valueMax = 500
indicatorAirQuality.value = currentDevice.pm10
}
if (primary === "hygrometer") {
//
}
if (primary === "barometer") {
//
}
}
function updateHeader() {
if (typeof currentDevice === "undefined" || !currentDevice) return
if (!currentDevice.isEnvironmentalSensor) return
//console.log("DeviceEnvironmental // updateHeader() >> " + currentDevice)
//indicatorAirQuality.visible = isAirMonitor && currentDevice.hasDataToday
//indicatorRadioactivity.visible = isGeigerCounter && currentDevice.hasDataToday
//indicatorHygrometer.visible = isWeatherStation && currentDevice.hasDataToday
// Indicators
if (primary === "hygrometer") {
if (currentDevice.temperatureC < -40) {
sensorTemp.visible = false
heatIndex.visible = false
sensorHygro.visible = false
} else {
if (currentDevice.temperatureC >= -40) {
sensorTemp.text = currentDevice.getTempString()
sensorTemp.visible = true
}
if (currentDevice.humidity >= 0) {
sensorHygro.text = currentDevice.humidity.toFixed(0) + "% " + qsTr("humidity")
sensorHygro.visible = true
}
if (currentDevice.temperatureC >= 27 && currentDevice.humidity >= 40) {
if (currentDevice.getHeatIndex() > (currentDevice.temperature + 1)) {
heatIndex.text = qsTr("feels like %1").arg(currentDevice.getHeatIndexString())
heatIndex.visible = true
} else {
heatIndex.visible = false
}
} else {
heatIndex.visible = false
}
}
} else if (primary === "barometer") {
// TODO
} else if (isAirMonitor) {
if (primary === "voc") indicatorAirQuality.value = currentDevice.voc
else if (primary === "hcho") indicatorAirQuality.value = currentDevice.hcho
else if (primary === "co2") indicatorAirQuality.value = currentDevice.co2
else if (primary === "co") indicatorAirQuality.value = currentDevice.co
else if (primary === "o2") indicatorAirQuality.value = currentDevice.o2
else if (primary === "o3") indicatorAirQuality.value = currentDevice.o3
else if (primary === "no2") indicatorAirQuality.value = currentDevice.no2
else if (primary === "so2") indicatorAirQuality.value = currentDevice.so2
else if (primary === "pm1") indicatorAirQuality.value = currentDevice.pm1
else if (primary === "pm25") indicatorAirQuality.value = currentDevice.pm25
else if (primary === "pm10") indicatorAirQuality.value = currentDevice.pm10
}
// Battery level
//imageBattery.visible = (currentDevice.hasBattery && currentDevice.deviceBattery >= 0)
//imageBattery.source = UtilsDeviceSensors.getDeviceBatteryIcon(currentDevice.deviceBattery)
//imageBattery.color = UtilsDeviceSensors.getDeviceBatteryColor(currentDevice.deviceBattery)
// Status
updateStatusText()
}
function updateData() {
if (typeof currentDevice === "undefined" || !currentDevice) return
if (!currentDevice.isEnvironmentalSensor) return
//console.log("DeviceEnvironmental // updateData() >> " + currentDevice)
}
function updateStatusText() {
if (typeof currentDevice === "undefined" || !currentDevice) return
if (!currentDevice.isEnvironmentalSensor) return
//console.log("DeviceEnvironmental // updateStatusText() >> " + currentDevice)
textStatus.text = UtilsDeviceSensors.getDeviceStatusText(currentDevice.status)
if (currentDevice.status === DeviceUtils.DEVICE_OFFLINE &&
(currentDevice.isDataFresh_rt() || currentDevice.isDataToday())) {
if (currentDevice.lastUpdateMin <= 1)
textStatus.text = qsTr("Synced")
else
textStatus.text = qsTr("Synced %1 ago").arg(currentDevice.lastUpdateStr)
}
}
function loadGraph() {
chartEnvLoader.visible = false
if (isAirMonitor) {
if (currentDevice.hasVocSensor || currentDevice.hasHchoSensor || currentDevice.hasCo2Sensor) {
if (chartEnvLoader.status !== Loader.Ready) {
chartEnvLoader.source = "ChartEnvironmentalVoc.qml"
} else {
historyChart.loadGraph()
historyChart.updateGraph()
}
currentDevice.updateChartData_environmentalVoc(31)
chartEnvLoader.visible = true
}
}
}
function updateGraph() {
if (typeof currentDevice === "undefined" || !currentDevice) return
if (!currentDevice.isEnvironmentalSensor) return
//console.log("DeviceEnvironmental // updateGraph() >> " + currentDevice)
// GRAPH
if (isAirMonitor) {
if (currentDevice.hasVocSensor || currentDevice.hasHchoSensor || currentDevice.hasCo2Sensor) {
currentDevice.updateChartData_environmentalVoc(31)
}
}
}
////////////////////////////////////////////////////////////////////
property real fakeAQI: 25
// 0- 50 (good)
// 51-100 (moderate)
// 101-150 (unhealthy for Sensitive Groups)
// 151-200 (unhealthy)
// 201-300 (Very Unhealthy)
// 301-500 (Hazardous)
////////////////////////////////////////////////////////////////////
Flow {
anchors.fill: parent
Rectangle {
id: headerBox
property int dimboxw: Math.min(deviceEnvironmental.width * 0.4, isPhone ? 320 : 600)
property int dimboxh: Math.max(deviceEnvironmental.height * 0.333, isPhone ? 180 : 256)
width: (uiMode === 1) ? parent.width : dimboxw
height: (uiMode === 1) ? dimboxh : parent.height
color: Theme.colorHeader
z: 5
//MouseArea { anchors.fill: parent } // prevent clicks below this area
Item {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 24
////////////////
IconSvg {
id: indicatorDisconnected
width: isMobile ? 96 : 128
height: isMobile ? 96 : 128
anchors.centerIn: parent
visible: (currentDevice && !currentDevice.hasDataToday)
source: "qrc:/assets/icons_material/baseline-bluetooth_disabled-24px.svg"
color: cccc
}
////////////////
AirQualityIndicator {
id: indicatorAirQuality
width: (uiMode === 1) ? headerBox.height-24 : headerBox.width * 0.60
height: width
anchors.centerIn: parent
visible: (currentDevice && isAirMonitor && currentDevice.hasDataToday)
color: cccc
}
////////////////
Column {
id: indicatorHygrometer
width: isMobile ? 96 : 128
height: isMobile ? 96 : 128
anchors.centerIn: parent
spacing: 2
visible: (currentDevice && currentDevice.hasDataToday &&
(primary === "hygrometer" || primary === "barometer"))
Text {
id: sensorTemp
anchors.horizontalCenter: parent.horizontalCenter
font.bold: false
font.pixelSize: isPhone ? 44 : 48
color: cccc
}
Text {
id: heatIndex
anchors.horizontalCenter: parent.horizontalCenter
font.bold: false
font.pixelSize: isPhone ? 19 : 20
color: cccc
}
Text {
id: sensorHygro
anchors.horizontalCenter: parent.horizontalCenter
font.bold: false
font.pixelSize: isPhone ? 22 : 24
color: cccc
}
}
////////////////
}
////////
Row {
id: status
anchors.left: parent.left
anchors.leftMargin: 8
anchors.right: itemLocation.left
anchors.rightMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
height: 24
spacing: 8
IconSvg {
id: imageStatus
width: 24
height: 24
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/assets/icons_material/duotone-schedule-24px.svg"
color: cccc
}
Text {
id: textStatus
width: status.width - status.spacing - imageStatus.width
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Loading…")
color: cccc
font.bold: false
font.pixelSize: 17
elide: Text.ElideRight
}
}
////////
Row {
id: itemLocation
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
anchors.right: parent.right
anchors.rightMargin: 8
height: 24
spacing: 4
IconSvg {
id: imageEditLocation
width: 20
height: 20
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/assets/icons_material/duotone-edit-24px.svg"
color: cccc
opacity: (isMobile || !textInputLocation.text || textInputLocation.focus || textInputLocationArea.containsMouse) ? 0.9 : 0
Behavior on opacity { OpacityAnimator { duration: 133 } }
}
TextInput {
id: textInputLocation
anchors.verticalCenter: parent.verticalCenter
padding: 4
font.pixelSize: 17
font.bold: false
color: cccc
text: currentDevice.deviceLocationName
onEditingFinished: {
currentDevice.deviceLocationName = text
focus = false
}
MouseArea {
id: textInputLocationArea
anchors.fill: parent
anchors.topMargin: -4
anchors.leftMargin: -24
anchors.rightMargin: -4
anchors.bottomMargin: -4
hoverEnabled: true
propagateComposedEvents: true
onPressed: (mouse) => {
textInputLocation.forceActiveFocus()
mouse.accepted = false
}
}
}
IconSvg {
id: imageLocation
width: 24
height: 24
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/assets/icons_material/duotone-pin_drop-24px.svg"
color: cccc
}
}
////////
Rectangle {
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !singleColumn
width: 2
opacity: 0.33
color: Theme.colorHeaderHighlight
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: singleColumn
height: 2
opacity: 0.33
color: Theme.colorHeaderHighlight
}
}
////////////////////////////////////////////////////////////////
Item {
id: sensorBox
width: {
if (isTablet && screenOrientation == Qt.PortraitOrientation) return parent.width
return singleColumn ? parent.width : (parent.width - headerBox.width)
}
height: {
if (isTablet && screenOrientation == Qt.PortraitOrientation) return (parent.height - headerBox.height)
return singleColumn ? (parent.height - headerBox.height) : parent.height
}
ItemBannerSync {
id: bannersync
z: 5
anchors.left: parent.left
anchors.right: parent.right
}
////////////////
Flickable {
id: sensorFlick
anchors.top: bannersync.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentWidth: parent.width
contentHeight: sensorFlow.height
flickableDirection: Flickable.VerticalFlick
boundsBehavior: Flickable.StopAtBounds
Flow {
id: sensorFlow
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
id: airBoxes
width: parent.width
height: airFlow.height + (airFlow.anchors.topMargin*2)
visible: isAirMonitor
color: headerUnicolor ? Theme.colorBackground : Theme.colorForeground
z: 3
Flow {
id: airFlow
anchors.top: parent.top
anchors.topMargin: isDesktop ? 20 : 14
anchors.left: parent.left
anchors.leftMargin: isDesktop ? 20 : 14
anchors.right: parent.right
anchors.rightMargin: 0
spacing: 8
onWidthChanged: updateSize()
function updateSize() {
var availableWidth = sensorBox.width - (anchors.leftMargin + anchors.rightMargin)
var cellColumnsTarget = Math.trunc(availableWidth / (wwwTarget + spacing))
if (cellColumnsTarget >= itemCount_AirMonitor) {
www = (availableWidth - (spacing * itemCount_AirMonitor)) / itemCount_AirMonitor
if (www > wwwMax) www = wwwMax
} else {
www = (availableWidth - (spacing * cellColumnsTarget)) / cellColumnsTarget
}
//console.log("--- wwww: " + www)
}
property int wwwTarget: isPhone ? 96 : 140
property int wwwMax: 200
property int www: wwwTarget
ItemEnvBox {
id: pm1
width: airFlow.www
visible: currentDevice.hasPM1Sensor
title: qsTr("PM1")
legend: qsTr("µg/m³")
value: currentDevice.pm1
precision: 0
onSensorSelection: primary = "pm1"
}
ItemEnvBox {
id: pm25
width: airFlow.www
visible: currentDevice.hasPM25Sensor
title: qsTr("PM2.5")
legend: qsTr("µg/m³")
value: currentDevice.pm25
limit_mid: 60
limit_high: 120
precision: 0
onSensorSelection: primary = "pm25"
}
ItemEnvBox {
id: pm100
width: airFlow.www
visible: currentDevice.hasPM10Sensor
title: qsTr("PM10")
legend: qsTr("µg/m³")
value: currentDevice.pm10
limit_mid: 100
limit_high: 350
precision: 0
onSensorSelection: primary = "pm10"
}
ItemEnvBox {
id: voc
width: airFlow.www
visible: currentDevice.hasVocSensor
title: qsTr("VOC")
legend: qsTr("µg/m³")
value: currentDevice.voc
limit_mid: 500
limit_high: 1000
precision: 0
onSensorSelection: primary = "voc"
}
ItemEnvBox {
id: hcho
width: airFlow.www
visible: currentDevice.hasHchoSensor
title: qsTr("HCHO")
legend: qsTr("µg/m³")
value: currentDevice.hcho
limit_mid: 500
limit_high: 1000
precision: 0
onSensorSelection: primary = "hcho"
}
/*
ItemEnvBox {
id: o2
width: airFlow.www
visible: currentDevice.hasO2Sensor
title: qsTr("O₂")
legend: qsTr("µg/m³")
value: currentDevice.o2
precision: 0
onSensorSelection: primary = "o2"
}
ItemEnvBox {
id: o3
width: airFlow.www
visible: currentDevice.hasO3Sensor
title: qsTr("O₃")
legend: qsTr("µg/m³")
value: currentDevice.o3
precision: 0
onSensorSelection: primary = "o3"
}
ItemEnvBox {
id: so2
width: airFlow.www
visible: currentDevice.hasSo2Sensor
title: qsTr("SO₂")
legend: qsTr("µg/m³")
value: currentDevice.so2
precision: 0
onSensorSelection: primary = "so2"
}
ItemEnvBox {
id: no2
width: airFlow.www
visible: currentDevice.hasNo2Sensor
title: qsTr("NO₂")
legend: qsTr("µg/m³")
value: currentDevice.no2
precision: 0
onSensorSelection: primary = "no2"
}
ItemEnvBox {
id: co
width: airFlow.www
visible: currentDevice.hasCoSensor
title: qsTr("CO")
legend: qsTr("ppm")
value: currentDevice.co
precision: 0
onSensorSelection: primary = "co"
}
*/
ItemEnvBox {
id: co2
width: airFlow.www
visible: currentDevice.hasCo2Sensor
title: (currentDevice.haseCo2Sensor ? qsTr("eCO₂") : qsTr("CO₂"))
legend: qsTr("ppm")
value: currentDevice.co2
precision: 0
limit_mid: 1000
limit_high: 2000
onSensorSelection: primary = "co2"
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !headerUnicolor
height: 2
color: Theme.colorSeparator
}
}
////////////////////////////////////////////////////
Rectangle {
id: radBoxes
width: parent.width
height: radFlow.height + (radFlow.anchors.topMargin*2)
visible: isGeigerCounter
color: headerUnicolor ? Theme.colorBackground : Theme.colorForeground
z: 3
Flow {
id: radFlow
anchors.top: parent.top
anchors.topMargin: isDesktop ? 20 : 12
anchors.left: parent.left
anchors.leftMargin: isDesktop ? 20 : 12
anchors.right: parent.right
anchors.rightMargin: 0
spacing: 12
onWidthChanged: updateSize()
function updateSize() {
var availableWidth = sensorBox.width - (anchors.leftMargin + anchors.rightMargin)
var cellColumnsTarget = Math.trunc(availableWidth / (wwwTarget + spacing))
if (cellColumnsTarget >= itemCount_GeigerCounter) {
www = (availableWidth - (spacing * itemCount_GeigerCounter)) / itemCount_GeigerCounter
if (www > wwwMax) www = wwwMax
} else {
www = (availableWidth - (spacing * cellColumnsTarget)) / cellColumnsTarget
}
//console.log("--- wwww: " + www)
}
property int wwwTarget: 128
property int wwwMax: 256
property int www: wwwTarget
ItemEnvBox {
id: rad_h
width: radFlow.www
title: qsTr("RADIATION")
legend: qsTr("µSv/h")
value: currentDevice.radioactivityH
precision: 2
limit_mid: 1
limit_high: 10
onSensorSelection: primary = "radiation"
}
ItemEnvBox {
id: rad_m
width: radFlow.www
title: qsTr("RADIATION")
legend: qsTr("µSv/m")
value: currentDevice.radioactivityM
precision: 2
limit_mid: 1
limit_high: 10
onSensorSelection: primary = "radiation"
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !headerUnicolor
height: 2
opacity: 0.5
color: Theme.colorSeparator
}
}
////////////////////////////////////////////////////
Rectangle {
id: weatherBoxes
visible: isWeatherStation
width: parent.width
height: weatherFlow.height + (weatherFlow.anchors.topMargin*2)
color: Theme.colorBackground
z: 3
Flow {
id: weatherFlow
anchors.top: parent.top
anchors.topMargin: isPhone ? 8 : 14
anchors.left: parent.left
anchors.leftMargin: isPhone ? 8 : 14
anchors.right: parent.right
anchors.rightMargin: 0
spacing: isPhone ? 8 : 14
onWidthChanged: updateSize()
function updateSize() {
var availableWidth = sensorBox.width - (anchors.leftMargin)
var cellColumnsTarget = Math.trunc(availableWidth / (wwwTarget + spacing))
if (cellColumnsTarget >= itemCount_WeatherStation) {
www = (availableWidth - (spacing * itemCount_WeatherStation)) / itemCount_WeatherStation
if (www > wwwMax) www = wwwMax
} else {
www = (availableWidth - (spacing * cellColumnsTarget)) / cellColumnsTarget
if (www > wwwMax) www = wwwMax
}
//console.log("--- wwww: " + www)
}
property int wwwTarget: isPhone ? 92 : 128
property int wwwMax: 160
property int www: wwwTarget
ItemWeatherBox {
id: temp
visible: currentDevice.hasTemperatureSensor
sz: weatherFlow.www
duo: false
title: qsTr("Temperature")
legend: "°" + settingsManager.tempUnit
icon: "qrc:/assets/icons_custom/thermometer-24px.svg"
value: currentDevice.temperature
precision: 1
//onSensorSelection: primary = "temperature"
}
ItemWeatherBox {
id: humi
visible: currentDevice.hasHumiditySensor
sz: weatherFlow.www
duo: false
title: qsTr("Humidity")
legend: qsTr("%")
icon: "qrc:/assets/icons_material/duotone-water_full-24px.svg"
value: currentDevice.humidity
precision: 0
//onSensorSelection: primary = "humidity"
}
ItemWeatherBox {