@@ -47,13 +47,25 @@ Rectangle {
47
47
triggeredOnStart: true
48
48
49
49
onTriggered: {
50
- // TODO create a device class instead of launching hard coded shell scripts from QML
50
+ // TODO(zehnm) create a device class instead of launching hard coded shell scripts from QML
51
51
uptimeValue .text = settingsLauncher .launch (" /usr/bin/yio-remote/uptime.sh" ).trim ();
52
- temperatureValue .text = Math .round (parseInt (settingsLauncher .launch (" cat /sys/class/thermal/thermal_zone0/temp" ))/ 1000 ) + " ºC" ;
52
+ // TODO(zehnm) create a sensor class for reading CPU temp instead of launching hard coded shell scripts from QML
53
+ var temp = parseInt (settingsLauncher .launch (" cat /sys/class/thermal/thermal_zone0/temp" )) / 1000
54
+ if (Number .isNaN (temp)) {
55
+ temp = 36
56
+ }
57
+
58
+ if (config .unitSystem === UnitSystem .IMPERIAL ) {
59
+ temperatureValue .text = Math .round (temp * 9 / 5 + 32 ) + " ºF"
60
+ } else {
61
+ temperatureValue .text = Math .round (temp) + " ºC"
62
+ }
53
63
}
54
64
}
55
65
56
- Component .onCompleted : timer .start ()
66
+ Component .onCompleted : {
67
+ timer .start ()
68
+ }
57
69
58
70
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
59
71
// UI ELEMENTS
@@ -71,6 +83,8 @@ Rectangle {
71
83
color: Style .color .background
72
84
}
73
85
86
+ ButtonGroup { id: radioGroup }
87
+
74
88
Item {
75
89
width: parent .width ; height: childrenRect .height + 40
76
90
@@ -82,11 +96,12 @@ Rectangle {
82
96
font: Style .font .button
83
97
}
84
98
85
- CheckBox {
99
+ RadioButton {
86
100
id: metricCheckBox
87
101
width: 40 ; height: 40
88
102
anchors { left: parent .left ; leftMargin: 20 ; top: unitText .bottom ; topMargin: 20 }
89
- checked: config .unitSystem == 0
103
+ checked: config .unitSystem === UnitSystem .METRIC
104
+ ButtonGroup .group : radioGroup
90
105
91
106
indicator: Rectangle {
92
107
implicitWidth: 20 ; implicitHeight: 20
@@ -102,9 +117,8 @@ Rectangle {
102
117
}
103
118
104
119
onCheckedChanged: {
105
- if (checked) {
106
- config .unitSystem = 0 ;
107
- }
120
+ config .unitSystem = checked ? UnitSystem .METRIC : UnitSystem .IMPERIAL
121
+ timer .restart ()
108
122
}
109
123
110
124
onPressed: {
@@ -123,11 +137,12 @@ Rectangle {
123
137
Behavior on opacity { NumberAnimation { duration: 200 } }
124
138
}
125
139
126
- CheckBox {
140
+ RadioButton {
127
141
id: imperialCheckBox
128
142
width: 40 ; height: 40
129
143
anchors { left: metricCheckBoxText .right ; leftMargin: 20 ; verticalCenter: metricCheckBox .verticalCenter }
130
- checked: config .unitSystem == 1
144
+ checked: config .unitSystem === UnitSystem .IMPERIAL
145
+ ButtonGroup .group : radioGroup
131
146
132
147
indicator: Rectangle {
133
148
implicitWidth: 20 ; implicitHeight: 20
@@ -143,12 +158,6 @@ Rectangle {
143
158
border { width: 2 ; color: imperialCheckBox .checked ? Style .color .highlight1 : Style .color .light }
144
159
}
145
160
146
- onCheckedChanged: {
147
- if (checked) {
148
- config .unitSystem = 1 ;
149
- }
150
- }
151
-
152
161
onPressed: {
153
162
Haptic .playEffect (Haptic .Click );
154
163
}
@@ -211,7 +220,7 @@ Rectangle {
211
220
Text {
212
221
id: temperatureValue
213
222
color: Style .color .text
214
- text: " 36ºC "
223
+ text: " "
215
224
horizontalAlignment: Text .AlignRight
216
225
anchors { right: parent .right ; rightMargin: 20 ; verticalCenter: temperatureText .verticalCenter }
217
226
font: Style .font .button
@@ -231,10 +240,10 @@ Rectangle {
231
240
anchors { top: parent .top ; topMargin: 30 ; left: parent .left ; leftMargin: (parent .width - (buttonReboot .width + buttonShutdown .width + 40 ))/ 2 }
232
241
233
242
mouseArea .onClicked : {
234
- // TODO create a framebuffer device class instead of launching hard coded shell scripts from QML
243
+ // TODO(zehnm) create a framebuffer device class instead of launching hard coded shell scripts from QML
235
244
settingsLauncher .launch (" fbv -d 1 $YIO_MEDIA_DIR/splash/bye.png" )
236
245
console .debug (" now reboot" )
237
- // TODO create a device class for system reboot instead of launching hard coded shell scripts from QML
246
+ // TODO(zehnm) create a device class for system reboot instead of launching hard coded shell scripts from QML
238
247
settingsLauncher .launch (" reboot" );
239
248
}
240
249
}
0 commit comments