FlightDisplayViewWidgets.qml 25.1 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 12 13 14 15 16 17 18 19 20 21 22 23 24 25


import QtQuick                  2.4
import QtQuick.Controls         1.3
import QtQuick.Controls.Styles  1.2
import QtQuick.Dialogs          1.2
import QtLocation               5.3
import QtPositioning            5.2

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

Item {
26
    id: _root
27

28 29
    property alias  guidedModeBar:  _guidedModeBar
    property bool   gotoEnabled:    _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
Don Gagne's avatar
Don Gagne committed
30

31 32
    property var    _activeVehicle:             QGroundControl.multiVehicleManager.activeVehicle
    property bool   _isSatellite:               _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
33
    property bool   _lightWidgetBorders:        _isSatellite
34 35
    property bool   _useAlternateInstruments:   QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen

36 37
    readonly property real _margins:                ScreenTools.defaultFontPixelHeight / 2
    readonly property real _toolButtonTopMargin:    parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2)
dogmaphobic's avatar
dogmaphobic committed
38

39
    QGCMapPalette { id: mapPal; lightColors: isBackgroundDark }
40
    QGCPalette { id: qgcPal }
41

42 43
    function getGadgetWidth() {
        if(ScreenTools.isMobile) {
44
            return ScreenTools.isTinyScreen ? mainWindow.width * 0.2 : mainWindow.width * 0.15
45 46 47 48 49
        }
        var w = mainWindow.width * 0.15
        return Math.min(w, 200)
    }

50 51 52 53
    ExclusiveGroup {
        id: _dropButtonsExclusiveGroup
    }

Don Gagne's avatar
Don Gagne committed
54 55 56 57
    ExclusiveGroup {
        id: _mapTypeButtonsExclusiveGroup
    }

Don Gagne's avatar
Don Gagne committed
58
    //-- Map warnings
59
    Column {
Don Gagne's avatar
Don Gagne committed
60 61 62 63 64 65
        anchors.horizontalCenter:   parent.horizontalCenter
        anchors.verticalCenter:     parent.verticalCenter
        spacing:                    ScreenTools.defaultFontPixelHeight

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
66
            visible:                    _activeVehicle && !_activeVehicle.coordinateValid && _mainIsMap
Don Gagne's avatar
Don Gagne committed
67 68
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
69
            font.pointSize:             ScreenTools.largeFontPointSize
70
            text:                       qsTr("No GPS Lock for Vehicle")
Don Gagne's avatar
Don Gagne committed
71 72 73 74
        }

        QGCLabel {
            anchors.horizontalCenter:   parent.horizontalCenter
75
            visible:                    _activeVehicle && _activeVehicle.prearmError
Don Gagne's avatar
Don Gagne committed
76 77
            z:                          QGroundControl.zOrderTopMost
            color:                      mapPal.text
78
            font.pointSize:             ScreenTools.largeFontPointSize
Don Gagne's avatar
Don Gagne committed
79
            text:                       _activeVehicle ? _activeVehicle.prearmError : ""
80 81 82 83 84 85 86 87 88 89 90 91 92 93
        }
    }

    //-- Dismiss Drop Down (if any)
    MouseArea {
        anchors.fill:   parent
        enabled:        _dropButtonsExclusiveGroup.current != null
        onClicked: {
            if(_dropButtonsExclusiveGroup.current)
                _dropButtonsExclusiveGroup.current.checked = false
            _dropButtonsExclusiveGroup.current = null
        }
    }

dogmaphobic's avatar
dogmaphobic committed
94
    //-- Instrument Panel
