FlightDisplayView.qml 29 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
import QtQuick                  2.3
import QtQuick.Controls         1.2
13
import QtQuick.Controls.Styles  1.4
14
import QtQuick.Dialogs          1.2
15 16
import QtLocation               5.3
import QtPositioning            5.3
17
import QtQuick.Layouts          1.2
Patrick José Pereira's avatar
Patrick José Pereira committed
18
import QtQuick.Window           2.2
19
import QtQml.Models             2.1
20

21
import QGroundControl               1.0
Don Gagne's avatar
Don Gagne committed
22
import QGroundControl.FlightDisplay 1.0
23 24 25 26
import QGroundControl.FlightMap     1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
27
import QGroundControl.Vehicle       1.0
28
import QGroundControl.Controllers   1.0
Don Gagne's avatar
Don Gagne committed
29
import QGroundControl.FactSystem    1.0
30 31

/// Flight Display View
32 33 34
QGCView {
    id:             root
    viewPanel:      _panel
35

36
    QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
37

Don Gagne's avatar
Don Gagne committed
38 39
    property alias  guidedController:   guidedActionsController

40 41
    property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false

42 43 44 45 46 47 48
    property var    _planMasterController:  masterController
    property var    _missionController:     _planMasterController.missionController
    property var    _geoFenceController:    _planMasterController.geoFenceController
    property var    _rallyPointController:  _planMasterController.rallyPointController
    property var    _activeVehicle:         QGroundControl.multiVehicleManager.activeVehicle
    property bool   _mainIsMap:             QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey,  true) : true
    property bool   _isPipVisible:          QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false
49
    property bool   _useChecklist:          QGroundControl.settingsManager.appSettings.useChecklist.rawValue
50 51
    property real   _savedZoomLevel:        0
    property real   _margins:               ScreenTools.defaultFontPixelWidth / 2
52
    property real   _pipSize:               flightView.width * 0.2
53 54
    property alias  _guidedController:      guidedActionsController
    property alias  _altitudeSlider:        altitudeSlider
55

56 57
    readonly property var       _dynamicCameras:        _activeVehicle ? _activeVehicle.dynamicCameras : null
    readonly property bool      _isCamera:              _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
Don Gagne's avatar
Don Gagne committed
58 59 60 61 62 63 64 65 66 67 68 69
    readonly property bool      isBackgroundDark:       _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
    readonly property real      _defaultRoll:           0
    readonly property real      _defaultPitch:          0
    readonly property real      _defaultHeading:        0
    readonly property real      _defaultAltitudeAMSL:   0
    readonly property real      _defaultGroundSpeed:    0
    readonly property real      _defaultAirSpeed:       0
    readonly property string    _mapName:               "FlightDisplayView"
    readonly property string    _showMapBackgroundKey:  "/showMapBackground"
    readonly property string    _mainIsMapKey:          "MainFlyWindowIsMap"
    readonly property string    _PIPVisibleKey:         "IsPIPVisible"

70
    function setStates() {
71
        QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, _mainIsMap)
72
        if(_mainIsMap) {
73 74 75 76 77 78 79 80
            //-- Adjust Margins
            _flightMapContainer.state   = "fullMode"
            _flightVideo.state          = "pipMode"
            //-- Save/Restore Map Zoom Level
            if(_savedZoomLevel != 0)
                _flightMap.zoomLevel = _savedZoomLevel
            else
                _savedZoomLevel = _flightMap.zoomLevel
81
        } else {
82 83 84 85 86 87
            //-- Adjust Margins
            _flightMapContainer.state   = "pipMode"
            _flightVideo.state          = "fullMode"
            //-- Set Map Zoom Level
            _savedZoomLevel = _flightMap.zoomLevel
            _flightMap.zoomLevel = _savedZoomLevel - 3
88
        }
Don Gagne's avatar
Don Gagne committed
89 90
    }

