FlightDisplayView.qml 31.4 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 17
import QtLocation               5.3
import QtPositioning            5.3
import QtMultimedia             5.5
18
import QtQuick.Layouts          1.2
Patrick José Pereira's avatar
Patrick José Pereira committed
19
import QtQuick.Window           2.2
20
import QtQml.Models             2.1
21

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

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

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

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

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

43 44 45 46 47 48 49
    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
50
    property bool   _useChecklist:          QGroundControl.settingsManager.appSettings.useChecklist.rawValue
51 52
    property real   _savedZoomLevel:        0
    property real   _margins:               ScreenTools.defaultFontPixelWidth / 2
53
    property real   _pipSize:               flightView.width * 0.2
54 55
    property alias  _guidedController:      guidedActionsController
    property alias  _altitudeSlider:        altitudeSlider
56

57 58
    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
59 60 61 62 63 64 65 66 67 68 69 70
    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"

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

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

Gus Grubba's avatar
Gus Grubba committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110
    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;
    }

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

116 117 118 119
    CheckList {
        id: checklist
    }

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

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

133 134 135 136 137 138 139 140 141 142 143 144 145 146
    // 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 {
147
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
148 149 150 151
                // 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)
                }
152 153 154 155 156 157 158 159 160 161 162 163
            }
            promptForMissionRemove = false
        }
    }

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

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

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

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

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

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

                    QGCButton {
                        Layout.fillWidth:   true
                        text:               qsTr("Leave plan on vehicle")
                        anchors.horizontalCenter:   parent.horizontalCenter
                        onClicked:                  hideDialog()
                    }
200
                }
201 202 203 204
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
    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
        }
220
    }
Patrick José Pereira's avatar
Patrick José Pereira committed
221

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
    /* 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
237 238
    }

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

241 242 243 244 245 246 247 248 249 250 251 252
    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
253
            visible:        _mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
254 255
            width:          _mainIsMap ? _panel.width  : _pipSize
            height:         _mainIsMap ? _panel.height : _pipSize * (9/16)
256 257 258 259 260 261 262 263 264 265 266 267 268 269
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
270
                }
271 272
            ]
            FlightDisplayViewMap {
273 274
                id:                         _flightMap
                anchors.fill:               parent
275
                planMasterController:       masterController
276 277 278 279
                guidedActionsController:    _guidedController
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
                qgcView:                    root
280
                multiVehicleView:           !singleVehicleView.checked
281
                scaleState:                 (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
282
            }
283
        }
284

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

            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
                }
            }

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

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

418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
        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
440
                text:           qsTr("Multi-Vehicle")
441 442 443 444
                color:          mapPal.text
            }
        }

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

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

            property var qgcView: root
470 471
        }

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

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

495
            property bool useLightColors: isBackgroundDark
496 497

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Rectangle {
696 697 698
            id:         checklistRect
            visible:    true
            width:      mainColumn.width + 3*ScreenTools.defaultFontPixelWidth
699
            height:     mainColumn.height + ScreenTools.defaultFontPixelHeight
700 701 702
            color:      qgcPal.windowShade
            radius:     3
            enabled:    QGroundControl.multiVehicleManager.vehicles.count > 0;
703 704

            Column {
705 706 707 708 709 710 711
                id:                     mainColumn
                width:                  40*ScreenTools.defaultFontPixelWidth
                spacing:                0.8*ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.top:            parent.top
                anchors.topMargin:      0.6*ScreenTools.defaultFontPixelWidth
                anchors.leftMargin:     1.5*ScreenTools.defaultFontPixelWidth
712 713

                // Header/title of checklist
714 715 716
                Item {
                    width:  parent.width
                    height: 1.75*ScreenTools.defaultFontPixelHeight
717

718 719 720 721 722 723 724 725 726 727 728 729 730
                    QGCLabel {
                        text:                   _activeVehicle ? qsTr("Pre-flight checklist")+" (MAV ID:"+_activeVehicle.id+")" : qsTr("Pre-flight checklist (no vehicle)")
                        anchors.left:           parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.pointSize:         ScreenTools.mediumFontPointSize
                    }
                    QGCButton {
                        width:                  1.2*ScreenTools.defaultFontPixelHeight
                        height:                 1.2*ScreenTools.defaultFontPixelHeight
                        anchors.right:          parent.right
                        anchors.verticalCenter: parent.verticalCenter
                        opacity :               0.2+0.8*(QGroundControl.multiVehicleManager.vehicles.count > 0)
                        tooltip:                "Reset the checklist (e.g. after a vehicle reboot)"
731

732
                        onClicked:              checklist.resetNrClicks()
733

734
                        Image { source:"/qmlimages/MapSyncBlack.svg" ; anchors.fill: parent }
735
                    }
736
                }
737

738
                Rectangle {width:parent.width ; height:1 ; color:qgcPal.text}
739

740 741 742 743 744
                // All check list items
                Repeater {
                    model: checklist.checkListItems
                }
            } // Column
745 746 747
        } //Rectangle
    } //Component
} //QGC View