FlightDisplayView.qml 34.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
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
22 23 24 25
import QGroundControl.Airspace      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactSystem    1.0
Don Gagne's avatar
Don Gagne committed
26
import QGroundControl.FlightDisplay 1.0
27 28
import QGroundControl.FlightMap     1.0
import QGroundControl.Palette       1.0
29
import QGroundControl.ScreenTools   1.0
30
import QGroundControl.Vehicle       1.0
31 32

/// Flight Display View
33
Item {
34

Gus Grubba's avatar
Gus Grubba committed
35
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
36 37 38 39 40
        id: _planController
        Component.onCompleted: {
            start(true /* flyView */)
            mainWindow.planMasterControllerView = _planController
        }
Gus Grubba's avatar
Gus Grubba committed
41 42
    }

43 44
    property alias  guidedController:               guidedActionsController
    property bool   activeVehicleJoystickEnabled:   activeVehicle ? activeVehicle.joystickEnabled : false
45

Gus Grubba's avatar
Gus Grubba committed
46 47 48
    property var    _missionController:     _planController.missionController
    property var    _geoFenceController:    _planController.geoFenceController
    property var    _rallyPointController:  _planController.rallyPointController
49 50
    property bool   _mainIsMap:             QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey,  true) : true
    property bool   _isPipVisible:          QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false
51
    property bool   _useChecklist:          QGroundControl.settingsManager.appSettings.useChecklist.rawValue
52 53
    property real   _savedZoomLevel:        0
    property real   _margins:               ScreenTools.defaultFontPixelWidth / 2
54
    property real   _pipSize:               mainWindow.width * 0.2
55 56
    property alias  _guidedController:      guidedActionsController
    property alias  _altitudeSlider:        altitudeSlider
57

Gus Grubba's avatar
Gus Grubba committed
58
    readonly property var       _dynamicCameras:        activeVehicle ? activeVehicle.dynamicCameras : null
59
    readonly property bool      _isCamera:              _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
60
    readonly property bool      isBackgroundDark:       _mainIsMap ? (mainWindow.flightDisplayMap ? mainWindow.flightDisplayMap.isSatelliteMap : true) : true
Don Gagne's avatar
Don Gagne committed
61 62 63 64 65 66 67 68 69 70 71
    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"

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

98 99 100
    function setPipVisibility(state) {
        _isPipVisible = state;
        QGroundControl.saveBoolGlobalSetting(_PIPVisibleKey, state)
101 102
    }

Gus Grubba's avatar
Gus Grubba committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    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;
    }

117
    BuiltInPreFlightCheckModel {
118
        id: preFlightCheckModel
119 120
    }

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

126 127 128 129 130 131 132 133 134 135 136 137 138 139
    Connections {
        target:                 mainWindow
        onArmVehicle:           guidedController.confirmAction(guidedController.actionArm)
        onDisarmVehicle: {
            if (guidedController.showEmergenyStop) {
                guidedController.confirmAction(guidedController.actionEmergencyStop)
            } else {
                guidedController.confirmAction(guidedController.actionDisarm)
            }
        }
        onVtolTransitionToFwdFlight:    guidedController.confirmAction(guidedController.actionVtolTransitionToFwdFlight)
        onVtolTransitionToMRFlight:     guidedController.confirmAction(guidedController.actionVtolTransitionToMRFlight)
    }

140 141
    Component.onCompleted: {
        setStates()
142 143 144
        if(QGroundControl.corePlugin.options.flyViewOverlay.toString().length) {
            flyViewOverlay.source = QGroundControl.corePlugin.options.flyViewOverlay
        }
145
    }
dogmaphobic's avatar
dogmaphobic committed
146

147 148
    // The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes

Gus Grubba's avatar
Gus Grubba committed
149
    property bool vehicleArmed:                 activeVehicle ? activeVehicle.armed : true // true here prevents pop up from showing during shutdown
150
    property bool vehicleWasArmed:              false
Gus Grubba's avatar
Gus Grubba committed
151
    property bool vehicleInMissionFlightMode:   activeVehicle ? (activeVehicle.flightMode === activeVehicle.missionFlightMode) : false
