FlightDisplayView.qml 34.9 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 13
import QtQuick                  2.11
import QtQuick.Controls         2.4
import QtQuick.Dialogs          1.3
import QtQuick.Layouts          1.11
14

15 16
import QtLocation               5.3
import QtPositioning            5.3
Patrick José Pereira's avatar
Patrick José Pereira committed
17
import QtQuick.Window           2.2
18
import QtQml.Models             2.1
19

20
import QGroundControl               1.0
21 22 23 24
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
25
import QGroundControl.FlightDisplay 1.0
26 27
import QGroundControl.FlightMap     1.0
import QGroundControl.Palette       1.0
28
import QGroundControl.ScreenTools   1.0
29
import QGroundControl.Vehicle       1.0
30 31

/// Flight Display View
32
Item {
33

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

42 43 44 45 46 47 48 49 50
    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
51
    property bool   _useChecklist:                  QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
52 53 54 55
    property real   _margins:                       ScreenTools.defaultFontPixelWidth / 2
    property real   _pipSize:                       mainWindow.width * 0.2
    property alias  _guidedController:              guidedActionsController
    property alias  _altitudeSlider:                altitudeSlider
56
    property real   _toolsMargin:                   ScreenTools.defaultFontPixelWidth * 0.75
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
Don Gagne's avatar
Don Gagne committed
60 61 62 63 64 65 66 67 68 69 70
    readonly property real      _defaultRoll:           0
    readonly property real      _defaultPitch:          0
    readonly property real      _defaultHeading:        0
    readonly property real      _defaultAltitudeAMSL:   0
    readonly property real      _defaultGroundSpeed:    0
    readonly property real      _defaultAirSpeed:       0
    readonly property string    _mapName:               "FlightDisplayView"
    readonly property string    _showMapBackgroundKey:  "/showMapBackground"
    readonly property string    _mainIsMapKey:          "MainFlyWindowIsMap"
    readonly property string    _PIPVisibleKey:         "IsPIPVisible"

71
    function setStates() {
72 73
        QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, mainIsMap)
        if(mainIsMap) {
74 75 76
            //-- Adjust Margins
            _flightMapContainer.state   = "fullMode"
            _flightVideo.state          = "pipMode"
77
        } else {
78 79 80
            //-- Adjust Margins
            _flightMapContainer.state   = "pipMode"
            _flightVideo.state          = "fullMode"
81
        }
Don Gagne's avatar
Don Gagne committed
82 83
    }

84 85 86
    function setPipVisibility(state) {
        _isPipVisible = state;
        QGroundControl.saveBoolGlobalSetting(_PIPVisibleKey, state)
87 88
    }

Gus Grubba's avatar
Gus Grubba committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102
    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;
    }

103
    Connections {
104 105
        target:                     _missionController
        onResumeMissionUploadFail:  guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionUploadFail)
106 107
    }

108 109 110 111 112 113 114 115 116 117 118 119
    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)
120
        onFlightDisplayMapChanged:      setStates()
121 122
    }

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

132 133 134 135 136 137 138 139
    // The following code is used to track vehicle states for showing the mission complete dialog
    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 vehicleWasInMissionFlightMode:    false
    property bool showMissionCompleteDialog:        vehicleWasArmed && vehicleWasInMissionFlightMode &&
                                                        (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems ||
                                                        (activeVehicle ? activeVehicle.cameraTriggerPoints.count !== 0 : false))
