FlightDisplayView.qml 34.5 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
import Wima                         1.0
32 33

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

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

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

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

44 45 46 47 48 49 50
    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
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:               flightView.width * 0.2
55 56
    property alias  _guidedController:      guidedActionsController
    property alias  _altitudeSlider:        altitudeSlider
57

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

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

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

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

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

117 118 119
    WimaController {
        id: wimaController
        Component.onCompleted: {
120
            wimaController.dataContainer = Qt.binding(function() { return dataContainerPointer })
121 122 123
        }
    }

124
    BuiltInPreFlightCheckModel {
125
        id: preFlightCheckModel
126 127
    }

128
    Connections {
129 130
        target:                     _missionController
        onResumeMissionUploadFail:  guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionUploadFail)
131 132
    }

133 134
    Component.onCompleted: {
        setStates()
135 136 137
        if(QGroundControl.corePlugin.options.flyViewOverlay.toString().length) {
            flyViewOverlay.source = QGroundControl.corePlugin.options.flyViewOverlay
        }
138

139 140
        wimaController.masterController     = Qt.binding(function() { return masterController; })
        wimaController.missionController    = Qt.binding(function() { return masterController.missionController; })
141
    }
dogmaphobic's avatar
dogmaphobic committed
142

143 144 145 146 147 148 149 150 151 152 153 154 155 156
    // 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 {
157
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
158 159 160 161
                // 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)
                }
162 163 164 165 166 167 168 169 170 171 172 173
            }
            promptForMissionRemove = false
        }
    }

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

    Component {
174 175 176
        id: missionCompleteDialogComponent

        QGCViewDialog {
177 178 179 180 181 182
            property var activeVehicleCopy: _activeVehicle
            onActiveVehicleCopyChanged:
                if (!activeVehicleCopy) {
                    hideDialog()
                }

183 184 185 186
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

187
                ColumnLayout {
188 189 190 191 192
                    id:                 column
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.right:      parent.right

193
                    ColumnLayout {
194
                        Layout.fillWidth:   true
195 196 197 198 199 200 201 202
                        spacing:            ScreenTools.defaultFontPixelHeight
                        visible:            !_activeVehicle.connectionLost || !_guidedController.showResumeMission

                        QGCLabel {
                            Layout.fillWidth:       true
                            text:                   qsTr("%1 Images Taken").arg(_activeVehicle.cameraTriggerPoints.count)
                            horizontalAlignment:    Text.AlignHCenter
                            visible:                _activeVehicle.cameraTriggerPoints.count != 0
203
                        }
204

205 206 207 208 209 210 211 212
                        QGCButton {
                            Layout.fillWidth:   true
                            text:               qsTr("Remove plan from vehicle")
                            onClicked: {
                                _planMasterController.removeAllFromVehicle()
                                hideDialog()
                            }
                        }
Don Gagne's avatar
Don Gagne committed
213

214 215 216 217 218 219
                        QGCButton {
                            Layout.fillWidth:   true
                            Layout.alignment:   Qt.AlignHCenter
                            text:               qsTr("Leave plan on vehicle")
                            onClicked:          hideDialog()
                        }
Don Gagne's avatar
Don Gagne committed
220

221 222 223 224 225
                        Rectangle {
                            Layout.fillWidth:   true
                            color:              qgcPal.text
                            height:             1
                        }
Don Gagne's avatar
Don Gagne committed
226

227 228 229 230 231 232 233 234 235 236
                        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
237 238
                        }

239 240 241 242 243 244 245 246 247 248 249 250 251 252
                        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
253 254
                    }

255
                    ColumnLayout {
Don Gagne's avatar
Don Gagne committed
256
                        Layout.fillWidth:   true
257 258 259 260 261 262 263 264 265
                        spacing:            ScreenTools.defaultFontPixelHeight
                        visible:            _activeVehicle.connectionLost && _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.")
                        }
Don Gagne's avatar
Don Gagne committed
266
                    }
267
                }
268 269 270 271
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
    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
        }
287
    }
Patrick José Pereira's avatar
Patrick José Pereira committed
288