91 92 93
    function setPipVisibility(state) {
        _isPipVisible = state;
        QGroundControl.saveBoolGlobalSetting(_PIPVisibleKey, state)
94 95
    }

Gus Grubba's avatar
Gus Grubba committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109
    function isInstrumentRight() {
        if(QGroundControl.corePlugin.options.instrumentWidget) {
            if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) {
                switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) {
                case CustomInstrumentWidget.POS_TOP_LEFT:
                case CustomInstrumentWidget.POS_BOTTOM_LEFT:
                case CustomInstrumentWidget.POS_CENTER_LEFT:
                    return false;
                }
            }
        }
        return true;
    }

110
    PlanMasterController {
111
        id:                     masterController
112
        Component.onCompleted:  start(true /* flyView */)
113 114
    }

115 116
    PreFlightCheckModel {
        id: preFlightCheckModel
117 118
    }

119
    Connections {
120 121 122
        target:                     _missionController
        onResumeMissionReady:       guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionReady)
        onResumeMissionUploadFail:  guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionUploadFail)
123 124
    }

125 126
    Component.onCompleted: {
        setStates()
127 128 129
        if(QGroundControl.corePlugin.options.flyViewOverlay.toString().length) {
            flyViewOverlay.source = QGroundControl.corePlugin.options.flyViewOverlay
        }
130
    }
dogmaphobic's avatar
dogmaphobic committed
131