140 141 142

    onVehicleArmedChanged: {
        if (vehicleArmed) {
143 144
            vehicleWasArmed = true
            vehicleWasInMissionFlightMode = vehicleInMissionFlightMode
145
        } else {
146 147
            if (showMissionCompleteDialog) {
                mainWindow.showComponentDialog(missionCompleteDialogComponent, qsTr("Flight Plan complete"), mainWindow.showDialogDefaultWidth, StandardButton.Close)
148
            }
149 150
            vehicleWasArmed = false
            vehicleWasInMissionFlightMode = false
151 152 153 154
        }
    }

    onVehicleInMissionFlightModeChanged: {
155 156
        if (vehicleInMissionFlightMode && vehicleArmed) {
            vehicleWasInMissionFlightMode = true
157 158 159 160
        }
    }

    Component {
161 162 163
        id: missionCompleteDialogComponent

        QGCViewDialog {
Gus Grubba's avatar
Gus Grubba committed
164
            property var activeVehicleCopy: activeVehicle
165 166 167 168 169
            onActiveVehicleCopyChanged:
                if (!activeVehicleCopy) {
                    hideDialog()
                }

170 171 172 173
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

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

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

188 189 190 191 192 193 194
                    QGCButton {
                        Layout.fillWidth:   true
                        text:               qsTr("Remove plan from vehicle")
                        visible:            !activeVehicle.connectionLost// && !activeVehicle.apmFirmware  // ArduPilot has a bug somewhere with mission clear
                        onClicked: {
                            _planController.removeAllFromVehicle()
                            hideDialog()
195
                        }
196
                    }
197

198 199 200 201 202 203
                    QGCButton {
                        Layout.fillWidth:   true
                        Layout.alignment:   Qt.AlignHCenter
                        text:               qsTr("Leave plan on vehicle")
                        onClicked:          hideDialog()
                    }
Don Gagne's avatar
Don Gagne committed
204

205 206 207 208 209
                    Rectangle {
                        Layout.fillWidth:   true
                        color:              qgcPal.text
                        height:             1
                    }
Don Gagne's avatar
Don Gagne committed
210

211 212 213 214
                    ColumnLayout {
                        Layout.fillWidth:   true
                        spacing:            ScreenTools.defaultFontPixelHeight
                        visible:            !activeVehicle.connectionLost && _guidedController.showResumeMission
Don Gagne's avatar
Don Gagne committed
215

216 217 218 219 220 221 222 223 224
                        QGCButton {
                            Layout.fillWidth:   true
                            Layout.alignment:   Qt.AlignHCenter
                            text:               qsTr("Resume Mission From Waypoint %1").arg(_guidedController._resumeMissionIndex)

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

227 228 229 230 231
                        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.")
                        }
Don Gagne's avatar
Don Gagne committed
232 233
                    }

234
                    QGCLabel {
Don Gagne's avatar
Don Gagne committed
235
                        Layout.fillWidth:   true
236 237 238 239
                        wrapMode:           Text.WordWrap
                        color:              qgcPal.warningText
                        text:               qsTr("If you are changing batteries for Resume Mission do not disconnect from the vehicle.")
                        visible:            _guidedController.showResumeMission
Don Gagne's avatar
Don Gagne committed
240
                    }
241
                }
242 243 244 245
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
246 247
    Window {
        id:             videoWindow
248 249
        width:          !mainIsMap ? _mapAndVideo.width  : _pipSize
        height:         !mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
Patrick José Pereira's avatar
Patrick José Pereira committed
250 251 252 253 254 255 256 257 258 259 260
        visible:        false

        Item {
            id:             videoItem
            anchors.fill:   parent
        }

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

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
    /* 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
278 279
    }

280
    QGCMapPalette { id: mapPal; lightColors: mainIsMap ? mainWindow.flightDisplayMap.isSatelliteMap : true }
281

282
    Item {
283
        id:             _mapAndVideo
284
        anchors.fill:   parent
285 286 287 288

        //-- Map View
        Item {
            id: _flightMapContainer
289
            z:  mainIsMap ? _mapAndVideo.z + 1 : _mapAndVideo.z + 2
290 291
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
292 293 294
            visible:        mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
            width:          mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
295 296 297 298 299 300 301 302 303 304 305 306 307 308
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
309
                }
310 311
            ]
            FlightDisplayViewMap {
312
                id:                         _fMap
313 314
                anchors.fill:               parent
                guidedActionsController:    _guidedController
Gus Grubba's avatar
Gus Grubba committed
315
                missionController:          _planController
316 317
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
318
                multiVehicleView:           !singleVehicleView.checked
319
                scaleState:                 (mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
320 321
                Component.onCompleted: {
                    mainWindow.flightDisplayMap = _fMap
322
                    _fMap.adjustMapSize()
323
                }
324
            }
325
        }
326

327
        //-- Video View
328
        Item {
329
            id:             _flightVideo
330 331 332
            z:              mainIsMap ? _mapAndVideo.z + 2 : _mapAndVideo.z + 1
            width:          !mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         !mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
333 334
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
335
            visible:        QGroundControl.videoManager.hasVideo && (!mainIsMap || _isPipVisible)
336 337 338 339 340 341

            onParentChanged: {
                /* If video comes back from popup
                 * correct anchors.
                 * Such thing is not possible with ParentChange.
                 */
342
                if(parent == _mapAndVideo) {
343
                    // Do anchors again after popup
344 345
                    anchors.left =       _mapAndVideo.left
                    anchors.bottom =     _mapAndVideo.bottom
346
                    anchors.margins =    _toolsMargin
347 348 349
                }
            }

350 351 352 353
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
354
                        target:             _flightVideo
355
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
Patrick José Pereira's avatar
Patrick José Pereira committed
356 357
                    }
                    PropertyChanges {
358 359
                        target:             _flightVideoPipControl
                        inPopup:            false
360 361 362 363 364
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
365
                        target:             _flightVideo
366 367
                        anchors.margins:    0
                    }
