FlightDisplayView.qml 30.7 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * 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
    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
50
    property bool   _useChecklist:                  QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
51
    property bool   _enforceChecklist:              _useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue
52
    property bool   _checklistComplete:             activeVehicle && (activeVehicle.checkListState === Vehicle.CheckListPassed)
53 54 55
    property real   _margins:                       ScreenTools.defaultFontPixelWidth / 2
    property real   _pipSize:                       mainWindow.width * 0.2
    property alias  _guidedController:              guidedActionsController
56 57 58 59
    property alias  _guidedConfirm:                 guidedActionConfirm
    property alias  _guidedList:                    guidedActionList
    property alias  _guidedSlider:                  altitudeSlider
    property real   _guidedZOrder:                  _flightVideoPipControl.z + 1
60
    property real   _toolsMargin:                   ScreenTools.defaultFontPixelWidth * 0.75
61

Don Gagne's avatar
Don Gagne committed
62 63 64 65 66
    readonly property string    _mapName:               "FlightDisplayView"
    readonly property string    _showMapBackgroundKey:  "/showMapBackground"
    readonly property string    _mainIsMapKey:          "MainFlyWindowIsMap"
    readonly property string    _PIPVisibleKey:         "IsPIPVisible"

67 68 69 70 71 72 73 74 75 76 77 78 79 80
    Timer {
        id:             checklistPopupTimer
        interval:       1000
        repeat:         false
        onTriggered: {
            if (visible && !_checklistComplete) {
                checklistDropPanel.open()
            }
            else {
                checklistDropPanel.close()
            }
        }
    }

81
    function setStates() {
82 83
        QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, mainIsMap)
        if(mainIsMap) {
84 85 86
            //-- Adjust Margins
            _flightMapContainer.state   = "fullMode"
            _flightVideo.state          = "pipMode"
87
        } else {
88 89 90
            //-- Adjust Margins
            _flightMapContainer.state   = "pipMode"
            _flightVideo.state          = "fullMode"
91
        }
Don Gagne's avatar
Don Gagne committed
92 93
    }

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

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

113 114 115 116 117 118
    function showPreflightChecklistIfNeeded () {
        if (activeVehicle && !_checklistComplete && _enforceChecklist) {
            checklistPopupTimer.restart()
        }
    }

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

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

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

148 149 150 151 152 153 154 155
    // 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))
156 157 158

    onVehicleArmedChanged: {
        if (vehicleArmed) {
159 160
            vehicleWasArmed = true
            vehicleWasInMissionFlightMode = vehicleInMissionFlightMode
161
        } else {
162 163
            if (showMissionCompleteDialog) {
                mainWindow.showComponentDialog(missionCompleteDialogComponent, qsTr("Flight Plan complete"), mainWindow.showDialogDefaultWidth, StandardButton.Close)
164
            }
165 166
            vehicleWasArmed = false
            vehicleWasInMissionFlightMode = false
167 168 169 170
        }
    }

    onVehicleInMissionFlightModeChanged: {
171 172
        if (vehicleInMissionFlightMode && vehicleArmed) {
            vehicleWasInMissionFlightMode = true
173 174 175 176
        }
    }

    Component {
177 178 179
        id: missionCompleteDialogComponent

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

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

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

197 198 199 200 201 202
                    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
                    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()
211
                        }
212
                    }
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
                    ColumnLayout {
                        Layout.fillWidth:   true
                        spacing:            ScreenTools.defaultFontPixelHeight
                        visible:            !activeVehicle.connectionLost && _guidedController.showResumeMission
Don Gagne's avatar
Don Gagne committed
231

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

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

243 244 245 246 247
                        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
248 249
                    }

250
                    QGCLabel {
Don Gagne's avatar
Don Gagne committed
251
                        Layout.fillWidth:   true
252 253 254 255
                        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
256
                    }
257
                }
258 259 260 261
            }
        }
    }

