FlightDisplayViewWidgets.qml 25.7 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 29
    property alias  guidedModeBar:          _guidedModeBar
    property bool   gotoEnabled:            _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
30
    property var    qgcView
31
    property bool   useLightColors
32
    property var    missionController
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
37

38 39 40
    // Guided bar properties
    property bool _missionAvailable:    missionController.containsItems
    property bool _missionActive:       _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.missionFlightMode : false
41 42 43
    property bool _vehiclePaused:       _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.pauseFlightMode : false
    property bool _vehicleInRTLMode:    _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.rtlFlightMode : false
    property bool _vehicleInLandMode:   _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.landFlightMode : false
44
    property int  _resumeMissionItem:   missionController.resumeMissionItem
45 46 47
    property bool _showEmergenyStop:    QGroundControl.corePlugin.options.guidedBarShowEmergencyStop
    property bool _showOrbit:           QGroundControl.corePlugin.options.guidedBarShowOrbit

48
    readonly property real _margins:        ScreenTools.defaultFontPixelHeight * 0.5
dogmaphobic's avatar
dogmaphobic committed
49

50
    QGCMapPalette { id: mapPal; lightColors: useLightColors }
51
    QGCPalette    { id: qgcPal }
52

53
    function getPreferredInstrumentWidth() {
54
        if(ScreenTools.isMobile) {
55
            return ScreenTools.isTinyScreen ? mainWindow.width * 0.2 : mainWindow.width * 0.15
56 57 58 59 60
        }
        var w = mainWindow.width * 0.15
        return Math.min(w, 200)
    }

61
    function _setInstrumentWidget() {
62 63 64 65 66 67 68 69 70 71 72 73 74 75
        if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
            instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source
            switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) {
            case CustomInstrumentWidget.POS_TOP_RIGHT:
                instrumentsLoader.state  = "topMode"
                break;
            case CustomInstrumentWidget.POS_BOTTOM_RIGHT:
                instrumentsLoader.state  = "bottomMode"
                break;
            case CustomInstrumentWidget.POS_CENTER_RIGHT:
            default:
                instrumentsLoader.state  = "centerMode"
                break;
            }
76
        } else {
77
            var useAlternateInstruments = QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen
78 79 80 81 82
            if(useAlternateInstruments) {
                instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
                instrumentsLoader.state  = "topMode"
            } else {
                instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml"
83
                instrumentsLoader.state  = QGroundControl.settingsManager.appSettings.showLargeCompass.value == 1 ? "centerMode" : "topMode"
84
            }
85 86 87 88
        }
    }

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

93 94 95 96 97
    Connections {
        target:         QGroundControl.settingsManager.appSettings.showLargeCompass
        onValueChanged: _setInstrumentWidget()
    }

98 99 100 101 102
    Connections {
        target:                 missionController
        onResumeMissionReady:   _guidedModeBar.confirmAction(_guidedModeBar.confirmResumeMissionReady)
    }

103 104 105 106
    Component.onCompleted: {
        _setInstrumentWidget()
    }

Don Gagne's avatar
Don Gagne committed
107
    //-- Map warnings
108
    Column {
Don Gagne's avatar
Don Gagne committed
109 110 111 112 113 114
        anchors.horizontalCenter:   parent.horizontalCenter
        anchors.verticalCenter:     parent.verticalCenter
        spacing:                    ScreenTools.defaultFontPixelHeight

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
115
            visible:                    _activeVehicle && !_activeVehicle.coordinateValid && _mainIsMap
Don Gagne's avatar
Don Gagne committed
116 117
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
118
            font.pointSize:             ScreenTools.largeFontPointSize
119
            text:                       qsTr("No GPS Lock for Vehicle")
Don Gagne's avatar
Don Gagne committed
120 121 122 123
        }

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
124
            visible:                    _activeVehicle && _activeVehicle.prearmError
Don Gagne's avatar
Don Gagne committed
125 126
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
127
            font.pointSize:             ScreenTools.largeFontPointSize
Don Gagne's avatar
Don Gagne committed
128
            text:                       _activeVehicle ? _activeVehicle.prearmError : ""