132 133 134 135 136 137 138 139 140 141 142 143 144 145
    // The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes

    property bool vehicleArmed:                 _activeVehicle ? _activeVehicle.armed : true // true here prevents pop up from showing during shutdown
    property bool vehicleWasArmed:              false
    property bool vehicleInMissionFlightMode:   _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false
    property bool promptForMissionRemove:       false

    onVehicleArmedChanged: {
        if (vehicleArmed) {
            if (!promptForMissionRemove) {
                promptForMissionRemove = vehicleInMissionFlightMode
                vehicleWasArmed = true
            }
        } else {
146
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
147 148 149 150
                // ArduPilot has a strange bug which prevents mission clear from working at certain times, so we can't show this dialog
                if (!_activeVehicle.apmFirmware) {
                    root.showDialog(missionCompleteDialogComponent, qsTr("Flight Plan complete"), showDialogDefaultWidth, StandardButton.Close)
                }
151 152 153 154 155 156 157 158 159 160 161 162
            }
            promptForMissionRemove = false
        }
    }

    onVehicleInMissionFlightModeChanged: {
        if (!promptForMissionRemove && vehicleArmed) {
            promptForMissionRemove = true
        }
    }

    Component {
163 164 165 166 167 168 169
        id: missionCompleteDialogComponent

        QGCViewDialog {
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

170
                ColumnLayout {
171 172 173 174 175 176 177
                    id:                 column
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    spacing:            ScreenTools.defaultFontPixelHeight

                    QGCLabel {
178 179 180 181
                        Layout.fillWidth:       true
                        text:                   qsTr("%1 Images Taken").arg(_activeVehicle.cameraTriggerPoints.count)
                        horizontalAlignment:    Text.AlignHCenter
                        visible:                _activeVehicle.cameraTriggerPoints.count != 0
182 183 184
                    }

                    QGCButton {
185 186
                        Layout.fillWidth:   true
                        text:               qsTr("Remove plan from vehicle")
187 188 189 190 191
                        onClicked: {
                            _planMasterController.removeAllFromVehicle()
                            hideDialog()
                        }
                    }
192 193 194

                    QGCButton {
                        Layout.fillWidth:   true
195
                        Layout.alignment:   Qt.AlignHCenter
196
                        text:               qsTr("Leave plan on vehicle")
197
                        onClicked:          hideDialog()
198
                    }
199
                }
200 201 202 203
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
    Window {
        id:             videoWindow
        width:          !_mainIsMap ? _panel.width  : _pipSize
        height:         !_mainIsMap ? _panel.height : _pipSize * (9/16)
        visible:        false

        Item {
            id:             videoItem
            anchors.fill:   parent
        }

        onClosing: {
            _flightVideo.state = "unpopup"
            videoWindow.visible = false
        }
219
    }
Patrick José Pereira's avatar
Patrick José Pereira committed
220

221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
    /* This timer will startVideo again after the popup window appears and is loaded.
     * Such approach was the only one to avoid a crash for windows users
     */
    Timer {
      id: videoPopUpTimer
      interval: 2000;
      running: false;
      repeat: false
      onTriggered: {
          // If state is popup, the next one will be popup-finished
          if (_flightVideo.state ==  "popup") {
            _flightVideo.state = "popup-finished"
          }
          QGroundControl.videoManager.startVideo()
      }
Patrick José Pereira's avatar
Patrick José Pereira committed
236 237
    }

238 239
    QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }

240 241 242 243 244 245 246 247 248 249 250 251
    QGCViewPanel {
        id:             _panel
        anchors.fill:   parent

        //-- Map View
        //   For whatever reason, if FlightDisplayViewMap is the _panel item, changing
        //   width/height has no effect.
        Item {
            id: _flightMapContainer
            z:  _mainIsMap ? _panel.z + 1 : _panel.z + 2
            anchors.left:   _panel.left
            anchors.bottom: _panel.bottom
252
            visible:        _mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
253 254
            width:          _mainIsMap ? _panel.width  : _pipSize
            height:         _mainIsMap ? _panel.height : _pipSize * (9/16)
255 256 257 258 259 260 261 262 263 264 265 266 267 268
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
269
                }
270 271
            ]
            FlightDisplayViewMap {
272 273
                id:                         _flightMap
                anchors.fill:               parent
274
                planMasterController:       masterController
275 276 277 278
                guidedActionsController:    _guidedController
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
                qgcView:                    root
279
                multiVehicleView:           !singleVehicleView.checked
280
                scaleState:                 (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
281
            }
282
        }
283

284
        //-- Video View
285
        Item {
286 287
            id:             _flightVideo
            z:              _mainIsMap ? _panel.z + 2 : _panel.z + 1
288 289
            width:          !_mainIsMap ? _panel.width  : _pipSize
            height:         !_mainIsMap ? _panel.height : _pipSize * (9/16)
290 291
            anchors.left:   _panel.left
            anchors.bottom: _panel.bottom
292
            visible:        QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
293 294 295 296 297 298 299 300 301 302 303 304 305 306

            onParentChanged: {
                /* If video comes back from popup
                 * correct anchors.
                 * Such thing is not possible with ParentChange.
                 */
                if(parent == _panel) {
                    // Do anchors again after popup
                    anchors.left =       _panel.left
                    anchors.bottom =     _panel.bottom
                    anchors.margins =    ScreenTools.defaultFontPixelHeight
                }
            }

307 308 309 310 311
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target: _flightVideo
Patrick José Pereira's avatar
Patrick José Pereira committed
312 313 314 315 316
                        anchors.margins: ScreenTools.defaultFontPixelHeight
                    }
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
317 318 319 320 321 322 323 324
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target: _flightVideo
                        anchors.margins:    0
                    }