152 153 154 155 156 157 158 159 160
    property bool promptForMissionRemove:       false

    onVehicleArmedChanged: {
        if (vehicleArmed) {
            if (!promptForMissionRemove) {
                promptForMissionRemove = vehicleInMissionFlightMode
                vehicleWasArmed = true
            }
        } else {
161
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
162
                // ArduPilot has a strange bug which prevents mission clear from working at certain times, so we can't show this dialog
Gus Grubba's avatar
Gus Grubba committed
163
                if (!activeVehicle.apmFirmware) {
164
                    mainWindow.showDialog(missionCompleteDialogComponent, qsTr("Flight Plan complete"), mainWindow.showDialogDefaultWidth, StandardButton.Close)
165
                }
166 167 168 169 170 171 172 173 174 175 176 177
            }
            promptForMissionRemove = false
        }
    }

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

    Component {
178 179 180
        id: missionCompleteDialogComponent

        QGCViewDialog {
Gus Grubba's avatar
Gus Grubba committed
181
            property var activeVehicleCopy: activeVehicle
182 183 184 185 186
            onActiveVehicleCopyChanged:
                if (!activeVehicleCopy) {
                    hideDialog()
                }

187 188 189 190
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

191
                ColumnLayout {
192 193 194 195 196
                    id:                 column
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.right:      parent.right

197
                    ColumnLayout {
198
                        Layout.fillWidth:   true
199
                        spacing:            ScreenTools.defaultFontPixelHeight
Gus Grubba's avatar
Gus Grubba committed
200
                        visible:            !activeVehicle.connectionLost || !_guidedController.showResumeMission
201 202 203

                        QGCLabel {
                            Layout.fillWidth:       true
Gus Grubba's avatar
Gus Grubba committed
204
                            text:                   qsTr("%1 Images Taken").arg(activeVehicle.cameraTriggerPoints.count)
205
                            horizontalAlignment:    Text.AlignHCenter
Gus Grubba's avatar
Gus Grubba committed
206
                            visible:                activeVehicle.cameraTriggerPoints.count !== 0
207
                        }
208

209 210 211 212
                        QGCButton {
                            Layout.fillWidth:   true
                            text:               qsTr("Remove plan from vehicle")
                            onClicked: {
Gus Grubba's avatar
Gus Grubba committed
213
                                _planController.removeAllFromVehicle()
214 215 216
                                hideDialog()
                            }
                        }
Don Gagne's avatar
Don Gagne committed
217

218 219 220 221 222 223
                        QGCButton {
                            Layout.fillWidth:   true
                            Layout.alignment:   Qt.AlignHCenter
                            text:               qsTr("Leave plan on vehicle")
                            onClicked:          hideDialog()
                        }
Don Gagne's avatar
Don Gagne committed
224

225 226 227 228 229
                        Rectangle {
                            Layout.fillWidth:   true
                            color:              qgcPal.text
                            height:             1
                        }
Don Gagne's avatar
Don Gagne committed
230

231 232 233 234 235 236 237 238 239 240
                        QGCButton {
                            Layout.fillWidth:   true
                            Layout.alignment:   Qt.AlignHCenter
                            text:               qsTr("Resume Mission From Waypoint %1").arg(_guidedController._resumeMissionIndex)
                            visible:            _guidedController.showResumeMission

                            onClicked: {
                                guidedController.executeAction(_guidedController.actionResumeMission, null, null)
                                hideDialog()
                            }
Don Gagne's avatar
Don Gagne committed
241 242
                        }

243 244 245 246 247 248 249 250 251 252 253 254 255 256
                        QGCLabel {
                            Layout.fillWidth:   true
                            wrapMode:           Text.WordWrap
                            text:               qsTr("Resume Mission will rebuild the current mission from the last flown waypoint and upload it to the vehicle for the next flight.")
                            visible:            _guidedController.showResumeMission
                        }

                        QGCLabel {
                            Layout.fillWidth:   true
                            wrapMode:           Text.WordWrap
                            color:              qgcPal.warningText
                            text:               qsTr("If you are changing batteries for Resume Mission do not disconnect from the vehicle when communication is lost.")
                            visible:            _guidedController.showResumeMission
                        }
Don Gagne's avatar
Don Gagne committed
257 258
                    }

259
                    ColumnLayout {
Don Gagne's avatar
Don Gagne committed
260
                        Layout.fillWidth:   true
261
                        spacing:            ScreenTools.defaultFontPixelHeight
Gus Grubba's avatar
Gus Grubba committed
262
                        visible:            activeVehicle.connectionLost && _guidedController.showResumeMission
263 264 265 266 267 268 269

                        QGCLabel {
                            Layout.fillWidth:   true
                            wrapMode:           Text.WordWrap
                            color:              qgcPal.warningText
                            text:               qsTr("If you are changing batteries for Resume Mission do not disconnect from the vehicle.")
                        }
Don Gagne's avatar
Don Gagne committed
270
                    }
271
                }
272 273 274 275
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
276 277
    Window {
        id:             videoWindow
278 279
        width:          !_mainIsMap ? _mapAndVideo.width  : _pipSize
        height:         !_mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
Patrick José Pereira's avatar
Patrick José Pereira committed
280 281 282 283 284 285 286 287 288 289 290
        visible:        false

        Item {
            id:             videoItem
            anchors.fill:   parent
        }

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

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
    /* 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
308 309
    }

310
    QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? mainWindow.flightDisplayMap.isSatelliteMap : true }
311

312
    Item {
313
        id:             _mapAndVideo
314 315 316 317 318
        anchors.fill:   parent

        //-- Map View
        Item {
            id: _flightMapContainer
319 320 321
            z:  _mainIsMap ? _mapAndVideo.z + 1 : _mapAndVideo.z + 2
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
322
            visible:        _mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
323 324
            width:          _mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         _mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
325 326 327 328 329 330 331 332 333 334 335 336 337 338
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
339
                }
340 341
            ]
            FlightDisplayViewMap {
342
                id:                         _fMap
343 344
                anchors.fill:               parent
                guidedActionsController:    _guidedController
Gus Grubba's avatar
Gus Grubba committed
345
                missionController:          _planController
346 347
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
348
                multiVehicleView:           !singleVehicleView.checked
349
                scaleState:                 (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
350 351 352
                Component.onCompleted: {
                    mainWindow.flightDisplayMap = _fMap
                }
353
            }
354
        }
355

356
        //-- Video View
357
        Item {
358
            id:             _flightVideo
359 360 361 362 363
            z:              _mainIsMap ? _mapAndVideo.z + 2 : _mapAndVideo.z + 1
            width:          !_mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         !_mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
364
            visible:        QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
365 366 367 368 369 370

            onParentChanged: {
                /* If video comes back from popup
                 * correct anchors.
                 * Such thing is not possible with ParentChange.
                 */
371
                if(parent == _mapAndVideo) {
372
                    // Do anchors again after popup
373 374
                    anchors.left =       _mapAndVideo.left
                    anchors.bottom =     _mapAndVideo.bottom
375 376 377 378
                    anchors.margins =    ScreenTools.defaultFontPixelHeight
                }
            }

379 380 381 382 383
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target: _flightVideo
Patrick José Pereira's avatar
Patrick José Pereira committed
384 385 386 387 388
                        anchors.margins: ScreenTools.defaultFontPixelHeight
                    }
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
389 390 391 392 393 394 395 396
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target: _flightVideo
                        anchors.margins:    0
                    }
