FlightDisplayViewWidgets.qml 8.77 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

18 19 20 21 22 23
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
24 25

Item {
26
    id: _root
27

28
    property var    qgcView
29
    property bool   useLightColors
30
    property var    missionController
Don Gagne's avatar
Don Gagne committed
31

32 33 34
    property var    _activeVehicle:         QGroundControl.multiVehicleManager.activeVehicle
    property bool   _isSatellite:           _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
    property bool   _lightWidgetBorders:    _isSatellite
35

36
    readonly property real _margins:        ScreenTools.defaultFontPixelHeight * 0.5
dogmaphobic's avatar
dogmaphobic committed
37

38
    QGCMapPalette { id: mapPal; lightColors: useLightColors }
39
    QGCPalette    { id: qgcPal }
40

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

50
    function _setInstrumentWidget() {
51 52 53 54
        if(QGroundControl.corePlugin.options.instrumentWidget) {
            if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
                instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source
                switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) {
Gus Grubba's avatar
Gus Grubba committed
55 56 57 58 59 60 61 62 63
                case CustomInstrumentWidget.POS_TOP_LEFT:
                    instrumentsLoader.state  = "topLeftMode"
                    break;
                case CustomInstrumentWidget.POS_BOTTOM_LEFT:
                    instrumentsLoader.state  = "bottomLeftMode"
                    break;
                case CustomInstrumentWidget.POS_CENTER_LEFT:
                    instrumentsLoader.state  = "centerLeftMode"
                    break;
64
                case CustomInstrumentWidget.POS_TOP_RIGHT:
Gus Grubba's avatar
Gus Grubba committed
65
                    instrumentsLoader.state  = "topRightMode"
66 67
                    break;
                case CustomInstrumentWidget.POS_BOTTOM_RIGHT:
Gus Grubba's avatar
Gus Grubba committed
68
                    instrumentsLoader.state  = "bottomRightMode"
69 70 71
                    break;
                case CustomInstrumentWidget.POS_CENTER_RIGHT:
                default:
Gus Grubba's avatar
Gus Grubba committed
72
                    instrumentsLoader.state  = "centerRightMode"
73 74
                    break;
                }
75
            } else {
76
                instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
77
            }
78 79
        } else {
            instrumentsLoader.source = ""
80 81 82 83
        }
    }

    Connections {
84 85
        target:         QGroundControl.settingsManager.appSettings.virtualJoystick
        onValueChanged: _setInstrumentWidget()
86 87
    }

88 89 90 91 92
    Connections {
        target:         QGroundControl.settingsManager.appSettings.showLargeCompass
        onValueChanged: _setInstrumentWidget()
    }

93 94 95 96
    Component.onCompleted: {
        _setInstrumentWidget()
    }

Don Gagne's avatar
Don Gagne committed
97
    //-- Map warnings
98
    Column {
Don Gagne's avatar
Don Gagne committed
99
        anchors.horizontalCenter:   parent.horizontalCenter
100
        anchors.top:                parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
101 102 103 104
        spacing:                    ScreenTools.defaultFontPixelHeight

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
105
            visible:                    _activeVehicle && !_activeVehicle.coordinate.isValid && _mainIsMap
Don Gagne's avatar
Don Gagne committed
106 107
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
108
            font.pointSize:             ScreenTools.largeFontPointSize
109
            text:                       qsTr("No GPS Lock for Vehicle")
Don Gagne's avatar
Don Gagne committed
110 111 112 113
        }

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
114
            visible:                    _activeVehicle && _activeVehicle.prearmError
Don Gagne's avatar
Don Gagne committed
115 116
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
117
            font.pointSize:             ScreenTools.largeFontPointSize
Don Gagne's avatar
Don Gagne committed
118
            text:                       _activeVehicle ? _activeVehicle.prearmError : ""
119
        }
120 121 122 123 124 125 126 127 128 129

        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
130
            text:                       "The vehicle has failed a pre-arm check. In order to arm the vehicle, resolve the failure."
131
        }
132 133
    }

dogmaphobic's avatar
dogmaphobic committed
134
    //-- Instrument Panel
135 136
    Loader {
        id:                     instrumentsLoader
137
        anchors.margins:        ScreenTools.defaultFontPixelHeight / 2
138
        anchors.right:          parent.right
139
        z:                      QGroundControl.zOrderWidgets
140 141 142 143
        property var  qgcView:  _root.qgcView
        property real maxHeight:parent.height - (anchors.margins * 2)
        states: [
            State {
Gus Grubba's avatar
Gus Grubba committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
                name:   "topRightMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.verticalCenter: undefined
                    anchors.bottom:         undefined
                    anchors.top:            _root ? _root.top : undefined
                    anchors.right:          _root ? _root.right : undefined
                    anchors.left:           undefined
                }
            },
            State {
                name:   "centerRightMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
                    anchors.bottom:         undefined
                    anchors.verticalCenter: _root ? _root.verticalCenter : undefined
                    anchors.right:          _root ? _root.right : undefined
                    anchors.left:           undefined
                }
            },
            State {
                name:   "bottomRightMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
                    anchors.verticalCenter: undefined
                    anchors.bottom:         _root ? _root.bottom : undefined
                    anchors.right:          _root ? _root.right : undefined
                    anchors.left:           undefined
                }
            },
            State {
                name:   "topLeftMode"
178 179 180
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.verticalCenter: undefined
181
                    anchors.bottom:         undefined
182
                    anchors.top:            _root ? _root.top : undefined
Gus Grubba's avatar
Gus Grubba committed
183 184
                    anchors.right:          undefined
                    anchors.left:           _root ? _root.left : undefined
185 186 187
                }
            },
            State {
Gus Grubba's avatar
Gus Grubba committed
188
                name:   "centerLeftMode"
189 190 191
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
192
                    anchors.bottom:         undefined
193
                    anchors.verticalCenter: _root ? _root.verticalCenter : undefined
Gus Grubba's avatar
Gus Grubba committed
194 195
                    anchors.right:          undefined
                    anchors.left:           _root ? _root.left : undefined
196
                }
197 198
            },
            State {
Gus Grubba's avatar
Gus Grubba committed
199
                name:   "bottomLeftMode"
200 201 202 203 204
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
                    anchors.verticalCenter: undefined
                    anchors.bottom:         _root ? _root.bottom : undefined
Gus Grubba's avatar
Gus Grubba committed
205 206
                    anchors.right:          undefined
                    anchors.left:           _root ? _root.left : undefined
207
                }
208 209
            }
        ]
210
    }
211
}