Patrick José Pereira's avatar
Patrick José Pereira committed
325 326 327 328 329 330 331 332
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
                    }
                },
                State {
                    name: "popup"
                    StateChangeScript {
333 334 335 336 337 338
                        script: {
                            // Stop video, restart it again with Timer
                            // Avoiding crashs if ParentChange is not yet done
                            QGroundControl.videoManager.stopVideo()
                            videoPopUpTimer.running = true
                        }
Patrick José Pereira's avatar
Patrick José Pereira committed
339
                    }
340 341 342 343 344 345 346
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: true
                    }
                },
                State {
                    name: "popup-finished"
Patrick José Pereira's avatar
Patrick José Pereira committed
347 348 349 350 351
                    ParentChange {
                        target: _flightVideo
                        parent: videoItem
                        x: 0
                        y: 0
352 353
                        width: videoItem.width
                        height: videoItem.height
Patrick José Pereira's avatar
Patrick José Pereira committed
354 355 356 357 358
                    }
                },
                State {
                    name: "unpopup"
                    StateChangeScript {
359 360 361 362
                        script: {
                            QGroundControl.videoManager.stopVideo()
                            videoPopUpTimer.running = true
                        }
Patrick José Pereira's avatar
Patrick José Pereira committed
363 364 365 366 367 368 369 370 371
                    }
                    ParentChange {
                        target: _flightVideo
                        parent: _panel
                    }
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
                    }
372
                }
373
            ]
374
            //-- Video Streaming
375
            FlightDisplayViewVideo {
Patrick José Pereira's avatar
Patrick José Pereira committed
376
                id:             videoStreaming
377 378 379 380
                anchors.fill:   parent
                visible:        QGroundControl.videoManager.isGStreamer
            }
            //-- UVC Video (USB Camera or Video Device)
381 382
            Loader {
                id:             cameraLoader
383 384
                anchors.fill:   parent
                visible:        !QGroundControl.videoManager.isGStreamer
385
                source:         QGroundControl.videoManager.uvcEnabled ? "qrc:/qml/FlightDisplayViewUVC.qml" : "qrc:/qml/FlightDisplayViewDummy.qml"
386
            }
dogmaphobic's avatar
dogmaphobic committed
387
        }
388 389 390 391

        QGCPipable {
            id:                 _flightVideoPipControl
            z:                  _flightVideo.z + 3
392 393
            width:              _pipSize
            height:             _pipSize * (9/16)
394 395 396
            anchors.left:       _panel.left
            anchors.bottom:     _panel.bottom
            anchors.margins:    ScreenTools.defaultFontPixelHeight
397
            visible:            QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen && _flightVideo.state != "popup"
398 399
            isHidden:           !_isPipVisible
            isDark:             isBackgroundDark
400
            enablePopup:        _mainIsMap
401 402 403 404 405 406 407
            onActivated: {
                _mainIsMap = !_mainIsMap
                setStates()
            }
            onHideIt: {
                setPipVisibility(!state)
            }
Patrick José Pereira's avatar
Patrick José Pereira committed
408 409 410 411
            onPopup: {
                videoWindow.visible = true
                _flightVideo.state = "popup"
            }
412 413
            onNewWidth: {
                _pipSize = newWidth
Jacob Walser's avatar
Jacob Walser committed
414
            }
dogmaphobic's avatar
dogmaphobic committed
415
        }
Don Gagne's avatar
Don Gagne committed
416

417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
        Row {
            id:                     singleMultiSelector
            anchors.topMargin:      ScreenTools.toolbarHeight + _margins
            anchors.rightMargin:    _margins
            anchors.right:          parent.right
            anchors.top:            parent.top
            spacing:                ScreenTools.defaultFontPixelWidth
            z:                      _panel.z + 4
            visible:                QGroundControl.multiVehicleManager.vehicles.count > 1

            ExclusiveGroup { id: multiVehicleSelectorGroup }

            QGCRadioButton {
                id:             singleVehicleView
                exclusiveGroup: multiVehicleSelectorGroup
                text:           qsTr("Single")
                checked:        true
                color:          mapPal.text
            }

            QGCRadioButton {
                exclusiveGroup: multiVehicleSelectorGroup
439
                text:           qsTr("Multi-Vehicle")
440 441 442 443
                color:          mapPal.text
            }
        }

444
        FlightDisplayViewWidgets {
445 446
            id:                 flightDisplayViewWidgets
            z:                  _panel.z + 4
447
            height:             ScreenTools.availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _margins : 0)
448
            anchors.left:       parent.left