Patrick José Pereira's avatar
Patrick José Pereira committed
397 398 399 400 401 402 403 404
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
                    }
                },
                State {
                    name: "popup"
                    StateChangeScript {
405 406 407 408 409 410
                        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
411
                    }
412 413 414 415 416 417 418
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: true
                    }
                },
                State {
                    name: "popup-finished"
Patrick José Pereira's avatar
Patrick José Pereira committed
419 420 421 422 423
                    ParentChange {
                        target: _flightVideo
                        parent: videoItem
                        x: 0
                        y: 0
424 425
                        width: videoItem.width
                        height: videoItem.height
Patrick José Pereira's avatar
Patrick José Pereira committed
426 427 428 429 430
                    }
                },
                State {
                    name: "unpopup"
                    StateChangeScript {
431 432 433 434
                        script: {
                            QGroundControl.videoManager.stopVideo()
                            videoPopUpTimer.running = true
                        }
Patrick José Pereira's avatar
Patrick José Pereira committed
435 436 437
                    }
                    ParentChange {
                        target: _flightVideo
438
                        parent: _mapAndVideo
Patrick José Pereira's avatar
Patrick José Pereira committed
439 440 441 442 443
                    }
                    PropertyChanges {
                        target: _flightVideoPipControl
                        inPopup: false
                    }
444
                }