95
    QGCInstrumentWidget {
96
        id:                     instrumentGadget
97
        anchors.margins:        ScreenTools.defaultFontPixelHeight / 2
Don Gagne's avatar
Don Gagne committed
98
        anchors.right:          altitudeSlider.visible ? altitudeSlider.left : parent.right
99
        anchors.verticalCenter: parent.verticalCenter
100
        visible:                !_useAlternateInstruments
101
        size:                   getGadgetWidth()
102 103 104 105
        active:                 _activeVehicle != null
        heading:                _heading
        rollAngle:              _roll
        pitchAngle:             _pitch
Don Gagne's avatar
Don Gagne committed
106 107
        groundSpeedFact:        _groundSpeedFact
        airSpeedFact:           _airSpeedFact
108
        lightBorders:           _lightWidgetBorders
109
        z:                      QGroundControl.zOrderWidgets
110
        qgcView:                parent.parent.qgcView
111
        maxHeight:              parent.height - (anchors.margins * 2)
dogmaphobic's avatar
dogmaphobic committed
112 113
    }

114 115
    QGCInstrumentWidgetAlternate {
        id:                     instrumentGadgetAlternate
116
        anchors.margins:        ScreenTools.defaultFontPixelHeight / 2
117
        anchors.top:            parent.top
Don Gagne's avatar
Don Gagne committed
118
        anchors.right:          altitudeSlider.visible ? altitudeSlider.left : parent.right
119 120
        visible:                _useAlternateInstruments
        width:                  ScreenTools.isTinyScreen ? getGadgetWidth() * 1.5 : getGadgetWidth()
121 122 123 124 125 126 127 128 129 130 131
        active:                 _activeVehicle != null
        heading:                _heading
        rollAngle:              _roll
        pitchAngle:             _pitch
        groundSpeedFact:        _groundSpeedFact
        airSpeedFact:           _airSpeedFact
        isSatellite:            _isSatellite
        z:                      QGroundControl.zOrderWidgets
    }

    ValuesWidget {
132 133 134 135 136 137 138 139
        anchors.topMargin:          ScreenTools.defaultFontPixelHeight
        anchors.top:                instrumentGadgetAlternate.bottom
        anchors.horizontalCenter:   instrumentGadgetAlternate.horizontalCenter
        width:                      getGadgetWidth()
        qgcView:                    parent.parent.qgcView
        textColor:                  _isSatellite ? "white" : "black"
        visible:                    _useAlternateInstruments
        maxHeight:                  virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.y - y : parent.height - anchors.margins - y
dogmaphobic's avatar
dogmaphobic committed
140 141
    }

142
    QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
143 144 145 146
        id:                         flyLabel
        text:                       qsTr("Fly")
        color:                      mapPal.text
        visible:                    !ScreenTools.isShortScreen && _mainIsMap
147 148 149 150 151
        anchors.topMargin:          _toolButtonTopMargin
        anchors.horizontalCenter:   toolColumn.horizontalCenter
        anchors.top:                parent.top
    }