129 130 131
        }
    }

dogmaphobic's avatar
dogmaphobic committed
132
    //-- Instrument Panel
133 134
    Loader {
        id:                     instrumentsLoader
135
        anchors.margins:        ScreenTools.defaultFontPixelHeight / 2
Don Gagne's avatar
Don Gagne committed
136
        anchors.right:          altitudeSlider.visible ? altitudeSlider.left : parent.right
137
        z:                      QGroundControl.zOrderWidgets
138 139 140 141 142 143 144 145
        property var  qgcView:  _root.qgcView
        property real maxHeight:parent.height - (anchors.margins * 2)
        states: [
            State {
                name:   "topMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.verticalCenter: undefined
146
                    anchors.bottom:         undefined
147 148 149 150 151 152 153 154
                    anchors.top:            _root ? _root.top : undefined
                }
            },
            State {
                name:   "centerMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
155
                    anchors.bottom:         undefined
156 157
                    anchors.verticalCenter: _root ? _root.verticalCenter : undefined
                }
158 159 160 161 162 163 164 165 166
            },
            State {
                name:   "bottomMode"
                AnchorChanges {
                    target:                 instrumentsLoader
                    anchors.top:            undefined
                    anchors.verticalCenter: undefined
                    anchors.bottom:         _root ? _root.bottom : undefined
                }
167 168
            }
        ]
169 170
    }