289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
    /* 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
304 305
    }

306 307
    QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }

308 309 310 311 312 313 314 315 316 317 318 319
    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
320
            visible:        _mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
321 322
            width:          _mainIsMap ? _panel.width  : _pipSize
            height:         _mainIsMap ? _panel.height : _pipSize * (9/16)
323 324 325 326 327 328 329 330 331 332 333 334 335 336
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
337
                }
338 339
            ]
            FlightDisplayViewMap {
340 341
                id:                         _flightMap
                anchors.fill:               parent
342
                planMasterController:       masterController
343
                wimaController:             wimaController
344 345 346 347
                guidedActionsController:    _guidedController
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
                qgcView:                    root
348
                multiVehicleView:           !singleVehicleView.checked
349
                scaleState:                 (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
350
            }
351
        }
352

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

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

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

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

487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
        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
504
                textColor:      mapPal.text
505 506 507 508
            }

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

514 515
        FlightDisplayViewWidgets {
            id:                 flightDisplayViewWidgets
516
            z:                  _panel.z + 4
517
            height:             ScreenTools.availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _margins : 0)
518
            anchors.left:       parent.left
519
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
520
            anchors.bottom:     parent.bottom
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
            qgcView:            root
            useLightColors:     isBackgroundDark
            missionController:  _missionController
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
        }

        FlightDisplayWimaMenu {
            id:                     wimaMenu
            z:                      _panel.z + 4
            anchors.left:           parent.left
            anchors.bottom:         parent.bottom
            anchors.leftMargin:     ScreenTools.defaultFontPixelHeight * 0.25
            anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25


            wimaController: wimaController
537 538
        }

539 540 541 542 543
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
544
            visible:            !QGroundControl.videoManager.fullScreen
545 546 547 548
            height:             ScreenTools.availableHeight
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
549 550

            property var qgcView: root
551 552
        }

553
        MultiVehicleList {
554 555 556 557 558 559 560 561
            anchors.margins:            _margins
            anchors.top:                singleMultiSelector.bottom
            anchors.right:              parent.right
            anchors.bottom:             parent.bottom
            width:                      ScreenTools.defaultFontPixelWidth * 30
            visible:                    !singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
            z:                          _panel.z + 4
            guidedActionsController:    _guidedController
562
        }
dogmaphobic's avatar
dogmaphobic committed
563

564
        //-- Virtual Joystick
565
        Loader {
566
            id:                         virtualJoystickMultiTouch
567 568
            z:                          _panel.z + 5
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
569
            height:                     Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16)
570
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
571 572
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
573
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
574
            source:                     "qrc:/qml/VirtualJoystick.qml"
575
            active:                     (_virtualJoystick ? _virtualJoystick.value : false) && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
Don Gagne's avatar
Don Gagne committed
576

577
            property bool useLightColors: isBackgroundDark
578 579

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
Don Gagne's avatar
Don Gagne committed
580
        }
581 582

        ToolStrip {
583
            visible:            (_activeVehicle ? _activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
584
            id:                 toolStrip
Gus Grubba's avatar
Gus Grubba committed
585 586 587 588
            anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth : undefined
            anchors.left:       isInstrumentRight() ? _panel.left : undefined
            anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
            anchors.right:      isInstrumentRight() ? undefined : _panel.right
589
            anchors.topMargin:  ScreenTools.toolbarHeight + (_margins * 2)
590 591 592 593
            anchors.top:        _panel.top
            z:                  _panel.z + 4
            title:              qsTr("Fly")
            maxHeight:          (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
DonLakeFlyer's avatar
DonLakeFlyer committed
594 595
            buttonVisible:      [ _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ]
            buttonEnabled:      [ _useChecklist && _activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
596

597
            property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
598 599
            property var _actionModel: [
                {
600 601 602 603
                    title:      _guidedController.startMissionTitle,
                    text:       _guidedController.startMissionMessage,
                    action:     _guidedController.actionStartMission,
                    visible:    _guidedController.showStartMission
604
                },
Don Gagne's avatar
Don Gagne committed
605 606 607 608 609 610
                {
                    title:      _guidedController.continueMissionTitle,
                    text:       _guidedController.continueMissionMessage,
                    action:     _guidedController.actionContinueMission,
                    visible:    _guidedController.showContinueMission
                },
611
                {
612 613 614 615
                    title:      _guidedController.resumeMissionTitle,
                    text:       _guidedController.resumeMissionMessage,
                    action:     _guidedController.actionResumeMission,
                    visible:    _guidedController.showResumeMission
616 617
                },
                {
618 619 620 621
                    title:      _guidedController.changeAltTitle,
                    text:       _guidedController.changeAltMessage,
                    action:     _guidedController.actionChangeAlt,
                    visible:    _guidedController.showChangeAlt
622 623
                },
                {
624 625 626 627
                    title:      _guidedController.landAbortTitle,
                    text:       _guidedController.landAbortMessage,
                    action:     _guidedController.actionLandAbort,
                    visible:    _guidedController.showLandAbort
628 629 630 631
                }
            ]

            model: [
632 633 634 635 636
                {
                    name:               "Checklist",
                    iconSource:         "/qmlimages/check.svg",
                    dropPanelComponent: checklistDropPanel
                },
637
                {
638
                    name:       _guidedController.takeoffTitle,
639
                    iconSource: "/res/takeoff.svg",
640
                    action:     _guidedController.actionTakeoff
641 642
                },
                {
643
                    name:       _guidedController.landTitle,
644
                    iconSource: "/res/land.svg",
645
                    action:     _guidedController.actionLand
646 647
                },
                {
648
                    name:       _guidedController.rtlTitle,
649
                    iconSource: "/res/rtl.svg",
650
                    action:     _guidedController.actionRTL
651 652
                },
                {
653
                    name:       _guidedController.pauseTitle,
Gus Grubba's avatar
Gus Grubba committed
654
                    iconSource: "/res/pause-mission.svg",
655
                    action:     _guidedController.actionPause
656 657 658
                },
                {
                    name:       qsTr("Action"),
Gus Grubba's avatar
Gus Grubba committed
659
                    iconSource: "/res/action.svg",
660
                    action:     -1
DonLakeFlyer's avatar
DonLakeFlyer committed
661
                }
662 663 664
            ]

            onClicked: {
665
                guidedActionsController.closeAll()
666 667
                var action = model[index].action
                if (action === -1) {
DonLakeFlyer's avatar
DonLakeFlyer committed
668 669
                    guidedActionList.model   = _actionModel
                    guidedActionList.visible = true
670
                } else {
671
                    _guidedController.confirmAction(action)
672 673 674 675 676
                }
            }
        }

        GuidedActionsController {
677
            id:                 guidedActionsController
678
            missionController:  _missionController
679
            confirmDialog:      guidedActionConfirm
DonLakeFlyer's avatar
DonLakeFlyer committed
680
            actionList:         guidedActionList
Don Gagne's avatar
Don Gagne committed
681
            altitudeSlider:     _altitudeSlider
682 683
            z:                  _flightVideoPipControl.z + 1

684
            onShowStartMissionChanged: {
Don Gagne's avatar
Don Gagne committed
685
                if (showStartMission) {
686 687 688 689
                    confirmAction(actionStartMission)
                }
            }

690 691 692 693 694 695
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

696 697 698 699 700
            onShowLandAbortChanged: {
                if (showLandAbort) {
                    confirmAction(actionLandAbort)
                }
            }
701 702 703

            /// Close all dialogs
            function closeAll() {
704
                mainWindow.enableToolbar()
705 706 707 708 709
                rootLoader.sourceComponent  = null
                guidedActionConfirm.visible = false
                guidedActionList.visible    = false
                altitudeSlider.visible      = false
            }
710 711
        }

712
        GuidedActionConfirm {
713 714 715 716
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
717 718
            guidedController:           _guidedController
            altitudeSlider:             _altitudeSlider
719 720
        }

721
        GuidedActionList {
722 723 724 725
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
726
            guidedController:           _guidedController
727 728 729
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
730
        GuidedAltitudeSlider {
731 732 733 734 735 736
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
737
            z:                  _guidedController.z
738 739 740 741 742
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
743
    }
744

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

791
    //-- Checklist GUI
792 793
    Component {
        id: checklistDropPanel
794 795 796
        PreFlightCheckList {
            model: preFlightCheckModel
        }
797
    }
798
}