From be0901cc892c15823976b840dc276dc39490cb0b Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 23 Jan 2018 08:24:40 -0500 Subject: [PATCH] Handle temperature units --- src/Airmap/AirspaceWeather.qml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Airmap/AirspaceWeather.qml b/src/Airmap/AirspaceWeather.qml index 0c822ba7b..c8a9c66e5 100644 --- a/src/Airmap/AirspaceWeather.qml +++ b/src/Airmap/AirspaceWeather.qml @@ -4,11 +4,12 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 import QtQml 2.2 -import QGroundControl 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.Airmap 1.0 +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Airmap 1.0 +import QGroundControl.SettingsManager 1.0 Item { height: _activeVehicle && _activeVehicle.airspaceController.hasWeather ? weatherRow.height : 0 @@ -16,6 +17,9 @@ Item { property var iconHeight: ScreenTools.defaultFontPixelWidth * 4 property color _colorWhite: "#ffffff" property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property bool _celcius: QGroundControl.settingsManager.unitsSettings.temperatureUnits.rawValue === UnitsSettings.TemperatureUnitsCelsius + property int _tempC: _activeVehicle ? _activeVehicle.airspaceController.weatherTemp : 0 + property string _tempS: (_celcius ? _tempC : _tempC * 1.8 + 32).toFixed(0) + (_celcius ? "°C" : "°F") Row { id: weatherRow spacing: ScreenTools.defaultFontPixelHeight * 0.5 @@ -29,7 +33,7 @@ Item { anchors.verticalCenter: parent.verticalCenter } QGCLabel { - text: _activeVehicle ? _activeVehicle.airspaceController.weatherTemp + "ºC" : "" + text: _tempS color: _colorWhite visible: _activeVehicle && _activeVehicle.airspaceController.hasWeather anchors.verticalCenter: parent.verticalCenter -- 2.22.0