152 153
    //-- Vertical Tool Buttons
    Column {
154 155 156 157 158 159 160
        id:                 toolColumn
        anchors.topMargin:  ScreenTools.isShortScreen ? _toolButtonTopMargin : ScreenTools.defaultFontPixelHeight / 2
        anchors.leftMargin: ScreenTools.defaultFontPixelHeight
        anchors.left:       parent.left
        anchors.top:        ScreenTools.isShortScreen ? parent.top : flyLabel.bottom
        spacing:            ScreenTools.defaultFontPixelHeight
        visible:            _mainIsMap
161 162 163

        //-- Map Center Control
        DropButton {
164 165 166 167 168 169 170
            id:                 centerMapDropButton
            dropDirection:      dropRight
            buttonImage:        "/qmlimages/MapCenter.svg"
            viewportMargins:    ScreenTools.defaultFontPixelWidth / 2
            exclusiveGroup:     _dropButtonsExclusiveGroup
            z:                  QGroundControl.zOrderWidgets
            lightBorders:       _lightWidgetBorders
171 172 173 174 175 176

            dropDownComponent: Component {
                Row {
                    spacing: ScreenTools.defaultFontPixelWidth

                    QGCCheckBox {
Don Gagne's avatar
Don Gagne committed
177 178 179 180 181
                        id:         followVehicleCheckBox
                        text:       qsTr("Follow Vehicle")
                        checked:    _flightMap ? _flightMap._followVehicle : false
                        anchors.verticalCenter: parent.verticalCenter
                        //anchors.baseline:   centerMapButton.baseline - This doesn't work correctly on mobile for some strange reason, so we center instead
182 183 184 185 186 187 188 189 190

                        onClicked: {
                            _dropButtonsExclusiveGroup.current = null
                            _flightMap._followVehicle = !_flightMap._followVehicle
                        }
                    }

                    QGCButton {
                        id:         centerMapButton
191
                        text:       qsTr("Center map on Vehicle")
192 193
                        enabled:    _activeVehicle && !followVehicleCheckBox.checked

194
                        property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
195 196 197

                        onClicked: {
                            _dropButtonsExclusiveGroup.current = null
198
                            _flightMap.center = activeVehicle.coordinate
199 200 201 202 203 204 205 206
                        }
                    }
                }
            }
        }

        //-- Map Type Control
        DropButton {
207 208 209 210 211 212 213
            id:                 mapTypeButton
            dropDirection:      dropRight
            buttonImage:        "/qmlimages/MapType.svg"
            viewportMargins:    ScreenTools.defaultFontPixelWidth / 2
            exclusiveGroup:     _dropButtonsExclusiveGroup
            z:                  QGroundControl.zOrderWidgets
            lightBorders:       _lightWidgetBorders
214 215

            dropDownComponent: Component {
Don Gagne's avatar
Don Gagne committed
216
                Column {
217 218
                    spacing: ScreenTools.defaultFontPixelWidth

Don Gagne's avatar
Don Gagne committed
219 220 221 222 223
                    Row {
                        spacing: ScreenTools.defaultFontPixelWidth

                        Repeater {
                            model: QGroundControl.flightMapSettings.mapTypes
224

Don Gagne's avatar
Don Gagne committed
225
                            QGCButton {
Don Gagne's avatar
Don Gagne committed
226
                                checkable:      true
227 228
                                checked:        QGroundControl.flightMapSettings.mapType === text
                                text:           modelData
Don Gagne's avatar
Don Gagne committed
229 230
                                width:          clearButton.width
                                exclusiveGroup: _mapTypeButtonsExclusiveGroup
231

Don Gagne's avatar
Don Gagne committed
232
                                onClicked: {
233
                                    QGroundControl.flightMapSettings.mapType = text
Don Gagne's avatar
Don Gagne committed
234
                                    checked = true
Don Gagne's avatar
Don Gagne committed
235 236
                                    _dropButtonsExclusiveGroup.current = null
                                }
237 238 239
                            }
                        }
                    }
Don Gagne's avatar
Don Gagne committed
240 241

                    QGCButton {
dogmaphobic's avatar
dogmaphobic committed
242 243
                        id:         clearButton
                        text:       qsTr("Clear Flight Trails")
Don Gagne's avatar
Don Gagne committed
244 245 246 247 248 249
                        enabled:    QGroundControl.multiVehicleManager.activeVehicle
                        onClicked: {
                            QGroundControl.multiVehicleManager.activeVehicle.clearTrajectoryPoints()
                            _dropButtonsExclusiveGroup.current = null
                        }
                    }
250 251 252 253 254 255 256
                }
            }
        }

        //-- Zoom Map In
        RoundButton {
            id:                 mapZoomPlus
257
            visible:            !ScreenTools.isTinyScreen && _mainIsMap
258 259 260
            buttonImage:        "/qmlimages/ZoomPlus.svg"
            exclusiveGroup:     _dropButtonsExclusiveGroup
            z:                  QGroundControl.zOrderWidgets
261
            lightBorders:       _lightWidgetBorders
262 263 264 265 266 267 268 269 270 271
            onClicked: {
                if(_flightMap)
                    _flightMap.zoomLevel += 0.5
                checked = false
            }
        }

        //-- Zoom Map Out
        RoundButton {
            id:                 mapZoomMinus
272
            visible:            !ScreenTools.isTinyScreen && _mainIsMap
273 274 275
            buttonImage:        "/qmlimages/ZoomMinus.svg"
            exclusiveGroup:     _dropButtonsExclusiveGroup
            z:                  QGroundControl.zOrderWidgets
276
            lightBorders:       _lightWidgetBorders
277 278 279 280 281 282 283 284
            onClicked: {
                if(_flightMap)
                    _flightMap.zoomLevel -= 0.5
                checked = false
            }
        }
    }