Patrick José Pereira's avatar
Patrick José Pereira committed
368
                    PropertyChanges {
369 370
                        target:             _flightVideoPipControl
                        inPopup:            false
Patrick José Pereira's avatar
Patrick José Pereira committed
371 372 373 374 375
                    }
                },
                State {
                    name: "popup"
                    StateChangeScript {
376 377
                        script: {
                            // Stop video, restart it again with Timer
Gus Grubba's avatar
Gus Grubba committed
378
                            // Avoiding crashes if ParentChange is not yet done
379 380 381
                            QGroundControl.videoManager.stopVideo()
                            videoPopUpTimer.running = true
                        }
Patrick José Pereira's avatar
Patrick José Pereira committed
382
                    }
383
                    PropertyChanges {
384 385
                        target:             _flightVideoPipControl
                        inPopup:            true
386 387 388 389
                    }
                },
                State {
                    name: "popup-finished"
Patrick José Pereira's avatar
Patrick José Pereira committed
390
                    ParentChange {
391 392 393 394 395 396
                        target:             _flightVideo
                        parent:             videoItem
                        x:                  0
                        y:                  0
                        width:              videoItem.width
                        height:             videoItem.height
Patrick José Pereira's avatar
Patrick José Pereira committed
397 398 399 400 401
                    }
                },
                State {
                    name: "unpopup"
                    StateChangeScript {
402 403 404 405
                        script: {
                            QGroundControl.videoManager.stopVideo()
                            videoPopUpTimer.running = true
                        }
Patrick José Pereira's avatar
Patrick José Pereira committed
406 407
                    }
                    ParentChange {
408 409
                        target:             _flightVideo
                        parent:             _mapAndVideo
Patrick José Pereira's avatar
Patrick José Pereira committed
410 411
                    }
                    PropertyChanges {
412 413
                        target:             _flightVideoPipControl
                        inPopup:             false
Patrick José Pereira's avatar
Patrick José Pereira committed
414
                    }
415
                }
416
            ]
417
            //-- Video Streaming
418
            FlightDisplayViewVideo {
Patrick José Pereira's avatar
Patrick José Pereira committed
419
                id:             videoStreaming
420 421 422 423
                anchors.fill:   parent
                visible:        QGroundControl.videoManager.isGStreamer
            }
            //-- UVC Video (USB Camera or Video Device)
424 425
            Loader {
                id:             cameraLoader
426 427
                anchors.fill:   parent
                visible:        !QGroundControl.videoManager.isGStreamer
428
                source:         visible ? (QGroundControl.videoManager.uvcEnabled ? "qrc:/qml/FlightDisplayViewUVC.qml" : "qrc:/qml/FlightDisplayViewDummy.qml") : ""
429
            }
dogmaphobic's avatar
dogmaphobic committed
430
        }
