AirspaceWeather.qml 1.98 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtQml                    2.2

Gus Grubba's avatar
Gus Grubba committed
7
import QGroundControl                   1.0
8 9
import QGroundControl.Airmap            1.0
import QGroundControl.Airspace          1.0
Gus Grubba's avatar
Gus Grubba committed
10 11
import QGroundControl.Controls          1.0
import QGroundControl.Palette           1.0
12
import QGroundControl.ScreenTools       1.0
Gus Grubba's avatar
Gus Grubba committed
13
import QGroundControl.SettingsManager   1.0
Gus Grubba's avatar
Gus Grubba committed
14 15

Item {
Gus Grubba's avatar
Gus Grubba committed
16 17
    height: _valid ? weatherRow.height : 0
    width:  _valid ? weatherRow.width  : 0
18
    property color  contentColor:       "#ffffff"
Gus Grubba's avatar
Gus Grubba committed
19
    property real   iconHeight:         ScreenTools.defaultFontPixelHeight * 2
20
    property bool   _valid:             QGroundControl.airspaceManager.weatherInfo.valid
Gus Grubba's avatar
Gus Grubba committed
21
    property bool   _celcius:           QGroundControl.settingsManager.unitsSettings.temperatureUnits.rawValue === UnitsSettings.TemperatureUnitsCelsius
22
    property int    _tempC:             _valid ? QGroundControl.airspaceManager.weatherInfo.temperature : 0
Gus Grubba's avatar
Gus Grubba committed
23
    property string _tempS:             (_celcius ? _tempC : _tempC * 1.8 + 32).toFixed(0) + (_celcius ? "°C" : "°F")
Gus Grubba's avatar
Gus Grubba committed
24
    Row {
Gus Grubba's avatar
Gus Grubba committed
25 26
        id:                         weatherRow
        spacing:                    ScreenTools.defaultFontPixelHeight * 0.5
Gus Grubba's avatar
Gus Grubba committed
27 28 29 30
        QGCColoredImage {
            width:                  height
            height:                 iconHeight
            sourceSize.height:      height
31
            source:                 _valid ? QGroundControl.airspaceManager.weatherInfo.icon : ""
32
            color:                  contentColor
Gus Grubba's avatar
Gus Grubba committed
33
            visible:                _valid
34
            fillMode:               Image.PreserveAspectFit
Gus Grubba's avatar
Gus Grubba committed
35 36 37
            anchors.verticalCenter: parent.verticalCenter
        }
        QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
38
            text:                   _tempS
39
            color:                  contentColor
Gus Grubba's avatar
Gus Grubba committed
40
            visible:                _valid
Gus Grubba's avatar
Gus Grubba committed
41 42 43 44
            anchors.verticalCenter: parent.verticalCenter
        }
    }
}