Don Gagne's avatar
Don Gagne committed
285 286 287
    //-- Guided mode buttons
    Rectangle {
        id:                         _guidedModeBar
Don Gagne's avatar
Don Gagne committed
288
        anchors.margins:            _barMargin
Don Gagne's avatar
Don Gagne committed
289 290
        anchors.bottom:             parent.bottom
        anchors.horizontalCenter:   parent.horizontalCenter
291
        width:                      guidedModeColumn.width  + (_margins * 2)
Don Gagne's avatar
Don Gagne committed
292
        height:                     guidedModeColumn.height + (_margins * 2)
293 294
        radius:                     ScreenTools.defaultFontPixelHeight * 0.25
        color:                      _lightWidgetBorders ? Qt.rgba(qgcPal.mapWidgetBorderLight.r, qgcPal.mapWidgetBorderLight.g, qgcPal.mapWidgetBorderLight.b, 0.8) : Qt.rgba(qgcPal.mapWidgetBorderDark.r, qgcPal.mapWidgetBorderDark.g, qgcPal.mapWidgetBorderDark.b, 0.75)
Don Gagne's avatar
Don Gagne committed
295 296
        visible:                    _activeVehicle
        z:                          QGroundControl.zOrderWidgets
Don Gagne's avatar
Don Gagne committed
297 298
        state:                      "Shown"

299 300
        property real _fontPointSize: ScreenTools.isMobile ? ScreenTools.largeFontPointSize : ScreenTools.defaultFontPointSize

Don Gagne's avatar
Don Gagne committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
        states: [
            State {
                name: "Shown"
                PropertyChanges { target: showAnimation; running: true  }
                PropertyChanges { target: guidedModeHideTimer; running: true }
            },
            State {
                name: "Hidden"
                PropertyChanges { target: hideAnimation; running: true  }
            }
        ]

        PropertyAnimation {
            id:             hideAnimation
            target:         _guidedModeBar
            property:       "_barMargin"
            duration:       1000
            easing.type:    Easing.InOutQuad
            from:           _guidedModeBar._showMargin
            to:             _guidedModeBar._hideMargin
        }

        PropertyAnimation {
            id:             showAnimation
            target:         _guidedModeBar
            property:       "_barMargin"
            duration:       250
            easing.type:    Easing.InOutQuad
            from:           _guidedModeBar._hideMargin
            to:             _guidedModeBar._showMargin
        }

        Timer {
            id:             guidedModeHideTimer
            interval:       7000
            running:        true
337 338 339 340 341
            onTriggered: {
                if (ScreenTools.isShortScreen) {
                    _guidedModeBar.state = "Hidden"
                }
            }
Don Gagne's avatar
Don Gagne committed
342
        }
Don Gagne's avatar
Don Gagne committed
343 344 345 346 347 348 349 350 351

        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
352
        readonly property int confirmRetask:        9
353
        readonly property int confirmOrbit:         10
Don Gagne's avatar
Don Gagne committed
354 355

        property int    confirmActionCode
Don Gagne's avatar
Don Gagne committed
356 357 358
        property real   _showMargin:    _margins
        property real   _hideMargin:    _margins - _guidedModeBar.height
        property real   _barMargin:     _showMargin
Don Gagne's avatar
Don Gagne committed
359 360 361 362 363 364 365 366 367 368

        function actionConfirmed() {
            switch (confirmActionCode) {
            case confirmHome:
                _activeVehicle.guidedModeRTL()
                break;
            case confirmLand:
                _activeVehicle.guidedModeLand()
                break;
            case confirmTakeoff:
369 370 371
                var altitude1 = altitudeSlider.getValue()
                if (!isNaN(altitude1)) {
                    _activeVehicle.guidedModeTakeoff(altitude1)
Don Gagne's avatar
Don Gagne committed
372 373 374 375 376 377 378 379 380 381 382 383
                }
                break;
            case confirmArm:
                _activeVehicle.armed = true
                break;
            case confirmDisarm:
                _activeVehicle.armed = false
                break;
            case confirmEmergencyStop:
                _activeVehicle.emergencyStop()
                break;
            case confirmChangeAlt:
384 385 386
                var altitude2 = altitudeSlider.getValue()
                if (!isNaN(altitude2)) {
                    _activeVehicle.guidedModeChangeAltitude(altitude2)
Don Gagne's avatar
Don Gagne committed
387 388 389 390 391
                }
                break;
            case confirmGoTo:
                _activeVehicle.guidedModeGotoLocation(_flightMap._gotoHereCoordinate)
                break;
392 393 394
            case confirmRetask:
                _activeVehicle.setCurrentMissionSequence(_flightMap._retaskSequence)
                break;
395 396 397 398 399 400
            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;
Don Gagne's avatar
Don Gagne committed
401
            default:
402
                console.warn(qsTr("Internal error: unknown confirmActionCode"), confirmActionCode)
Don Gagne's avatar
Don Gagne committed
403 404 405
            }
        }

406 407
        function rejectGuidedModeConfirm() {
            guidedModeConfirm.visible = false
Don Gagne's avatar
Don Gagne committed
408
            _guidedModeBar.visible = true
409 410
            altitudeSlider.visible = false
            _flightMap._gotoHereCoordinate = QtPositioning.coordinate()
Don Gagne's avatar
Don Gagne committed
411
            guidedModeHideTimer.restart()
412 413
        }

Don Gagne's avatar
Don Gagne committed
414
        function confirmAction(actionCode) {
Don Gagne's avatar
Don Gagne committed
415
            guidedModeHideTimer.stop()
Don Gagne's avatar
Don Gagne committed
416 417 418
            confirmActionCode = actionCode
            switch (confirmActionCode) {
            case confirmArm:
419
                guidedModeConfirm.confirmText = qsTr("arm")
Don Gagne's avatar
Don Gagne committed
420 421
                break;
            case confirmDisarm:
422
                guidedModeConfirm.confirmText = qsTr("disarm")
Don Gagne's avatar
Don Gagne committed
423 424
                break;
            case confirmEmergencyStop:
425
                guidedModeConfirm.confirmText = qsTr("STOP ALL MOTORS!")
Don Gagne's avatar
Don Gagne committed
426 427 428
                break;
            case confirmTakeoff:
                altitudeSlider.visible = true
429
                altitudeSlider.setInitialValueMeters(3)
430
                guidedModeConfirm.confirmText = qsTr("takeoff")
Don Gagne's avatar
Don Gagne committed
431 432
                break;
            case confirmLand:
433
                guidedModeConfirm.confirmText = qsTr("land")
Don Gagne's avatar
Don Gagne committed
434
                break;
Don Gagne's avatar
Don Gagne committed
435
            case confirmHome:
436
                guidedModeConfirm.confirmText = qsTr("return to land")
Don Gagne's avatar
Don Gagne committed
437
                break;
Don Gagne's avatar
Don Gagne committed
438 439
            case confirmChangeAlt:
                altitudeSlider.visible = true
440
                altitudeSlider.setInitialValueAppSettingsDistanceUnits(_activeVehicle.altitudeAMSL.value)
441
                guidedModeConfirm.confirmText = qsTr("change altitude")
Don Gagne's avatar
Don Gagne committed
442 443
                break;
            case confirmGoTo:
444
                guidedModeConfirm.confirmText = qsTr("move vehicle")
Don Gagne's avatar
Don Gagne committed
445
                break;
446
            case confirmRetask:
447
                guidedModeConfirm.confirmText = qsTr("active waypoint change")
448
                break;
449 450 451
            case confirmOrbit:
                guidedModeConfirm.confirmText = qsTr("enter orbit mode")
                break;
Don Gagne's avatar
Don Gagne committed
452
            }
Don Gagne's avatar
Don Gagne committed
453
            _guidedModeBar.visible = false
Don Gagne's avatar
Don Gagne committed
454 455 456
            guidedModeConfirm.visible = true
        }

Don Gagne's avatar
Don Gagne committed
457 458
        Column {
            id:                 guidedModeColumn
Don Gagne's avatar
Don Gagne committed
459 460 461 462 463
            anchors.margins:    _margins
            anchors.top:        parent.top
            anchors.left:       parent.left
            spacing:            _margins

464 465
            QGCLabel {
                anchors.horizontalCenter: parent.horizontalCenter
Don Gagne's avatar
Don Gagne committed
466
                color:      _lightWidgetBorders ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight
467
                text:       "Click in map to move vehicle"
468
                visible:    gotoEnabled
469 470
            }

Don Gagne's avatar
Don Gagne committed
471
            Row {
Don Gagne's avatar
Don Gagne committed
472
                spacing: _margins * 2
Don Gagne's avatar
Don Gagne committed
473 474

                QGCButton {
475
                    pointSize:  _guidedModeBar._fontPointSize
476
                    text:       (_activeVehicle && _activeVehicle.armed) ? (_activeVehicle.flying ? qsTr("Emergency Stop") : qsTr("Disarm")) :  qsTr("Arm")
Don Gagne's avatar
Don Gagne committed
477
                    visible:    _activeVehicle
Don Gagne's avatar
Don Gagne committed
478
                    onClicked:  _guidedModeBar.confirmAction(_activeVehicle.armed ? (_activeVehicle.flying ? _guidedModeBar.confirmEmergencyStop : _guidedModeBar.confirmDisarm) : _guidedModeBar.confirmArm)
479
                }
Don Gagne's avatar
Don Gagne committed
480

Don Gagne's avatar
Don Gagne committed
481
                QGCButton {
482
                    pointSize:  _guidedModeBar._fontPointSize
483
                    text:       qsTr("RTL")
484
                    visible:    (_activeVehicle && _activeVehicle.armed) && _activeVehicle.guidedModeSupported && _activeVehicle.flying
Don Gagne's avatar
Don Gagne committed
485
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmHome)
486
                }
Don Gagne's avatar
Don Gagne committed
487

Don Gagne's avatar
Don Gagne committed
488
                QGCButton {
489
                    pointSize:  _guidedModeBar._fontPointSize
490
                    text:       (_activeVehicle && _activeVehicle.flying) ?  qsTr("Land"):  qsTr("Takeoff")
491
                    visible:    _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.armed
Don Gagne's avatar
Don Gagne committed
492
                    onClicked:  _guidedModeBar.confirmAction(_activeVehicle.flying ? _guidedModeBar.confirmLand : _guidedModeBar.confirmTakeoff)
493
                }
Don Gagne's avatar
Don Gagne committed
494

Don Gagne's avatar
Don Gagne committed
495
                QGCButton {
496
                    pointSize:  _guidedModeBar._fontPointSize
497
                    text:       qsTr("Pause")
498
                    visible:    (_activeVehicle && _activeVehicle.armed) && _activeVehicle.pauseVehicleSupported && _activeVehicle.flying
Don Gagne's avatar
Don Gagne committed
499 500
                    onClicked:  {
                        guidedModeHideTimer.restart()
501 502 503
                        _activeVehicle.pauseVehicle()
                    }
                }
Don Gagne's avatar
Don Gagne committed
504

Don Gagne's avatar
Don Gagne committed
505
                QGCButton {
506
                    pointSize:  _guidedModeBar._fontPointSize
507
                    text:       qsTr("Change Altitude")
508
                    visible:    (_activeVehicle && _activeVehicle.flying) && _activeVehicle.guidedModeSupported && _activeVehicle.armed
Don Gagne's avatar
Don Gagne committed
509
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmChangeAlt)
510
                }
511 512 513 514

                QGCButton {
                    pointSize:  _guidedModeBar._fontPointSize
                    text:       qsTr("Orbit")
515
                    visible:    (_activeVehicle && _activeVehicle.flying) && _activeVehicle.orbitModeSupported && _activeVehicle.armed
516 517 518
                    onClicked:  _guidedModeBar.confirmAction(_guidedModeBar.confirmOrbit)
                }

Don Gagne's avatar
Don Gagne committed
519 520
            } // Row
        } // Column
