Просмотр исходного кода

Allow display and entry of temperature measurements in Celsius on manual log entry

Neal Wilson 7 лет назад
Родитель
Сommit
25c539f7e2
1 измененных файлов: 23 добавлений и 1 удалений
  1. 23
    1
      config/Windows/manuallogentry.xml

+ 23
- 1
config/Windows/manuallogentry.xml Просмотреть файл

@@ -14,6 +14,9 @@
14 14
         <item id="15s">15 Second View</item>
15 15
         <item id="30s">30 Second View</item>
16 16
         <item id="1m">1 Minute View</item>
17
+		<separator />
18
+		<item id="showC">Display Celsius</item>
19
+		<item id="showF">Display Fahrenheit</item>
17 20
     </menu>
18 21
 	<layout type="vertical">
19 22
 		<tabbar id="tabs"/>
@@ -222,8 +225,27 @@
222 225
 		currenttemperature = findChildObject(this, 'currenttemperature');
223 226
 		currentnote = findChildObject(this, 'currentnote');
224 227
 		addmeasurement = findChildObject(this, 'addmeasurement');
228
+		var currentUnit = Units.Fahrenheit;
229
+		var showC = findChildObject(this, 'showC');
230
+        showC.triggered.connect(function() {
231
+            pluginContext.table.setDisplayUnits(Units.Celsius);
232
+            pluginContext.graph.showC();
233
+			QSettings.setValue("temperatureUnit", "C");
234
+			currentUnit = Units.Celsius;
235
+        });
236
+        var showF = findChildObject(this, 'showF');
237
+        showF.triggered.connect(function() {
238
+            pluginContext.table.setDisplayUnits(Units.Fahrenheit);
239
+            pluginContext.graph.showF();
240
+			QSettings.setValue("temperatureUnit", "F");
241
+			currentUnit = Units.Fahrenheit;
242
+        });
243
+		if(QSettings.value("temperatureUnit", "F") == "C") {
244
+			showC.trigger();
245
+		}
225 246
 		addmeasurement.clicked.connect(function() {
226
-			pluginContext.newMeasurement(new Measurement(Number(currenttemperature.text), currenttime.time), 1);
247
+			var fromUnit = 
248
+			pluginContext.newMeasurement(new Measurement(Units.convertTemperature(Number(currenttemperature.text), currentUnit, Units.Fahrenheit), currenttime.time), 1);
227 249
 			if(currentnote.text.length > 0) {
228 250
 				pluginContext.table.newAnnotation(currentnote.text, 1, 2);
229 251
 			}

Загрузка…
Отмена
Сохранить