449
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
450 451
            anchors.bottom:     parent.bottom
            qgcView:            root
452
            useLightColors:     isBackgroundDark
453
            missionController:  _missionController
454
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
455 456
        }

457 458 459 460 461
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
462
            visible:            !QGroundControl.videoManager.fullScreen
463 464 465 466
            height:             ScreenTools.availableHeight
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
467 468

            property var qgcView: root
469 470
        }

471 472 473 474 475 476
        MultiVehicleList {
            anchors.margins:    _margins
            anchors.top:        singleMultiSelector.bottom
            anchors.right:      parent.right
            anchors.bottom:     parent.bottom
            width:              ScreenTools.defaultFontPixelWidth * 30
477
            visible:            !singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
478
            z:                  _panel.z + 4
479
        }
dogmaphobic's avatar
dogmaphobic committed
480

481
        //-- Virtual Joystick
482
        Loader {
483
            id:                         virtualJoystickMultiTouch
484 485
            z:                          _panel.z + 5
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
486
            height:                     Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16)
487
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen
488 489
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
490
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
491
            source:                     "qrc:/qml/VirtualJoystick.qml"
492
            active:                     _virtualJoystick ? _virtualJoystick.value : false
Don Gagne's avatar
Don Gagne committed
493

494
            property bool useLightColors: isBackgroundDark
495 496

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
Don Gagne's avatar
Don Gagne committed
497
        }