431 432 433 434

        QGCPipable {
            id:                 _flightVideoPipControl
            z:                  _flightVideo.z + 3
435 436
            width:              _pipSize
            height:             _pipSize * (9/16)
437 438
            anchors.left:       _mapAndVideo.left
            anchors.bottom:     _mapAndVideo.bottom
439
            anchors.margins:    ScreenTools.defaultFontPixelHeight
440
            visible:            QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen && _flightVideo.state != "popup"
441 442
            isHidden:           !_isPipVisible
            isDark:             isBackgroundDark
443
            enablePopup:        mainIsMap
444
            onActivated: {
445
                mainIsMap = !mainIsMap
446
                setStates()
447
                _fMap.adjustMapSize()
448 449 450 451
            }
            onHideIt: {
                setPipVisibility(!state)
            }
Patrick José Pereira's avatar
Patrick José Pereira committed
452 453 454 455
            onPopup: {
                videoWindow.visible = true
                _flightVideo.state = "popup"
            }
456 457
            onNewWidth: {
                _pipSize = newWidth
Jacob Walser's avatar
Jacob Walser committed
458
            }
dogmaphobic's avatar
dogmaphobic committed
459
        }
Don Gagne's avatar
Don Gagne committed
460

461 462
        Row {
            id:                     singleMultiSelector
463 464
            anchors.topMargin:      ScreenTools.toolbarHeight + _toolsMargin
            anchors.rightMargin:    _toolsMargin
465 466
            anchors.right:          parent.right
            spacing:                ScreenTools.defaultFontPixelWidth
467
            z:                      _mapAndVideo.z + 4
468
            visible:                QGroundControl.multiVehicleManager.vehicles.count > 1 && QGroundControl.corePlugin.options.enableMultiVehicleList
469 470 471 472 473

            QGCRadioButton {
                id:             singleVehicleView
                text:           qsTr("Single")
                checked:        true
474
                textColor:      mapPal.text
475 476 477
            }

            QGCRadioButton {
478
                text:           qsTr("Multi-Vehicle")
479
                textColor:      mapPal.text
480 481 482
            }
        }

483
        FlightDisplayViewWidgets {
484
            id:                 flightDisplayViewWidgets
485
            z:                  _mapAndVideo.z + 4
486
            height:             availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _toolsMargin : 0) - _toolsMargin
487
            anchors.left:       parent.left
488
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
489
            anchors.bottom:     parent.bottom
490
            anchors.top:        singleMultiSelector.visible? singleMultiSelector.bottom : undefined
491
            useLightColors:     isBackgroundDark
492
            missionController:  _missionController
493
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
494 495
        }

496 497 498 499 500
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
501
            visible:            !QGroundControl.videoManager.fullScreen
502
            height:             mainWindow.height - mainWindow.header.height
503 504 505 506 507
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
        }

508
        MultiVehicleList {
509
            anchors.margins:            _toolsMargin
510 511 512 513
            anchors.top:                singleMultiSelector.bottom
            anchors.right:              parent.right
            anchors.bottom:             parent.bottom
            width:                      ScreenTools.defaultFontPixelWidth * 30
514
            visible:                    !singleVehicleView.checked && !QGroundControl.videoManager.fullScreen && QGroundControl.corePlugin.options.enableMultiVehicleList
515
            z:                          _mapAndVideo.z + 4
516
            guidedActionsController:    _guidedController
517
        }
dogmaphobic's avatar
dogmaphobic committed
518

519
        //-- Virtual Joystick