Don Gagne's avatar
Don Gagne committed
171 172 173
    //-- Guided mode buttons
    Rectangle {
        id:                         _guidedModeBar
Don Gagne's avatar
Don Gagne committed
174
        anchors.margins:            _barMargin
Don Gagne's avatar
Don Gagne committed
175 176
        anchors.bottom:             parent.bottom
        anchors.horizontalCenter:   parent.horizontalCenter
177 178
        width:                      (guidedModeButtons.visible ?  guidedModeButtons.width : guidedModeConfirm.width) + (_margins * 2)
        height:                     (guidedModeButtons.visible ?  guidedModeButtons.height : guidedModeConfirm.height) + (_margins * 2)
179
        radius:                     ScreenTools.defaultFontPixelHeight * 0.25
180
        color:                      _backgroundColor
Don Gagne's avatar
Don Gagne committed
181 182
        visible:                    _activeVehicle
        z:                          QGroundControl.zOrderWidgets
Don Gagne's avatar
Don Gagne committed
183

184 185 186
        property real   _fontPointSize:     ScreenTools.isMobile ? ScreenTools.largeFontPointSize : ScreenTools.defaultFontPointSize
        property color  _backgroundColor:   _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
        property color  _textColor:         _isSatellite ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight
Don Gagne's avatar
Don Gagne committed
187

188 189 190 191 192 193 194 195 196 197 198 199
        property string _emergencyStopTitle:    qsTr("Emergency Stop")
        property string _armTitle:              qsTr("Arm")
        property string _disarmTitle:           qsTr("Disarm")
        property string _rtlTitle:              qsTr("RTL")
        property string _takeoffTitle:          qsTr("Takeoff")
        property string _landTitle:             qsTr("Land")
        property string _startMissionTitle:     qsTr("Start Mission")
        property string _resumeMissionTitle:    qsTr("Resume Mission")
        property string _pauseTitle:            _missionActive ? qsTr("Pause Mission") : qsTr("Pause")
        property string _changeAltTitle:        qsTr("Change Altitude")
        property string _orbitTitle:            qsTr("Orbit")
        property string _abortTitle:            qsTr("Abort")
Don Gagne's avatar
Don Gagne committed
200

Don Gagne's avatar
Don Gagne committed
201

202 203 204 205 206 207 208 209 210 211 212 213 214 215
        readonly property int confirmHome:                  1
        readonly property int confirmLand:                  2
        readonly property int confirmTakeoff:               3
        readonly property int confirmArm:                   4
        readonly property int confirmDisarm:                5
        readonly property int confirmEmergencyStop:         6
        readonly property int confirmChangeAlt:             7
        readonly property int confirmGoTo:                  8
        readonly property int confirmRetask:                9
        readonly property int confirmOrbit:                 10
        readonly property int confirmAbort:                 11
        readonly property int confirmStartMission:          12
        readonly property int confirmResumeMission:         13
        readonly property int confirmResumeMissionReady:    14
Don Gagne's avatar
Don Gagne committed
216 217

        property int    confirmActionCode
Don Gagne's avatar
Don Gagne committed
218 219 220
        property real   _showMargin:    _margins
        property real   _hideMargin:    _margins - _guidedModeBar.height
        property real   _barMargin:     _showMargin
Don Gagne's avatar
Don Gagne committed
221 222 223 224 225 226 227 228 229 230

        function actionConfirmed() {
            switch (confirmActionCode) {
            case confirmHome:
                _activeVehicle.guidedModeRTL()
                break;
            case confirmLand:
                _activeVehicle.guidedModeLand()
                break;
            case confirmTakeoff:
231 232 233
                _activeVehicle.guidedModeTakeoff()
                break;
            case confirmResumeMission:
234 235 236 237 238
                missionController.resumeMission(missionController.resumeMissionItem)
                break;
            case confirmResumeMissionReady:
                _activeVehicle.startMission()
                break;
239 240
            case confirmStartMission:
                _activeVehicle.startMission()
Don Gagne's avatar
Don Gagne committed
241 242 243 244 245 246 247 248 249 250 251
                break;
            case confirmArm:
                _activeVehicle.armed = true
                break;
            case confirmDisarm:
                _activeVehicle.armed = false
                break;
            case confirmEmergencyStop:
                _activeVehicle.emergencyStop()
                break;
            case confirmChangeAlt:
252
                _activeVehicle.guidedModeChangeAltitude(altitudeSlider.getValue())
Don Gagne's avatar
Don Gagne committed
253 254 255 256
                break;
            case confirmGoTo:
                _activeVehicle.guidedModeGotoLocation(_flightMap._gotoHereCoordinate)
                break;
257 258 259
            case confirmRetask:
                _activeVehicle.setCurrentMissionSequence(_flightMap._retaskSequence)
                break;
260 261 262 263 264 265
            case confirmOrbit:
                //-- All parameters controlled by RC
                _activeVehicle.guidedModeOrbit()
                //-- Center on current flight map position and orbit with a 50m radius (velocity/direction controlled by the RC)
                //_activeVehicle.guidedModeOrbit(QGroundControl.flightMapPosition, 50.0)
                break;
266
            case confirmAbort:
267
                _activeVehicle.abortLanding(50)     // hardcoded value for climbOutAltitude that is currently ignored
268
                break;
Don Gagne's avatar
Don Gagne committed
269
            default:
270
                console.warn(qsTr("Internal error: unknown confirmActionCode"), confirmActionCode)
Don Gagne's avatar
Don Gagne committed
271 272 273
            }
        }

274
        function rejectGuidedModeConfirm() {
275
            guidedModeButtons.visible = true
276 277 278 279 280
            guidedModeConfirm.visible = false
            altitudeSlider.visible = false
            _flightMap._gotoHereCoordinate = QtPositioning.coordinate()
        }

Don Gagne's avatar
Don Gagne committed
281 282 283 284
        function confirmAction(actionCode) {
            confirmActionCode = actionCode
            switch (confirmActionCode) {
            case confirmArm:
285 286
                guidedModeConfirm.title = _armTitle
                guidedModeConfirm.message = qsTr("arm")
Don Gagne's avatar
Don Gagne committed
287 288
                break;
            case confirmDisarm:
289 290
                guidedModeConfirm.title = _disarmTitle
                guidedModeConfirm.message = qsTr("disarm")
Don Gagne's avatar
Don Gagne committed
291 292
                break;
            case confirmEmergencyStop:
293 294
                guidedModeConfirm.title = _emergencyStopTitle
                guidedModeConfirm.message = qsTr("WARNING: This still stop all motors. If vehicle is currently in air it will crash.")
Don Gagne's avatar
Don Gagne committed
295 296
                break;
            case confirmTakeoff:
297 298
                guidedModeConfirm.title = _takeoffTitle
                guidedModeConfirm.message = qsTr("Takeoff from ground and hold position.")
Don Gagne's avatar
Don Gagne committed
299
                break;
300
            case confirmStartMission:
301 302
                guidedModeConfirm.title = _startMissionTitle
                guidedModeConfirm.message = qsTr("Start the mission which is currently displayed above. If the vehicle is on the ground it will takeoff.")
303 304
                break;
            case confirmResumeMission:
305 306
                guidedModeConfirm.title = _resumeMissionTitle
                guidedModeConfirm.message = qsTr("Resume the mission which is displayed above. This will re-generate the mission from waypoint %1, takeoff and continue the mission.").arg(_resumeMissionItem)
307
                break;
308
            case confirmResumeMissionReady:
309 310
                guidedModeConfirm.title = _resumeMissionTitle
                guidedModeConfirm.message = qsTr("Review the modified mission above. Confirm if you want to takeoff and begin mission.")
311
                break;
Don Gagne's avatar
Don Gagne committed
312
            case confirmLand:
313 314
                guidedModeConfirm.title = _landTitle
                guidedModeConfirm.message = qsTr("Land the vehicle at the current position.")
Don Gagne's avatar
Don Gagne committed
315
                break;
Don Gagne's avatar
Don Gagne committed
316
            case confirmHome:
317 318
                guidedModeConfirm.title = _rtlTitle
                guidedModeConfirm.message = qsTr("Return to the home position of the vehicle.")
Don Gagne's avatar
Don Gagne committed
319
                break;
Don Gagne's avatar
Don Gagne committed
320 321
            case confirmChangeAlt:
                altitudeSlider.visible = true
322 323 324
                altitudeSlider.setValue(0)
                guidedModeConfirm.title = _changeAltTitle
                guidedModeConfirm.message = qsTr("Adjust the slider to the left up or down to change the altitude of the vehicle.")
Don Gagne's avatar
Don Gagne committed
325 326
                break;
            case confirmGoTo:
327 328
                guidedModeConfirm.title = qsTr("Go To Location")
                guidedModeConfirm.message = qsTr("Confirm to move to the new location.")
Don Gagne's avatar
Don Gagne committed
329
                break;
330
            case confirmRetask:
331 332
                guidedModeConfirm.title = qsTr("Waypoint Change")
                guidedModeConfirm.message = qsTr("Confirm to change current mission item to %1.").arg(_flightMap._retaskSequence)
333
                break;
334
            case confirmOrbit:
335 336
                guidedModeConfirm.title = _orbitTitle
                guidedModeConfirm.message = qsTr("Confirm to enter Orbit mode.")
337
                break;
338
            case confirmAbort:
339 340
                guidedModeConfirm.title = _abortTitle
                guidedModeConfirm.message = qsTr("Confirm to abort the current landing.")
341
                break;
Don Gagne's avatar
Don Gagne committed
342
            }
343
            guidedModeButtons.visible = false
Don Gagne's avatar
Don Gagne committed
344 345 346
            guidedModeConfirm.visible = true
        }

347 348
        ColumnLayout {
            id:                 guidedModeButtons
Don Gagne's avatar
Don Gagne committed
349 350 351 352 353
            anchors.margins:    _margins
            anchors.top:        parent.top
            anchors.left:       parent.left
            spacing:            _margins

354
            QGCLabel {
355 356 357 358
                anchors.horizontalCenter:   parent.horizontalCenter
                color:                      _guidedModeBar._textColor
                text:                       qsTr("Click in map to move vehicle")
                visible:                    gotoEnabled
359 360
            }

Don Gagne's avatar
Don Gagne committed
361
            Row {
362
                spacing:    _margins * 2
Don Gagne's avatar
Don Gagne committed
363 364

                QGCButton {
365
                    pointSize:  _guidedModeBar._fontPointSize
366
                    text:       _guidedModeBar._emergencyStopTitle
367 368 369 370 371 372
                    visible:    _showEmergenyStop && _activeVehicle && _activeVehicle.armed && _activeVehicle.flying
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmEmergencyStop)
                }

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
373
                    text:       _guidedModeBar._disarmTitle
374 375
                    visible:    _activeVehicle && _activeVehicle.armed && !_activeVehicle.flying
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmDisarm)
376
                }