445
            ]
446
            //-- Video Streaming
447
            FlightDisplayViewVideo {
Patrick José Pereira's avatar
Patrick José Pereira committed
448
                id:             videoStreaming
449 450 451 452
                anchors.fill:   parent
                visible:        QGroundControl.videoManager.isGStreamer
            }
            //-- UVC Video (USB Camera or Video Device)
453 454
            Loader {
                id:             cameraLoader
455 456
                anchors.fill:   parent
                visible:        !QGroundControl.videoManager.isGStreamer
457
                source:         QGroundControl.videoManager.uvcEnabled ? "qrc:/qml/FlightDisplayViewUVC.qml" : "qrc:/qml/FlightDisplayViewDummy.qml"
458
            }
dogmaphobic's avatar
dogmaphobic committed
459
        }
460 461 462 463

        QGCPipable {
            id:                 _flightVideoPipControl
            z:                  _flightVideo.z + 3
464 465
            width:              _pipSize
            height:             _pipSize * (9/16)
466 467
            anchors.left:       _mapAndVideo.left
            anchors.bottom:     _mapAndVideo.bottom
468
            anchors.margins:    ScreenTools.defaultFontPixelHeight
469
            visible:            QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen && _flightVideo.state != "popup"
470 471
            isHidden:           !_isPipVisible
            isDark:             isBackgroundDark
472
            enablePopup:        _mainIsMap
473 474 475 476 477 478 479
            onActivated: {
                _mainIsMap = !_mainIsMap
                setStates()
            }
            onHideIt: {
                setPipVisibility(!state)
            }
Patrick José Pereira's avatar
Patrick José Pereira committed
480 481 482 483
            onPopup: {
                videoWindow.visible = true
                _flightVideo.state = "popup"
            }
484 485
            onNewWidth: {
                _pipSize = newWidth
Jacob Walser's avatar
Jacob Walser committed
486
            }
dogmaphobic's avatar
dogmaphobic committed
487
        }
Don Gagne's avatar
Don Gagne committed
488

489 490 491 492 493 494 495
        Row {
            id:                     singleMultiSelector
            anchors.topMargin:      ScreenTools.toolbarHeight + _margins
            anchors.rightMargin:    _margins
            anchors.right:          parent.right
            anchors.top:            parent.top
            spacing:                ScreenTools.defaultFontPixelWidth
496
            z:                      _mapAndVideo.z + 4
497
            visible:                QGroundControl.multiVehicleManager.vehicles.count > 1 && QGroundControl.corePlugin.options.enableMultiVehicleList
498 499 500 501 502

            QGCRadioButton {
                id:             singleVehicleView
                text:           qsTr("Single")
                checked:        true
503
                textColor:      mapPal.text
504 505 506
            }

            QGCRadioButton {
507
                text:           qsTr("Multi-Vehicle")
508
                textColor:      mapPal.text
509 510 511
            }
        }

512
        FlightDisplayViewWidgets {
513
            id:                 flightDisplayViewWidgets
514 515
            z:                  _mapAndVideo.z + 4
            height:             availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _margins : 0) - (ScreenTools.defaultFontPixelHeight * 0.5)
516
            anchors.left:       parent.left
517
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
518
            anchors.bottom:     parent.bottom
519
            useLightColors:     isBackgroundDark
520
            missionController:  _missionController
521
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
522 523
        }

524 525 526 527 528
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
529
            visible:            !QGroundControl.videoManager.fullScreen
530
            height:             mainWindow.height - mainWindow.header.height
531 532 533 534 535
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
        }

536
        MultiVehicleList {
537 538 539 540 541
            anchors.margins:            _margins
            anchors.top:                singleMultiSelector.bottom
            anchors.right:              parent.right
            anchors.bottom:             parent.bottom
            width:                      ScreenTools.defaultFontPixelWidth * 30
542
            visible:                    !singleVehicleView.checked && !QGroundControl.videoManager.fullScreen && QGroundControl.corePlugin.options.enableMultiVehicleList
543
            z:                          _mapAndVideo.z + 4
544
            guidedActionsController:    _guidedController
545
        }
