FlightDisplayViewWidgets.qml 6.51 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9

10 11
import QtQuick                  2.3
import QtQuick.Controls         1.2
12
import QtQuick.Controls.Styles  1.4
13
import QtQuick.Dialogs          1.2
14 15
import QtLocation               5.3
import QtPositioning            5.3
16
import QtQuick.Layouts          1.2
17

Gus Grubba's avatar
Gus Grubba committed
18 19 20 21 22 23 24
import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.FlightMap     1.0
import QGroundControl.Airmap        1.0
25 26

Item {
Gus Grubba's avatar
Gus Grubba committed
27
    id: widgetRoot
28

29
    property var    qgcView
30
    property bool   useLightColors
31
    property var    missionController
Gus Grubba's avatar
Gus Grubba committed
32
    property bool   showValues:             true
Don Gagne's avatar
Don Gagne committed
33

34 35 36
    property var    _activeVehicle:         QGroundControl.multiVehicleManager.activeVehicle
    property bool   _isSatellite:           _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
    property bool   _lightWidgetBorders:    _isSatellite
Gus Grubba's avatar
Gus Grubba committed
37
    property bool   _enableAirMap:          QGroundControl.airmapSupported ? QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue : false
38

39
    readonly property real _margins:        ScreenTools.defaultFontPixelHeight * 0.5
dogmaphobic's avatar
dogmaphobic committed
40

41
    QGCMapPalette { id: mapPal; lightColors: useLightColors }
42
    QGCPalette    { id: qgcPal }
43

44
    function getPreferredInstrumentWidth() {
45
        if(ScreenTools.isMobile) {
46
            return mainWindow.width * 0.25
47 48
        } else if(ScreenTools.isHugeScreen) {
            return mainWindow.width * 0.11
49
        }
50
        return ScreenTools.defaultFontPixelWidth * 30
51 52
    }

53
    function _setInstrumentWidget() {
54 55 56
        if(QGroundControl.corePlugin.options.instrumentWidget) {
            if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
                instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source
57
            } else {
58 59 60
                // Note: We currently show alternate instruments all the time. This is a trial change for daily builds.
                // Leaving non-alternate code in for now in case the trial fails.
                var useAlternateInstruments = true//QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen
61 62 63 64 65
                if(useAlternateInstruments) {
                    instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
                } else {
                    instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml"
                }
66
            }
67 68
        } else {
            instrumentsLoader.source = ""
69 70 71 72
        }
    }

    Connections {
73 74
        target:         QGroundControl.settingsManager.appSettings.virtualJoystick
        onValueChanged: _setInstrumentWidget()
75 76
    }

77 78 79 80 81
    Connections {
        target:         QGroundControl.settingsManager.appSettings.showLargeCompass
        onValueChanged: _setInstrumentWidget()
    }

82 83 84 85
    Component.onCompleted: {
        _setInstrumentWidget()
    }

Don Gagne's avatar
Don Gagne committed
86
    //-- Map warnings
87
    Column {
Don Gagne's avatar
Don Gagne committed
88
        anchors.horizontalCenter:   parent.horizontalCenter
89
        anchors.top:                parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
90 91 92 93
        spacing:                    ScreenTools.defaultFontPixelHeight

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
94
            visible:                    _activeVehicle && !_activeVehicle.coordinate.isValid && _mainIsMap
Don Gagne's avatar
Don Gagne committed
95 96
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
97
            font.pointSize:             ScreenTools.largeFontPointSize
98
            text:                       qsTr("No GPS Lock for Vehicle")
Don Gagne's avatar
Don Gagne committed
99 100 101 102
        }

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
103
            visible:                    _activeVehicle && _activeVehicle.prearmError
Don Gagne's avatar
Don Gagne committed
104 105
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
106
            font.pointSize:             ScreenTools.largeFontPointSize
Don Gagne's avatar
Don Gagne committed
107
            text:                       _activeVehicle ? _activeVehicle.prearmError : ""
108
        }
109 110 111 112 113 114 115 116 117 118 119 120

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
            visible:                    _activeVehicle && _activeVehicle.prearmError
            width:                      ScreenTools.defaultFontPixelWidth * 50
            horizontalAlignment:        Text.AlignHCenter
            wrapMode:                   Text.WordWrap
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
            font.pointSize:             ScreenTools.largeFontPointSize
            text:                       "The vehicle has failed a pre-arm check. In order to arm the vehicle, resolve the failure or disable the arming check via the Safety tab on the Vehicle Setup page."
        }
121
    }
Gus Grubba's avatar
Gus Grubba committed
122 123 124 125 126 127
    Column {
        id:                     instrumentsColumn
        spacing:                ScreenTools.defaultFontPixelHeight * 0.25
        anchors.top:            parent.top
        anchors.topMargin:      QGroundControl.corePlugin.options.instrumentWidget.widgetTopMargin + (ScreenTools.defaultFontPixelHeight * 0.5)
        anchors.margins:        ScreenTools.defaultFontPixelHeight * 0.5
128
        anchors.right:          parent.right
Gus Grubba's avatar
Gus Grubba committed
129 130 131 132 133
        //-------------------------------------------------------
        // Airmap Airspace Control
        AirspaceControl {
            id:                 airspaceControl
            width:              getPreferredInstrumentWidth()
Gus Grubba's avatar
Gus Grubba committed
134
            visible:            _enableAirMap
Gus Grubba's avatar
Gus Grubba committed
135 136 137
            anchors.margins:    ScreenTools.defaultFontPixelHeight * 0.5
            onColapsedChanged: {
                widgetRoot.showValues = colapsed
138
            }
Gus Grubba's avatar
Gus Grubba committed
139 140 141 142 143 144 145 146 147
        }
        //-------------------------------------------------------
        //-- Instrument Panel
        Loader {
            id:                         instrumentsLoader
            anchors.margins:            ScreenTools.defaultFontPixelHeight * 0.5
            property var  qgcView:      widgetRoot.qgcView
            property real maxHeight:    widgetRoot ? widgetRoot.height - instrumentsColumn.y - airspaceControl.height - (ScreenTools.defaultFontPixelHeight * 4) : 0
        }
148
    }
149
}