Patrick José Pereira's avatar
Patrick José Pereira committed
262 263
    Window {
        id:             videoWindow
264 265
        width:          !mainIsMap ? _mapAndVideo.width  : _pipSize
        height:         !mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
Patrick José Pereira's avatar
Patrick José Pereira committed
266 267 268 269 270 271 272 273 274 275 276
        visible:        false

        Item {
            id:             videoItem
            anchors.fill:   parent
        }

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

279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
    /* 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
294 295
    }

296
    QGCMapPalette { id: mapPal; lightColors: mainIsMap ? mainWindow.flightDisplayMap.isSatelliteMap : true }
297

298
    Item {
299
        id:             _mapAndVideo
300
        anchors.fill:   parent
301 302 303 304

        //-- Map View
        Item {
            id: _flightMapContainer
305
            z:  mainIsMap ? _mapAndVideo.z + 1 : _mapAndVideo.z + 2
306 307
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
308 309 310
            visible:        mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
            width:          mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
311 312 313 314 315 316 317 318 319 320 321 322 323 324
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
325
                }
326 327
            ]
            FlightDisplayViewMap {
328
                id:                         _fMap
329 330
                anchors.fill:               parent
                guidedActionsController:    _guidedController
Gus Grubba's avatar
Gus Grubba committed
331
                missionController:          _planController
332 333
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
334
                multiVehicleView:           !singleVehicleView.checked
335
                scaleState:                 (mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
336 337
                Component.onCompleted: {
                    mainWindow.flightDisplayMap = _fMap
338
                    _fMap.adjustMapSize()
339
                }
340
            }
341
        }
342

343
        //-- Video View
344
        Item {
345
            id:             _flightVideo
346 347 348
            z:              mainIsMap ? _mapAndVideo.z + 2 : _mapAndVideo.z + 1
            width:          !mainIsMap ? _mapAndVideo.width  : _pipSize
            height:         !mainIsMap ? _mapAndVideo.height : _pipSize * (9/16)
349 350
            anchors.left:   _mapAndVideo.left
            anchors.bottom: _mapAndVideo.bottom
351
            visible:        QGroundControl.videoManager.hasVideo && (!mainIsMap || _isPipVisible)
352 353 354 355 356 357

            onParentChanged: {
                /* If video comes back from popup
                 * correct anchors.
                 * Such thing is not possible with ParentChange.
                 */
358
                if(parent == _mapAndVideo) {
359
                    // Do anchors again after popup
360 361
                    anchors.left =       _mapAndVideo.left
                    anchors.bottom =     _mapAndVideo.bottom
362
                    anchors.margins =    _toolsMargin
363 364 365
                }
            }

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

        QGCPipable {
            id:                 _flightVideoPipControl
            z:                  _flightVideo.z + 3
451 452
            width:              _pipSize
            height:             _pipSize * (9/16)
453 454
            anchors.left:       _mapAndVideo.left
            anchors.bottom:     _mapAndVideo.bottom
455
            anchors.margins:    ScreenTools.defaultFontPixelHeight
456
            visible:            QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen && _flightVideo.state != "popup"
457 458
            isHidden:           !_isPipVisible
            isDark:             isBackgroundDark
459
            enablePopup:        mainIsMap
460
            onActivated: {
461
                mainIsMap = !mainIsMap
462
                setStates()
463
                _fMap.adjustMapSize()
464 465 466 467
            }
            onHideIt: {
                setPipVisibility(!state)
            }
Patrick José Pereira's avatar
Patrick José Pereira committed
468 469 470 471
            onPopup: {
                videoWindow.visible = true
                _flightVideo.state = "popup"
            }
472 473
            onNewWidth: {
                _pipSize = newWidth
Jacob Walser's avatar
Jacob Walser committed
474
            }
dogmaphobic's avatar
dogmaphobic committed
475
        }
Don Gagne's avatar
Don Gagne committed
476

477 478
        Row {
            id:                     singleMultiSelector
479 480
            anchors.topMargin:      ScreenTools.toolbarHeight + _toolsMargin
            anchors.rightMargin:    _toolsMargin
481 482
            anchors.right:          parent.right
            spacing:                ScreenTools.defaultFontPixelWidth
483
            z:                      _mapAndVideo.z + 4
484
            visible:                QGroundControl.multiVehicleManager.vehicles.count > 1 && QGroundControl.corePlugin.options.enableMultiVehicleList
485 486 487 488 489

            QGCRadioButton {
                id:             singleVehicleView
                text:           qsTr("Single")
                checked:        true
490
                textColor:      mapPal.text
491 492 493
            }

            QGCRadioButton {
494
                text:           qsTr("Multi-Vehicle")
495
                textColor:      mapPal.text
496 497 498
            }
        }

499
        FlightDisplayViewWidgets {
500
            id:                 flightDisplayViewWidgets
501
            z:                  _mapAndVideo.z + 4
502
            height:             availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _toolsMargin : 0) - _toolsMargin
503
            anchors.left:       parent.left
504
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
505
            anchors.bottom:     parent.bottom
506
            anchors.top:        singleMultiSelector.visible? singleMultiSelector.bottom : undefined
507
            useLightColors:     isBackgroundDark
508
            missionController:  _missionController
509
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
510 511
        }

512 513 514 515 516
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
517
            visible:            !QGroundControl.videoManager.fullScreen
518
            height:             mainWindow.height - mainWindow.header.height
519 520 521 522 523
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
        }

524
        MultiVehicleList {
525
            anchors.margins:            _toolsMargin
526 527 528 529
            anchors.top:                singleMultiSelector.bottom
            anchors.right:              parent.right
            anchors.bottom:             parent.bottom
            width:                      ScreenTools.defaultFontPixelWidth * 30
530
            visible:                    !singleVehicleView.checked && !QGroundControl.videoManager.fullScreen && QGroundControl.corePlugin.options.enableMultiVehicleList
531
            z:                          _mapAndVideo.z + 4
532
            guidedActionsController:    _guidedController
533
        }
dogmaphobic's avatar
dogmaphobic committed
534

535
        //-- Virtual Joystick