Don Gagne's avatar
Don Gagne committed
377

Don Gagne's avatar
Don Gagne committed
378
                QGCButton {
379
                    pointSize:  _guidedModeBar._fontPointSize
380 381
                    text:       _guidedModeBar._rtlTitle
                    visible:    _activeVehicle && _activeVehicle.armed && _activeVehicle.guidedModeSupported && _activeVehicle.flying && !_vehicleInRTLMode
Don Gagne's avatar
Don Gagne committed
382
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmHome)
383
                }
Don Gagne's avatar
Don Gagne committed
384

Don Gagne's avatar
Don Gagne committed
385
                QGCButton {
386
                    pointSize:  _guidedModeBar._fontPointSize
387
                    text:       _guidedModeBar._takeoffTitle
388 389 390 391 392 393
                    visible:    _activeVehicle && _activeVehicle.guidedModeSupported && !_activeVehicle.flying  && !_activeVehicle.fixedWing
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmTakeoff)
                }

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
394 395
                    text:       _guidedModeBar._landTitle
                    visible:    _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.armed && !_activeVehicle.fixedWing && !_vehicleInLandMode
396 397 398 399 400
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmLand)
                }

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
401 402
                    text:       _guidedModeBar._startMissionTitle
                    visible:    _activeVehicle && _missionAvailable && !_missionActive