521 522
    } // Rectangle - Guided mode buttons

523
    MouseArea {
Don Gagne's avatar
Don Gagne committed
524 525 526
        anchors.fill:   parent
        enabled:        guidedModeConfirm.visible
        onClicked:      _guidedModeBar.rejectGuidedModeConfirm()
527 528
    }

529 530 531
    // Action confirmation control
    SliderSwitch {
        id:                         guidedModeConfirm
Don Gagne's avatar
Don Gagne committed
532 533
        anchors.bottomMargin:       _margins
        anchors.bottom:             parent.bottom
534 535 536
        anchors.horizontalCenter:   parent.horizontalCenter
        visible:                    false
        z:                          QGroundControl.zOrderWidgets
537
        fontPointSize:              _guidedModeBar._fontPointSize
538 539 540

        onAccept: {
            guidedModeConfirm.visible = false
Don Gagne's avatar
Don Gagne committed
541
            _guidedModeBar.visible = true
542 543
            _guidedModeBar.actionConfirmed()
            altitudeSlider.visible = false
Don Gagne's avatar
Don Gagne committed
544
            guidedModeHideTimer.restart()
Don Gagne's avatar
Don Gagne committed
545
        }
546

Don Gagne's avatar
Don Gagne committed
547
        onReject: _guidedModeBar.rejectGuidedModeConfirm()
548
    }