536
        Loader {
537
            id:                         virtualJoystickMultiTouch
538
            z:                          _mapAndVideo.z + 5
539
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
540
            height:                     Math.min(mainWindow.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
Gus Grubba's avatar
Gus Grubba committed
541
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen && !(activeVehicle ? activeVehicle.highLatencyLink : false)
542 543
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
544
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
545
            source:                     "qrc:/qml/VirtualJoystick.qml"
Gus Grubba's avatar
Gus Grubba committed
546
            active:                     (_virtualJoystick ? _virtualJoystick.value : false) && !(activeVehicle ? activeVehicle.highLatencyLink : false)
Don Gagne's avatar
Don Gagne committed
547

548
            property bool useLightColors: isBackgroundDark
549 550
            // The default behaviour is not centralized throttle
            property bool centralizeThrottle: _virtualJoystickCentralized ? _virtualJoystickCentralized.value : false
551 552

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
553
            property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized
Don Gagne's avatar
Don Gagne committed
554
        }
555

556 557 558 559 560 561 562 563 564 565 566 567 568 569
        FlyViewToolStrip {
            id:                         toolStrip
            anchors.leftMargin:         isInstrumentRight() ? _toolsMargin : undefined
            anchors.left:               isInstrumentRight() ? _mapAndVideo.left : undefined
            anchors.rightMargin:        isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
            anchors.right:              isInstrumentRight() ? undefined : _mapAndVideo.right
            anchors.topMargin:          _toolsMargin
            anchors.top:                parent.top
            z:                          _mapAndVideo.z + 4
            maxHeight:                  parent.height - toolStrip.y + (_flightVideo.visible ? (_flightVideo.y - parent.height) : 0)
            guidedActionsController:    _guidedController
            guidedActionList:           _guidedList
            preFlightCheckList:         checklistDropPanel
            visible:                    (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
570 571 572
        }

        GuidedActionsController {
573
            id:                 guidedActionsController
574
            missionController:  _missionController
575 576 577
            confirmDialog:      _guidedConfirm
            actionList:         _guidedList
            altitudeSlider:     _guidedSlider
578 579
        }

580
        GuidedActionConfirm {
581 582 583 584
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
585
            z:                          _guidedZOrder
586
            guidedController:           _guidedController
587
            altitudeSlider:             _guidedSlider
588 589
        }

590
        GuidedActionList {
591 592 593 594
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
595
            z:                          _guidedZOrder
596
            guidedController:           _guidedController
597 598 599
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
600
        GuidedAltitudeSlider {
601 602 603 604 605 606
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
607
            z:                  _guidedZOrder
608 609 610 611 612
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
613
    }
614

615
    //-- Airspace Indicator
616
    Rectangle {
617 618 619
        id:             airspaceIndicator
        width:          airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
        height:         airspaceRow.height * 1.25
620
        color:          qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
621
        visible:        QGroundControl.airmapSupported && mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone
622 623 624 625 626 627 628
        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 {
629
            id: airspaceRow
630 631
            spacing: ScreenTools.defaultFontPixelWidth
            anchors.centerIn: parent
632
            QGCLabel { text: airspaceIndicator.providerName+":"; anchors.verticalCenter: parent.verticalCenter; }
633 634
            QGCLabel {
                text: {
635
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
636
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
637
                            return qsTr("Approval Pending")
638
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
639
                            return qsTr("Flight Approved")
Gus Grubba's avatar
Gus Grubba committed
640
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitRejected)
641
                            return qsTr("Flight Rejected")
642 643 644 645
                    }
                    return ""
                }
                color: {
646
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
647
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
648
                            return qgcPal.colorOrange
649
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
650 651 652 653 654 655 656
                            return qgcPal.colorGreen
                    }
                    return qgcPal.colorRed
                }
                anchors.verticalCenter: parent.verticalCenter;
            }
        }
Gus Grubba's avatar
Gus Grubba committed
657
        property var  flightPermit: QGroundControl.airmapSupported ? QGroundControl.airspaceManager.flightPlan.flightPermitStatus : null
658
        property string  providerName: QGroundControl.airspaceManager.providerName
659 660
    }

661
    //-- Checklist GUI
662 663
    Popup {
        id:             checklistDropPanel
664 665
        x:              toolStrip.x + toolStrip.width + (ScreenTools.defaultFontPixelWidth * 2)
        y:              toolStrip.y
Gus Grubba's avatar
Gus Grubba committed
666 667
        height:         checkList.height
        width:          checkList.width
668 669 670 671
        modal:          true
        focus:          true
        closePolicy:    Popup.CloseOnEscape | Popup.CloseOnPressOutside
        background: Rectangle {
672 673 674
            anchors.fill:   parent
            color:          Qt.rgba(0,0,0,0)
            clip:           true
675
        }
676

677 678 679
        Loader {
            id:         checkList
            anchors.centerIn: parent
680
        }
681 682 683 684 685 686 687 688 689 690 691 692

        property alias checkListItem: checkList.item

        Connections {
            target: checkList.item
            onAllChecksPassedChanged: {
                if (target.allChecksPassed)
                {
                    checklistPopupTimer.restart()
                }
            }
        }
693
    }
694

695
}