498 499

        ToolStrip {
500
            visible:            (_activeVehicle ? _activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
501
            id:                 toolStrip
Gus Grubba's avatar
Gus Grubba committed
502 503 504 505
            anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth : undefined
            anchors.left:       isInstrumentRight() ? _panel.left : undefined
            anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
            anchors.right:      isInstrumentRight() ? undefined : _panel.right
506
            anchors.topMargin:  ScreenTools.toolbarHeight + (_margins * 2)
507 508 509 510
            anchors.top:        _panel.top
            z:                  _panel.z + 4
            title:              qsTr("Fly")
            maxHeight:          (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
511
            buttonVisible:      [ _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true, _guidedController.smartShotsAvailable ]
512
            buttonEnabled:      [ _useChecklist && _activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable, _anySmartShotAvailable ]
513

514
            property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
515
            property bool _anySmartShotAvailable: _guidedController.showOrbit
516 517
            property var _actionModel: [
                {
518 519 520 521
                    title:      _guidedController.startMissionTitle,
                    text:       _guidedController.startMissionMessage,
                    action:     _guidedController.actionStartMission,
                    visible:    _guidedController.showStartMission
522
                },
Don Gagne's avatar
Don Gagne committed
523 524 525 526 527 528
                {
                    title:      _guidedController.continueMissionTitle,
                    text:       _guidedController.continueMissionMessage,
                    action:     _guidedController.actionContinueMission,
                    visible:    _guidedController.showContinueMission
                },
529
                {
530 531 532 533
                    title:      _guidedController.resumeMissionTitle,
                    text:       _guidedController.resumeMissionMessage,
                    action:     _guidedController.actionResumeMission,
                    visible:    _guidedController.showResumeMission
534 535
                },
                {
536 537 538 539
                    title:      _guidedController.changeAltTitle,
                    text:       _guidedController.changeAltMessage,
                    action:     _guidedController.actionChangeAlt,
                    visible:    _guidedController.showChangeAlt
540 541
                },
                {
542 543 544 545
                    title:      _guidedController.landAbortTitle,
                    text:       _guidedController.landAbortMessage,
                    action:     _guidedController.actionLandAbort,
                    visible:    _guidedController.showLandAbort
546 547 548 549
                }
            ]
            property var _smartShotModel: [
                {
550 551 552 553
                    title:      _guidedController.orbitTitle,
                    text:       _guidedController.orbitMessage,
                    action:     _guidedController.actionOrbit,
                    visible:    _guidedController.showOrbit
554 555 556 557
                }
            ]

            model: [
558 559 560 561 562
                {
                    name:               "Checklist",
                    iconSource:         "/qmlimages/check.svg",
                    dropPanelComponent: checklistDropPanel
                },
563
                {
564
                    name:       _guidedController.takeoffTitle,
565
                    iconSource: "/res/takeoff.svg",
566
                    action:     _guidedController.actionTakeoff
567 568
                },
                {
569
                    name:       _guidedController.landTitle,
570
                    iconSource: "/res/land.svg",
571
                    action:     _guidedController.actionLand
572 573
                },
                {
574
                    name:       _guidedController.rtlTitle,
575
                    iconSource: "/res/rtl.svg",
576
                    action:     _guidedController.actionRTL
577 578
                },
                {
579
                    name:       _guidedController.pauseTitle,
Gus Grubba's avatar
Gus Grubba committed
580
                    iconSource: "/res/pause-mission.svg",
581
                    action:     _guidedController.actionPause
582 583 584
                },
                {
                    name:       qsTr("Action"),
Gus Grubba's avatar
Gus Grubba committed
585
                    iconSource: "/res/action.svg",
586 587 588 589 590 591 592 593 594 595 596 597 598
                    action:     -1
                },
                /*
                  No firmware support any smart shots yet
                {
                    name:       qsTr("Smart"),
                    iconSource: "/qmlimages/MapCenter.svg",
                    action:     -1
                },
                */
            ]

            onClicked: {
599
                guidedActionsController.closeAll()
600 601
                var action = model[index].action
                if (action === -1) {
602
                    if (index == 5) {
603
                        guidedActionList.model   = _actionModel
604
                        guidedActionList.visible = true
605
                    } else if (index == 6) {
606
                        guidedActionList.model   = _smartShotModel
607 608 609
                        guidedActionList.visible = true
                    }
                } else {
610
                    _guidedController.confirmAction(action)
611 612 613 614 615
                }
            }
        }

        GuidedActionsController {
616
            id:                 guidedActionsController
617
            missionController:  _missionController
618
            confirmDialog:      guidedActionConfirm
DonLakeFlyer's avatar
DonLakeFlyer committed
619
            actionList:         guidedActionList
Don Gagne's avatar
Don Gagne committed
620
            altitudeSlider:     _altitudeSlider
621 622
            z:                  _flightVideoPipControl.z + 1

623
            onShowStartMissionChanged: {
624
                if (showStartMission && !showResumeMission) {
625 626 627 628
                    confirmAction(actionStartMission)
                }
            }

629 630 631 632 633 634
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

635 636 637 638 639
            onShowResumeMissionChanged: {
                if (showResumeMission) {
                    confirmAction(actionResumeMission)
                }
            }
640 641 642 643 644 645

            onShowLandAbortChanged: {
                if (showLandAbort) {
                    confirmAction(actionLandAbort)
                }
            }
646 647 648

            /// Close all dialogs
            function closeAll() {
649
                mainWindow.enableToolbar()
650 651 652 653 654
                rootLoader.sourceComponent  = null
                guidedActionConfirm.visible = false
                guidedActionList.visible    = false
                altitudeSlider.visible      = false
            }
655 656
        }

657
        GuidedActionConfirm {
658 659 660 661
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
662 663
            guidedController:           _guidedController
            altitudeSlider:             _altitudeSlider
664 665
        }

666
        GuidedActionList {
667 668 669 670
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
671
            guidedController:           _guidedController
672 673 674
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
675
        GuidedAltitudeSlider {
676 677 678 679 680 681
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
682
            z:                  _guidedController.z
683 684 685 686 687
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
688
    }
689

690
    //-- Checklist GUI
691 692 693
    Component {
        id: checklistDropPanel

694 695 696
        PreFlightCheckList {
            model: preFlightCheckModel
        }
697 698
    } //Component
} //QGC View