520
        Loader {
521
            id:                         virtualJoystickMultiTouch
522
            z:                          _mapAndVideo.z + 5
523
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
524
            height:                     Math.min(mainWindow.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
Gus Grubba's avatar
Gus Grubba committed
525
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen && !(activeVehicle ? activeVehicle.highLatencyLink : false)
526 527
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
528
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
529
            source:                     "qrc:/qml/VirtualJoystick.qml"
Gus Grubba's avatar
Gus Grubba committed
530
            active:                     (_virtualJoystick ? _virtualJoystick.value : false) && !(activeVehicle ? activeVehicle.highLatencyLink : false)
Don Gagne's avatar
Don Gagne committed
531

532
            property bool useLightColors: isBackgroundDark
533 534
            // The default behaviour is not centralized throttle
            property bool centralizeThrottle: _virtualJoystickCentralized ? _virtualJoystickCentralized.value : false
535 536

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
537
            property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized
Don Gagne's avatar
Don Gagne committed
538
        }
539 540

        ToolStrip {
Gus Grubba's avatar
Gus Grubba committed
541
            visible:            (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
542
            id:                 toolStrip
543

544
            anchors.leftMargin: isInstrumentRight() ? _toolsMargin : undefined
545
            anchors.left:       isInstrumentRight() ? _mapAndVideo.left : undefined
Gus Grubba's avatar
Gus Grubba committed
546
            anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
547
            anchors.right:      isInstrumentRight() ? undefined : _mapAndVideo.right
548
            anchors.topMargin:  _toolsMargin
549
            anchors.top:        parent.top
550
            z:                  _mapAndVideo.z + 4
551
            maxHeight:          parent.height - toolStrip.y + (_flightVideo.visible ? (_flightVideo.y - parent.height) : 0)
552

553
            property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
554 555
            property var _actionModel: [
                {
556 557 558 559
                    title:      _guidedController.startMissionTitle,
                    text:       _guidedController.startMissionMessage,
                    action:     _guidedController.actionStartMission,
                    visible:    _guidedController.showStartMission
560
                },
Don Gagne's avatar
Don Gagne committed
561 562 563 564 565 566
                {
                    title:      _guidedController.continueMissionTitle,
                    text:       _guidedController.continueMissionMessage,
                    action:     _guidedController.actionContinueMission,
                    visible:    _guidedController.showContinueMission
                },
567
                {
568 569 570 571
                    title:      _guidedController.changeAltTitle,
                    text:       _guidedController.changeAltMessage,
                    action:     _guidedController.actionChangeAlt,
                    visible:    _guidedController.showChangeAlt
572 573
                },
                {
574 575 576 577
                    title:      _guidedController.landAbortTitle,
                    text:       _guidedController.landAbortMessage,
                    action:     _guidedController.actionLandAbort,
                    visible:    _guidedController.showLandAbort
578 579 580 581
                }
            ]

            model: [
582
                /*{
583 584
                    name:               "Plan",
                    iconSource:         "/qmlimages/Plan.svg",
Gus Grubba's avatar
Gus Grubba committed
585 586
                    buttonVisible:      true,
                    buttonEnabled:      true,
587
                },*/
588 589 590
                {
                    name:               "Checklist",
                    iconSource:         "/qmlimages/check.svg",
Gus Grubba's avatar
Gus Grubba committed
591 592
                    buttonVisible:      _useChecklist,
                    buttonEnabled:      _useChecklist && activeVehicle && !activeVehicle.armed,
593
                },
594
                {
Gus Grubba's avatar
Gus Grubba committed
595 596 597 598 599
                    name:               _guidedController.takeoffTitle,
                    iconSource:         "/res/takeoff.svg",
                    buttonVisible:      _guidedController.showTakeoff || !_guidedController.showLand,
                    buttonEnabled:      _guidedController.showTakeoff,
                    action:             _guidedController.actionTakeoff
600 601
                },
                {
Gus Grubba's avatar
Gus Grubba committed
602 603 604 605 606
                    name:               _guidedController.landTitle,
                    iconSource:         "/res/land.svg",
                    buttonVisible:      _guidedController.showLand && !_guidedController.showTakeoff,
                    buttonEnabled:      _guidedController.showLand,
                    action:             _guidedController.actionLand
607 608
                },
                {
Gus Grubba's avatar
Gus Grubba committed
609 610 611 612 613
                    name:               _guidedController.rtlTitle,
                    iconSource:         "/res/rtl.svg",
                    buttonVisible:      true,
                    buttonEnabled:      _guidedController.showRTL,
                    action:             _guidedController.actionRTL
614 615
                },
                {
Gus Grubba's avatar
Gus Grubba committed
616 617 618 619 620
                    name:               _guidedController.pauseTitle,
                    iconSource:         "/res/pause-mission.svg",
                    buttonVisible:      _guidedController.showPause,
                    buttonEnabled:      _guidedController.showPause,
                    action:             _guidedController.actionPause
621 622
                },
                {
Gus Grubba's avatar
Gus Grubba committed
623 624 625 626 627
                    name:               qsTr("Action"),
                    iconSource:         "/res/action.svg",
                    buttonVisible:      !_guidedController.showPause,
                    buttonEnabled:      _anyActionAvailable,
                    action:             -1
DonLakeFlyer's avatar
DonLakeFlyer committed
628
                }
629 630 631
            ]

            onClicked: {
632
                guidedActionsController.closeAll()
633
                /*if(index === 0) {
634
                    mainWindow.showPlanView()
635 636
                } else*/
                if(index === 0) {
637
                    checklistDropPanel.open()
638
                } else {
639 640 641 642 643 644 645
                    var action = model[index].action
                    if (action === -1) {
                        guidedActionList.model   = _actionModel
                        guidedActionList.visible = true
                    } else {
                        _guidedController.confirmAction(action)
                    }
646
                }
647

648 649 650 651
            }
        }

        GuidedActionsController {
652
            id:                 guidedActionsController
653
            missionController:  _missionController
654
            confirmDialog:      guidedActionConfirm
DonLakeFlyer's avatar
DonLakeFlyer committed
655
            actionList:         guidedActionList
Don Gagne's avatar
Don Gagne committed
656
            altitudeSlider:     _altitudeSlider
657 658
            z:                  _flightVideoPipControl.z + 1

659
            onShowStartMissionChanged: {
Don Gagne's avatar
Don Gagne committed
660
                if (showStartMission) {
661 662 663 664
                    confirmAction(actionStartMission)
                }
            }

665 666 667 668 669 670
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

671 672 673 674 675
            onShowLandAbortChanged: {
                if (showLandAbort) {
                    confirmAction(actionLandAbort)
                }
            }
676 677 678 679 680 681 682

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

685
        GuidedActionConfirm {
686 687 688 689
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
690 691
            guidedController:           _guidedController
            altitudeSlider:             _altitudeSlider
692 693
        }

694
        GuidedActionList {
695 696 697 698
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
699
            guidedController:           _guidedController
700 701 702
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
703
        GuidedAltitudeSlider {
704 705 706 707 708 709
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
710
            z:                  _guidedController.z
711 712 713 714 715
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
716
    }
717

718
    //-- Airspace Indicator
719
    Rectangle {
720 721 722
        id:             airspaceIndicator
        width:          airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
        height:         airspaceRow.height * 1.25
723
        color:          qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
724
        visible:        QGroundControl.airmapSupported && mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone
725 726 727 728 729 730 731
        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 {
732
            id: airspaceRow
733 734
            spacing: ScreenTools.defaultFontPixelWidth
            anchors.centerIn: parent
735
            QGCLabel { text: airspaceIndicator.providerName+":"; anchors.verticalCenter: parent.verticalCenter; }
736 737
            QGCLabel {
                text: {
738
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
739
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
740
                            return qsTr("Approval Pending")
741
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
742
                            return qsTr("Flight Approved")
Gus Grubba's avatar
Gus Grubba committed
743
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitRejected)
744
                            return qsTr("Flight Rejected")
745 746 747 748
                    }
                    return ""
                }
                color: {
749
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
750
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
751
                            return qgcPal.colorOrange
752
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
753 754 755 756 757 758 759
                            return qgcPal.colorGreen
                    }
                    return qgcPal.colorRed
                }
                anchors.verticalCenter: parent.verticalCenter;
            }
        }
Gus Grubba's avatar
Gus Grubba committed
760
        property var  flightPermit: QGroundControl.airmapSupported ? QGroundControl.airspaceManager.flightPlan.flightPermitStatus : null
761
        property string  providerName: QGroundControl.airspaceManager.providerName
762 763
    }

764
    //-- Checklist GUI
765 766 767 768
    Popup {
        id:             checklistDropPanel
        x:              Math.round((mainWindow.width  - width)  * 0.5)
        y:              Math.round((mainWindow.height - height) * 0.5)
Gus Grubba's avatar
Gus Grubba committed
769 770
        height:         checkList.height
        width:          checkList.width
771 772 773 774
        modal:          true
        focus:          true
        closePolicy:    Popup.CloseOnEscape | Popup.CloseOnPressOutside
        background: Rectangle {
775 776 777
            anchors.fill:  parent
            color:      Qt.rgba(0,0,0,0)
            clip:       true
778
        }
779 780 781
        Loader {
            id:         checkList
            anchors.centerIn: parent
782
        }
783
    }
784

785
}