dogmaphobic's avatar
dogmaphobic committed
546

547
        //-- Virtual Joystick
548
        Loader {
549
            id:                         virtualJoystickMultiTouch
550
            z:                          _mapAndVideo.z + 5
551
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
552
            height:                     Math.min(mainWindow.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
Gus Grubba's avatar
Gus Grubba committed
553
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen && !(activeVehicle ? activeVehicle.highLatencyLink : false)
554 555
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
556
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
557
            source:                     "qrc:/qml/VirtualJoystick.qml"
Gus Grubba's avatar
Gus Grubba committed
558
            active:                     (_virtualJoystick ? _virtualJoystick.value : false) && !(activeVehicle ? activeVehicle.highLatencyLink : false)
Don Gagne's avatar
Don Gagne committed
559

560
            property bool useLightColors: isBackgroundDark
561 562

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
Don Gagne's avatar
Don Gagne committed
563
        }
564 565

        ToolStrip {
Gus Grubba's avatar
Gus Grubba committed
566
            visible:            (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
567
            id:                 toolStrip
568 569

            anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth * 2 : undefined
570
            anchors.left:       isInstrumentRight() ? _mapAndVideo.left : undefined
Gus Grubba's avatar
Gus Grubba committed
571
            anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
572
            anchors.right:      isInstrumentRight() ? undefined : _mapAndVideo.right
573
            anchors.topMargin:  ScreenTools.toolbarHeight + anchors.leftMargin
574 575
            anchors.top:        _mapAndVideo.top
            z:                  _mapAndVideo.z + 4
576
            maxHeight:          (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
577 578 579

            buttonVisible:      [true, _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, _guidedController.showPause, !_guidedController.showPause ]
            buttonEnabled:      [true, _useChecklist && activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
580

581
            property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
582 583
            property var _actionModel: [
                {
584 585 586 587
                    title:      _guidedController.startMissionTitle,
                    text:       _guidedController.startMissionMessage,
                    action:     _guidedController.actionStartMission,
                    visible:    _guidedController.showStartMission
588
                },
Don Gagne's avatar
Don Gagne committed
589 590 591 592 593 594
                {
                    title:      _guidedController.continueMissionTitle,
                    text:       _guidedController.continueMissionMessage,
                    action:     _guidedController.actionContinueMission,
                    visible:    _guidedController.showContinueMission
                },
595
                {
596 597 598 599
                    title:      _guidedController.resumeMissionTitle,
                    text:       _guidedController.resumeMissionMessage,
                    action:     _guidedController.actionResumeMission,
                    visible:    _guidedController.showResumeMission
600 601
                },
                {
602 603 604 605
                    title:      _guidedController.changeAltTitle,
                    text:       _guidedController.changeAltMessage,
                    action:     _guidedController.actionChangeAlt,
                    visible:    _guidedController.showChangeAlt
606 607
                },
                {
608 609 610 611
                    title:      _guidedController.landAbortTitle,
                    text:       _guidedController.landAbortMessage,
                    action:     _guidedController.actionLandAbort,
                    visible:    _guidedController.showLandAbort
612 613 614 615
                }
            ]

            model: [
616
                {
617 618 619 620 621 622
                    name:               "Plan",
                    iconSource:         "/qmlimages/Plan.svg",
                },
                {
                    name:               "Checklist",
                    iconSource:         "/qmlimages/check.svg",
623 624
                    dropPanelComponent: checklistDropPanel
                },
625
                {
626
                    name:       _guidedController.takeoffTitle,
627
                    iconSource: "/res/takeoff.svg",
628
                    action:     _guidedController.actionTakeoff
629 630
                },
                {
631
                    name:       _guidedController.landTitle,
632
                    iconSource: "/res/land.svg",
633
                    action:     _guidedController.actionLand
634 635
                },
                {
636
                    name:       _guidedController.rtlTitle,
637
                    iconSource: "/res/rtl.svg",
638
                    action:     _guidedController.actionRTL
639 640
                },
                {
641
                    name:       _guidedController.pauseTitle,
Gus Grubba's avatar
Gus Grubba committed
642
                    iconSource: "/res/pause-mission.svg",
643
                    action:     _guidedController.actionPause
644 645 646
                },
                {
                    name:       qsTr("Action"),
Gus Grubba's avatar
Gus Grubba committed
647
                    iconSource: "/res/action.svg",
648
                    action:     -1
DonLakeFlyer's avatar
DonLakeFlyer committed
649
                }
650 651 652
            ]

            onClicked: {
653
                guidedActionsController.closeAll()
654 655
                if(index === 0) {
                    mainWindow.showPlanView()
656
                } else {
657 658 659 660 661 662 663
                    var action = model[index].action
                    if (action === -1) {
                        guidedActionList.model   = _actionModel
                        guidedActionList.visible = true
                    } else {
                        _guidedController.confirmAction(action)
                    }
664
                }
665

666 667 668 669
            }
        }

        GuidedActionsController {
670
            id:                 guidedActionsController
671
            missionController:  _missionController
672
            confirmDialog:      guidedActionConfirm
DonLakeFlyer's avatar
DonLakeFlyer committed
673
            actionList:         guidedActionList
Don Gagne's avatar
Don Gagne committed
674
            altitudeSlider:     _altitudeSlider
675 676
            z:                  _flightVideoPipControl.z + 1

677
            onShowStartMissionChanged: {
Don Gagne's avatar
Don Gagne committed
678
                if (showStartMission) {
679 680 681 682
                    confirmAction(actionStartMission)
                }
            }

683 684 685 686 687 688
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

689 690 691 692 693
            onShowLandAbortChanged: {
                if (showLandAbort) {
                    confirmAction(actionLandAbort)
                }
            }
694 695 696 697 698 699 700

            /// Close all dialogs
            function closeAll() {
                guidedActionConfirm.visible = false
                guidedActionList.visible    = false
                altitudeSlider.visible      = false
            }
701 702
        }

703
        GuidedActionConfirm {
704 705 706 707
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
708 709
            guidedController:           _guidedController
            altitudeSlider:             _altitudeSlider
710 711
        }

712
        GuidedActionList {
713 714 715 716
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
717
            guidedController:           _guidedController
718 719 720
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
721
        GuidedAltitudeSlider {
722 723 724 725 726 727
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
728
            z:                  _guidedController.z
729 730 731 732 733
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
734
    }
735

736
    //-- Airspace Indicator
737
    Rectangle {
738 739 740
        id:             airspaceIndicator
        width:          airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
        height:         airspaceRow.height * 1.25
741
        color:          qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
742
        visible:        QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone
743 744 745 746 747 748 749
        radius:         3
        border.width:   1
        border.color:   qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
        anchors.top:    parent.top
        anchors.topMargin: ScreenTools.toolbarHeight + (ScreenTools.defaultFontPixelHeight * 0.25)
        anchors.horizontalCenter: parent.horizontalCenter
        Row {
750
            id: airspaceRow
751 752
            spacing: ScreenTools.defaultFontPixelWidth
            anchors.centerIn: parent
753
            QGCLabel { text: airspaceIndicator.providerName+":"; anchors.verticalCenter: parent.verticalCenter; }
754 755
            QGCLabel {
                text: {
756
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
757
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
758
                            return qsTr("Approval Pending")
759
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
760
                            return qsTr("Flight Approved")
Gus Grubba's avatar
Gus Grubba committed
761
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitRejected)
762
                            return qsTr("Flight Rejected")
763 764 765 766
                    }
                    return ""
                }
                color: {
767
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
768
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
769
                            return qgcPal.colorOrange
770
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
771 772 773 774 775 776 777
                            return qgcPal.colorGreen
                    }
                    return qgcPal.colorRed
                }
                anchors.verticalCenter: parent.verticalCenter;
            }
        }
Gus Grubba's avatar
Gus Grubba committed
778
        property var  flightPermit: QGroundControl.airmapSupported ? QGroundControl.airspaceManager.flightPlan.flightPermitStatus : null
779
        property string  providerName: QGroundControl.airspaceManager.providerName
780 781
    }

782
    //-- Checklist GUI
783 784
    Component {
        id: checklistDropPanel
785 786 787
        PreFlightCheckList {
            model: preFlightCheckModel
        }
788
    }
789
}