Don Gagne's avatar
Don Gagne committed
549 550 551 552 553 554 555 556 557 558 559 560 561

    //-- Altitude slider
    Rectangle {
        id:                 altitudeSlider
        anchors.margins:    _margins
        anchors.right:      parent.right
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
        color:              qgcPal.window
        width:              ScreenTools.defaultFontPixelWidth * 10
        opacity:            0.8
        visible:            false

562 563 564 565 566 567 568
        function setInitialValueMeters(meters) {
            altSlider.value = QGroundControl.metersToAppSettingsDistanceUnits(meters)
        }

        function setInitialValueAppSettingsDistanceUnits(height) {
            altSlider.value = height
        }
Don Gagne's avatar
Don Gagne committed
569 570 571

        /// Returns NaN for bad value
        function getValue() {
572 573 574 575 576 577
            var value =  parseFloat(altField.text)
            if (!isNaN(value)) {
                return QGroundControl.appSettingsDistanceUnitsToMeters(value);
            } else {
                return value;
            }
Don Gagne's avatar
Don Gagne committed
578 579 580 581 582 583 584 585 586 587 588
        }

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

            QGCLabel {
                anchors.horizontalCenter: parent.horizontalCenter
589
                text: qsTr("Alt (rel)")
Don Gagne's avatar
Don Gagne committed
590 591 592 593
            }

            QGCLabel {
                anchors.horizontalCenter: parent.horizontalCenter
594
                text: QGroundControl.appSettingsDistanceUnitsString
Don Gagne's avatar
Don Gagne committed
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
            }

            QGCTextField {
                id:             altField
                anchors.left:   parent.left
                anchors.right:  parent.right
                text:           altSlider.value.toFixed(1)
            }
        }

        Slider {
            id:                 altSlider
            anchors.margins:    _margins
            anchors.top:        headerColumn.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            orientation:        Qt.Vertical
Don Gagne's avatar
Don Gagne committed
613 614
            minimumValue:       QGroundControl.metersToAppSettingsDistanceUnits(2)
            maximumValue:       QGroundControl.metersToAppSettingsDistanceUnits((_activeVehicle && _activeVehicle.flying) ? 100 : 10)
Don Gagne's avatar
Don Gagne committed
615 616
        }
    }
617
}