FlightDisplayView.qml 34.6 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 45 46 47 48 49 50 51 52 53 54 55 56 57
    property alias  guidedController:              guidedActionsController
    property bool   activeVehicleJoystickEnabled:  activeVehicle ? activeVehicle.joystickEnabled : false
    property bool   mainIsMap:                     QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey,  true) : true
    property bool   isBackgroundDark:              mainIsMap ? (mainWindow.flightDisplayMap ? mainWindow.flightDisplayMap.isSatelliteMap : true) : true

    property var    _missionController:             _planController.missionController
    property var    _geoFenceController:            _planController.geoFenceController
    property var    _rallyPointController:          _planController.rallyPointController
    property bool   _isPipVisible:                  QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false
    property bool   _useChecklist:                  QGroundControl.settingsManager.appSettings.useChecklist.rawValue
    property real   _savedZoomLevel:                0
    property real   _margins:                       ScreenTools.defaultFontPixelWidth / 2
    property real   _pipSize:                       mainWindow.width * 0.2
    property alias  _guidedController:              guidedActionsController
    property alias  _altitudeSlider:                altitudeSlider
58

Gus Grubba's avatar
Gus Grubba committed
59
    readonly property var       _dynamicCameras:        activeVehicle ? activeVehicle.dynamicCameras : null
60
    readonly property bool      _isCamera:              _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
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 74
        QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, mainIsMap)
        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 95 96
            if(mainWindow.flightDisplayMap) {
                _savedZoomLevel = mainWindow.flightDisplayMap.zoomLevel
                mainWindow.flightDisplayMap.zoomLevel = _savedZoomLevel - 3
            }
97
        }
Don Gagne's avatar
Don Gagne committed
98 99
    }

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

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

119
    BuiltInPreFlightCheckModel {
120
        id: preFlightCheckModel
121 122
    }

123
    Connections {
124 125
        target:                     _missionController
        onResumeMissionUploadFail:  guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionUploadFail)
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
        onFlightDisplayMapChanged:      setStates()
141 142
    }

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

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

    onVehicleArmedChanged: {
        if (vehicleArmed) {
            if (!promptForMissionRemove) {
                promptForMissionRemove = vehicleInMissionFlightMode
                vehicleWasArmed = true
            }
        } else {
163
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
164
                // 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
165
                if (!activeVehicle.apmFirmware) {
166
                    mainWindow.showDialog(missionCompleteDialogComponent, qsTr("Flight Plan complete"), mainWindow.showDialogDefaultWidth, StandardButton.Close)
167
                }
168 169 170 171 172 173 174 175 176 177 178 179
            }
            promptForMissionRemove = false
        }
    }

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

    Component {
180 181 182
        id: missionCompleteDialogComponent

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

189 190 191 192
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

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

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

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

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

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

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

233 234 235 236 237 238 239 240 241 242
                        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
243 244
                        }

245 246 247 248 249 250 251 252 253 254 255 256 257 258
                        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
259 260
                    }

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

                        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
272
                    }
273
                }
274 275 276 277
            }
        }
    }

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

        Item {
            id:             videoItem
            anchors.fill:   parent
        }

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

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

312
    QGCMapPalette { id: mapPal; lightColors: mainIsMap ? mainWindow.flightDisplayMap.isSatelliteMap : true }
313

314
    Item {
315
        id:             _mapAndVideo
316 317 318 319 320
        anchors.fill:   parent

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

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

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

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

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

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

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

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

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

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

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

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

562
            property bool useLightColors: isBackgroundDark
563 564

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

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

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

            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 ]
582

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

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

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

668 669 670 671
            }
        }

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

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

685 686 687 688 689 690
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

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

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

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

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

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

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

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