403 404 405 406 407
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmStartMission)
                }

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
408
                    text:       _guidedModeBar._resumeMissionTitle
409
                    visible:    _activeVehicle && !_activeVehicle.flying && _missionAvailable && _resumeMissionItem !== -1
410
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmResumeMission)
411
                }
Don Gagne's avatar
Don Gagne committed
412

Don Gagne's avatar
Don Gagne committed
413
                QGCButton {
414
                    pointSize:  _guidedModeBar._fontPointSize
415 416
                    text:       _guidedModeBar._pauseTitle
                    visible:    _activeVehicle && _activeVehicle.armed && _activeVehicle.pauseVehicleSupported && _activeVehicle.flying && !_vehiclePaused
417
                    onClicked:  _activeVehicle.pauseVehicle()
418
                }
Don Gagne's avatar
Don Gagne committed
419

Don Gagne's avatar
Don Gagne committed
420
                QGCButton {
421
                    pointSize:  _guidedModeBar._fontPointSize
422
                    text:       _guidedModeBar._changeAltTitle
423
                    visible:    (_activeVehicle && _activeVehicle.flying) && _activeVehicle.guidedModeSupported && _activeVehicle.armed && !_missionActive
Don Gagne's avatar
Don Gagne committed
424
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmChangeAlt)
425
                }
426 427 428

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
429
                    text:       _guidedModeBar._orbitTitle
430
                    visible:    _showOrbit && _activeVehicle && _activeVehicle.flying && _activeVehicle.orbitModeSupported && _activeVehicle.armed && !_missionActive
431 432 433
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmOrbit)
                }

434 435
                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
436
                    text:       _guidedModeBar._abortTitle
437
                    visible:    _activeVehicle && _activeVehicle.flying && _activeVehicle.fixedWing
438 439
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmAbort)
                }
440 441
            }
        }
442

443 444 445 446 447 448 449
        Column {
            id:                 guidedModeConfirm
            anchors.margins:    _margins
            anchors.top:        parent.top
            anchors.left:       parent.left
            spacing:            _margins
            visible:            false
450

451 452
            property alias title:   titleText.text
            property alias message: messageText.text
453

454 455 456 457 458 459 460
            QGCLabel {
                id:                 titleText
                anchors.left:           slider.left
                anchors.right:          slider.right
                color:                  _guidedModeBar._textColor
                horizontalAlignment:    Text.AlignHCenter
            }
461

462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
            QGCLabel {
                id:                     messageText
                anchors.left:           slider.left
                anchors.right:          slider.right
                color:                  _guidedModeBar._textColor
                horizontalAlignment:    Text.AlignHCenter
                wrapMode:               Text.WordWrap
            }

            // Action confirmation control
            SliderSwitch {
                id:             slider
                fontPointSize:  _guidedModeBar._fontPointSize
                confirmText:    qsTr("Slide to confirm")
                width:          Math.max(implicitWidth, ScreenTools.defaultFontPixelWidth * 30)

                onAccept: {
                    guidedModeButtons.visible = true
                    guidedModeConfirm.visible = false
                    altitudeSlider.visible = false
                    _guidedModeBar.actionConfirmed()
                }

                onReject: _guidedModeBar.rejectGuidedModeConfirm()
            }
Don Gagne's avatar
Don Gagne committed
487
        }
488

489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
        QGCColoredImage {
            anchors.margins:    _margins
            anchors.top:        _guidedModeBar.top
            anchors.right:      _guidedModeBar.right
            width:              ScreenTools.defaultFontPixelHeight
            height:             width
            sourceSize.height:  width
            source:             "/res/XDelete.svg"
            fillMode:           Image.PreserveAspectFit
            color:              qgcPal.alertText
            visible:            guidedModeConfirm.visible

            QGCMouseArea {
                fillItem:   parent
                onClicked:  _guidedModeBar.rejectGuidedModeConfirm()
            }
        }

    } // Rectangle - Guided mode buttons
Don Gagne's avatar
Don Gagne committed
508 509 510 511 512 513 514 515

    //-- Altitude slider
    Rectangle {
        id:                 altitudeSlider
        anchors.margins:    _margins
        anchors.right:      parent.right
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
516
        radius:             ScreenTools.defaultFontPixelWidth / 2
Don Gagne's avatar
Don Gagne committed
517
        width:              ScreenTools.defaultFontPixelWidth * 10
518
        color:              qgcPal.window
Don Gagne's avatar
Don Gagne committed
519 520
        visible:            false

521 522
        function setValue(value) {
            altSlider.value = value
523 524
        }

Don Gagne's avatar
Don Gagne committed
525
        function getValue() {
526
            return altSlider.value
Don Gagne's avatar
Don Gagne committed
527 528 529 530 531 532 533 534 535 536
        }

        Column {
            id:                 headerColumn
            anchors.margins:    _margins
            anchors.top:        parent.top
            anchors.left:       parent.left
            anchors.right:      parent.right

            QGCLabel {
537 538
                anchors.horizontalCenter:   parent.horizontalCenter
                text:                       altSlider.value >=0 ? qsTr("Up") : qsTr("Down")
Don Gagne's avatar
Don Gagne committed
539 540 541
            }

            QGCLabel {
542 543 544
                id:                         altField
                anchors.horizontalCenter:   parent.horizontalCenter
                text:                       Math.abs(altSlider.value.toFixed(1)) + " " + QGroundControl.appSettingsDistanceUnitsString
Don Gagne's avatar
Don Gagne committed
545 546 547
            }
        }

548
        QGCSlider {
Don Gagne's avatar
Don Gagne committed
549 550 551 552 553 554 555
            id:                 altSlider
            anchors.margins:    _margins
            anchors.top:        headerColumn.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            orientation:        Qt.Vertical
556 557 558 559 560 561 562 563 564 565 566 567 568
            //minimumValue:       QGroundControl.metersToAppSettingsDistanceUnits(0)
            //maximumValue:       QGroundControl.metersToAppSettingsDistanceUnits((_activeVehicle && _activeVehicle.flying) ? Math.round((_activeVehicle.altitudeRelative.value + 100) / 100) * 100 : 10)
            minimumValue:       QGroundControl.metersToAppSettingsDistanceUnits(-10)
            maximumValue:       QGroundControl.metersToAppSettingsDistanceUnits(10)
            indicatorCentered:  true
            rotation:           180

            // We want slide up to be positive values
            transform: Rotation {
                origin.x:   altSlider.width / 2
                origin.y:   altSlider.height / 2
                angle:      180
            }
Don Gagne's avatar
Don Gagne committed
569 570
        }
    }
571
}