FlightDisplayView.qml 37.4 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10


11 12
import QtQuick                  2.3
import QtQuick.Controls         1.2
13
import QtQuick.Controls.Styles  1.4
14
import QtQuick.Dialogs          1.2
15 16
import QtLocation               5.3
import QtPositioning            5.3
17
import QtQuick.Layouts          1.2
Patrick José Pereira's avatar
Patrick José Pereira committed
18
import QtQuick.Window           2.2
19
import QtQml.Models             2.1
20

21
import QGroundControl               1.0
22 23 24 25
import QGroundControl.Airspace      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactSystem    1.0
Don Gagne's avatar
Don Gagne committed
26
import QGroundControl.FlightDisplay 1.0
27 28
import QGroundControl.FlightMap     1.0
import QGroundControl.Palette       1.0
29
import QGroundControl.ScreenTools   1.0
30
import QGroundControl.Vehicle       1.0
31
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
    property var    _planMasterController:  masterController
45
    property var    _wimaController:        wimaController
46 47 48 49 50 51
    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
52
    property bool   _useChecklist:          QGroundControl.settingsManager.appSettings.useChecklist.rawValue
53 54
    property real   _savedZoomLevel:        0
    property real   _margins:               ScreenTools.defaultFontPixelWidth / 2
55
    property real   _pipSize:               flightView.width * 0.2
56 57
    property alias  _guidedController:      guidedActionsController
    property alias  _altitudeSlider:        altitudeSlider
58

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

73
    function setStates() {
74
        QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, _mainIsMap)
75
        if(_mainIsMap) {
76 77 78 79 80 81 82 83
            //-- Adjust Margins
            _flightMapContainer.state   = "fullMode"
            _flightVideo.state          = "pipMode"
            //-- Save/Restore Map Zoom Level
            if(_savedZoomLevel != 0)
                _flightMap.zoomLevel = _savedZoomLevel
            else
                _savedZoomLevel = _flightMap.zoomLevel
84
        } else {
85 86 87 88 89 90
            //-- Adjust Margins
            _flightMapContainer.state   = "pipMode"
            _flightVideo.state          = "fullMode"
            //-- Set Map Zoom Level
            _savedZoomLevel = _flightMap.zoomLevel
            _flightMap.zoomLevel = _savedZoomLevel - 3
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
    PlanMasterController {
114
        id:                     masterController
115
        Component.onCompleted:  start(true /* flyView */)
116 117
    }

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

124 125 126
        onForceUploadConfirm: {
            _guidedController.confirmAction(
                        _guidedController.actionForceUpload)
127 128
        }

129 130 131 132 133 134 135 136
        onSmartRTLRequestConfirm: {
            _guidedController.confirmAction(
                        _guidedController.actionSmartRTLRequestConfirm)
        }

        onSmartRTLPathConfirm: {
            _guidedController.confirmAction(
                        _guidedController.actionSmartRTLPathConfirm)
137
        }
138 139
    }

140
    BuiltInPreFlightCheckModel {
141
        id: preFlightCheckModel
142 143
    }

144
    Connections {
145 146
        target:                     _missionController
        onResumeMissionUploadFail:  guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionUploadFail)
147 148
    }

149 150
    Component.onCompleted: {
        setStates()
151 152 153
        if(QGroundControl.corePlugin.options.flyViewOverlay.toString().length) {
            flyViewOverlay.source = QGroundControl.corePlugin.options.flyViewOverlay
        }
154

155 156
        wimaController.masterController     = Qt.binding(function() { return masterController; })
        wimaController.missionController    = Qt.binding(function() { return masterController.missionController; })
157
    }
dogmaphobic's avatar
dogmaphobic committed
158

159 160 161 162 163 164 165 166 167 168 169 170 171 172
    // 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 {
173
            if (promptForMissionRemove && (_missionController.containsItems || _geoFenceController.containsItems || _rallyPointController.containsItems)) {
174 175 176 177
                // 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)
                }
178 179 180 181 182 183 184 185 186 187 188 189
            }
            promptForMissionRemove = false
        }
    }

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

    Component {
190 191 192
        id: missionCompleteDialogComponent

        QGCViewDialog {
193 194 195 196 197 198
            property var activeVehicleCopy: _activeVehicle
            onActiveVehicleCopyChanged:
                if (!activeVehicleCopy) {
                    hideDialog()
                }

199 200 201 202
            QGCFlickable {
                anchors.fill:   parent
                contentHeight:  column.height

203
                ColumnLayout {
204 205 206 207 208
                    id:                 column
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.right:      parent.right

209
                    ColumnLayout {
210
                        Layout.fillWidth:   true
211 212 213 214 215 216 217 218
                        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
219
                        }
220

221 222 223 224 225 226 227 228
                        QGCButton {
                            Layout.fillWidth:   true
                            text:               qsTr("Remove plan from vehicle")
                            onClicked: {
                                _planMasterController.removeAllFromVehicle()
                                hideDialog()
                            }
                        }
Don Gagne's avatar
Don Gagne committed
229

230 231 232 233 234 235
                        QGCButton {
                            Layout.fillWidth:   true
                            Layout.alignment:   Qt.AlignHCenter
                            text:               qsTr("Leave plan on vehicle")
                            onClicked:          hideDialog()
                        }
Don Gagne's avatar
Don Gagne committed
236

237 238 239 240 241
                        Rectangle {
                            Layout.fillWidth:   true
                            color:              qgcPal.text
                            height:             1
                        }
Don Gagne's avatar
Don Gagne committed
242

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

255 256 257 258 259 260 261 262 263 264 265 266 267 268
                        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
269 270
                    }

271
                    ColumnLayout {
Don Gagne's avatar
Don Gagne committed
272
                        Layout.fillWidth:   true
273 274 275 276 277 278 279 280 281
                        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
282
                    }
283
                }
284 285 286 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
    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
        }
303
    }
Patrick José Pereira's avatar
Patrick José Pereira committed
304

305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
    /* 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
320 321
    }

322 323
    QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }

324 325 326 327 328 329 330 331 332 333 334 335
    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
336
            visible:        _mainIsMap || _isPipVisible && !QGroundControl.videoManager.fullScreen
337 338
            width:          _mainIsMap ? _panel.width  : _pipSize
            height:         _mainIsMap ? _panel.height : _pipSize * (9/16)
339 340 341 342 343 344 345 346 347 348 349 350 351 352
            states: [
                State {
                    name:   "pipMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    ScreenTools.defaultFontPixelHeight
                    }
                },
                State {
                    name:   "fullMode"
                    PropertyChanges {
                        target:             _flightMapContainer
                        anchors.margins:    0
                    }
353
                }
354 355
            ]
            FlightDisplayViewMap {
356 357
                id:                         _flightMap
                anchors.fill:               parent
358
                planMasterController:       masterController
359
                wimaController:             wimaController
360 361 362 363
                guidedActionsController:    _guidedController
                flightWidgets:              flightDisplayViewWidgets
                rightPanelWidth:            ScreenTools.defaultFontPixelHeight * 9
                qgcView:                    root
364
                multiVehicleView:           !singleVehicleView.checked
365
                scaleState:                 (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
366
            }
367
        }
368

369
        //-- Video View
370
        Item {
371 372
            id:             _flightVideo
            z:              _mainIsMap ? _panel.z + 2 : _panel.z + 1
373 374
            width:          !_mainIsMap ? _panel.width  : _pipSize
            height:         !_mainIsMap ? _panel.height : _pipSize * (9/16)
375 376
            anchors.left:   _panel.left
            anchors.bottom: _panel.bottom
377
            visible:        QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
378 379 380 381 382 383 384 385 386 387 388 389 390 391

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

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

        QGCPipable {
            id:                 _flightVideoPipControl
            z:                  _flightVideo.z + 3
478 479
            width:              _pipSize
            height:             _pipSize * (9/16)
480 481 482
            anchors.left:       _panel.left
            anchors.bottom:     _panel.bottom
            anchors.margins:    ScreenTools.defaultFontPixelHeight
483
            visible:            QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen && _flightVideo.state != "popup"
484 485
            isHidden:           !_isPipVisible
            isDark:             isBackgroundDark
486
            enablePopup:        _mainIsMap
487 488 489 490 491 492 493
            onActivated: {
                _mainIsMap = !_mainIsMap
                setStates()
            }
            onHideIt: {
                setPipVisibility(!state)
            }
Patrick José Pereira's avatar
Patrick José Pereira committed
494 495 496 497
            onPopup: {
                videoWindow.visible = true
                _flightVideo.state = "popup"
            }
498 499
            onNewWidth: {
                _pipSize = newWidth
Jacob Walser's avatar
Jacob Walser committed
500
            }
dogmaphobic's avatar
dogmaphobic committed
501
        }
Don Gagne's avatar
Don Gagne committed
502

503 504 505 506 507 508 509 510 511 512 513 514 515 516
//        Item {
//            id: theItem
//            anchors.right:      parent.right
//            anchors.bottom:     parent.top
//            z:                  1000
//            visible:            true

//            Text {
//                id: theText
//                text: qsTr("Hello World!")
//                font.pointSize: 40
//            }
//        }

517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
        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
534
                textColor:      mapPal.text
535 536 537 538
            }

            QGCRadioButton {
                exclusiveGroup: multiVehicleSelectorGroup
539
                text:           qsTr("Multi-Vehicle")
540
                textColor:      mapPal.text
541 542 543
            }
        }

544 545 546
        FlightDisplayViewWidgets {
            id:                 flightDisplayViewWidgets
            z:                  _panel.z + 4
547
            height:             ScreenTools.availableHeight - (singleMultiSelector.visible ? singleMultiSelector.height + _margins : 0)
548
            anchors.left:       parent.left
549
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
550
            anchors.bottom:     parent.bottom
551 552 553 554 555 556
            qgcView:            root
            useLightColors:     isBackgroundDark
            missionController:  _missionController
            visible:            singleVehicleView.checked && !QGroundControl.videoManager.fullScreen
        }

557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
        /*Rectangle {

            z:                      _panel.z + 4
            anchors.left:           parent.left
            anchors.bottom:         parent.bottom
            anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
            anchors.bottomMargin:   ScreenTools.defaultFontPixelWidth
            color:                  "red"
            width:                  childrenRect.width
            height:                 childrenRect.height


            Rectangle {
                height: 20
                width: 100
                anchors.bottom: innerRectangle.top
                anchors.left: parent.left
                color: "green"
            }


            Rectangle {
                id:innerRectangle
                height: 100
                width: 100
                anchors.bottom: parent.bottom
                anchors.left: parent.left
                color: "blue"
            }



            MouseArea {
                property bool value: false

                anchors.fill: innerRectangle

                onClicked: {
                    if (value) {
                        innerRectangle.height /= 2
                        innerRectangle.width /= 2
                        value = false
                    }
                    else
                    {
                        innerRectangle.height *= 2
                        innerRectangle.width *= 2
                        value = true
                    }
                }
            }
        }*/

610 611 612 613 614
        FlightDisplayWimaMenu {
            id:                     wimaMenu
            z:                      _panel.z + 4
            anchors.left:           parent.left
            anchors.bottom:         parent.bottom
Valentin Platzgummer's avatar
Valentin Platzgummer committed
615 616
            anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
            anchors.bottomMargin:   ScreenTools.defaultFontPixelWidth
Valentin Platzgummer's avatar
Valentin Platzgummer committed
617
            maxWidth:               singleMultiSelector.x - ScreenTools.defaultFontPixelHeight*4
618 619
            maxHeight:              _flightMap.height - toolStrip.height - toolStrip.y
                                    - ScreenTools.defaultFontPixelHeight*4
620 621


622 623 624
            wimaController:         _wimaController
            planMasterController:   _planMasterController
            missionController:      _missionController
625 626
        }

627 628 629 630 631
        //-------------------------------------------------------------------------
        //-- Loader helper for plugins to overlay elements over the fly view
        Loader {
            id:                 flyViewOverlay
            z:                  flightDisplayViewWidgets.z + 1
632
            visible:            !QGroundControl.videoManager.fullScreen
633 634 635 636
            height:             ScreenTools.availableHeight
            anchors.left:       parent.left
            anchors.right:      altitudeSlider.visible ? altitudeSlider.left : parent.right
            anchors.bottom:     parent.bottom
637 638

            property var qgcView: root
639 640
        }

641
        MultiVehicleList {
642 643 644 645 646 647 648 649
            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
650
        }
dogmaphobic's avatar
dogmaphobic committed
651

652
        //-- Virtual Joystick
653
        Loader {
654
            id:                         virtualJoystickMultiTouch
655 656
            z:                          _panel.z + 5
            width:                      parent.width  - (_flightVideoPipControl.width / 2)
657
            height:                     Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16)
658
            visible:                    (_virtualJoystick ? _virtualJoystick.value : false) && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
659 660
            anchors.bottom:             _flightVideoPipControl.top
            anchors.bottomMargin:       ScreenTools.defaultFontPixelHeight * 2
661
            anchors.horizontalCenter:   flightDisplayViewWidgets.horizontalCenter
662
            source:                     "qrc:/qml/VirtualJoystick.qml"
663
            active:                     (_virtualJoystick ? _virtualJoystick.value : false) && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
Don Gagne's avatar
Don Gagne committed
664

665
            property bool useLightColors: isBackgroundDark
666 667

            property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
Don Gagne's avatar
Don Gagne committed
668
        }
669 670

        ToolStrip {
671
            visible:            (_activeVehicle ? _activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen
672
            id:                 toolStrip
Gus Grubba's avatar
Gus Grubba committed
673 674 675 676
            anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth : undefined
            anchors.left:       isInstrumentRight() ? _panel.left : undefined
            anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth
            anchors.right:      isInstrumentRight() ? undefined : _panel.right
677
            anchors.topMargin:  ScreenTools.toolbarHeight + (_margins * 2)
678 679 680 681
            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
682 683
            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 ]
684
            horizontal:         true
685
            enableSwitchButton: true
686

687
            property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
688 689
            property var _actionModel: [
                {
690 691 692 693
                    title:      _guidedController.startMissionTitle,
                    text:       _guidedController.startMissionMessage,
                    action:     _guidedController.actionStartMission,
                    visible:    _guidedController.showStartMission
694
                },
Don Gagne's avatar
Don Gagne committed
695 696 697 698 699 700
                {
                    title:      _guidedController.continueMissionTitle,
                    text:       _guidedController.continueMissionMessage,
                    action:     _guidedController.actionContinueMission,
                    visible:    _guidedController.showContinueMission
                },
701
                {
702 703 704 705
                    title:      _guidedController.resumeMissionTitle,
                    text:       _guidedController.resumeMissionMessage,
                    action:     _guidedController.actionResumeMission,
                    visible:    _guidedController.showResumeMission
706 707
                },
                {
708 709 710 711
                    title:      _guidedController.changeAltTitle,
                    text:       _guidedController.changeAltMessage,
                    action:     _guidedController.actionChangeAlt,
                    visible:    _guidedController.showChangeAlt
712 713
                },
                {
714 715 716 717
                    title:      _guidedController.landAbortTitle,
                    text:       _guidedController.landAbortMessage,
                    action:     _guidedController.actionLandAbort,
                    visible:    _guidedController.showLandAbort
718 719 720 721
                }
            ]

            model: [
722 723 724 725 726
                {
                    name:               "Checklist",
                    iconSource:         "/qmlimages/check.svg",
                    dropPanelComponent: checklistDropPanel
                },
727
                {
728
                    name:       _guidedController.takeoffTitle,
729
                    iconSource: "/res/takeoff.svg",
730
                    action:     _guidedController.actionTakeoff
731 732
                },
                {
733
                    name:       _guidedController.landTitle,
734
                    iconSource: "/res/land.svg",
735
                    action:     _guidedController.actionLand
736 737
                },
                {
738
                    name:       _guidedController.rtlTitle,
739
                    iconSource: "/res/rtl.svg",
740
                    action:     _guidedController.actionRTL
741 742
                },
                {
743
                    name:       _guidedController.pauseTitle,
Gus Grubba's avatar
Gus Grubba committed
744
                    iconSource: "/res/pause-mission.svg",
745
                    action:     _guidedController.actionPause
746 747 748
                },
                {
                    name:       qsTr("Action"),
Gus Grubba's avatar
Gus Grubba committed
749
                    iconSource: "/res/action.svg",
750
                    action:     -1
DonLakeFlyer's avatar
DonLakeFlyer committed
751
                }
752 753 754
            ]

            onClicked: {
755
                guidedActionsController.closeAll()
756 757
                var action = model[index].action
                if (action === -1) {
DonLakeFlyer's avatar
DonLakeFlyer committed
758 759
                    guidedActionList.model   = _actionModel
                    guidedActionList.visible = true
760
                } else {
761
                    _guidedController.confirmAction(action)
762 763 764 765 766
                }
            }
        }

        GuidedActionsController {
767
            id:                 guidedActionsController
768
            wimaController:     wimaController
769
            missionController:  _missionController
770
            confirmDialog:      guidedActionConfirm
DonLakeFlyer's avatar
DonLakeFlyer committed
771
            actionList:         guidedActionList
Don Gagne's avatar
Don Gagne committed
772
            altitudeSlider:     _altitudeSlider
773 774
            z:                  _flightVideoPipControl.z + 1

775
            onShowStartMissionChanged: {
Don Gagne's avatar
Don Gagne committed
776
                if (showStartMission) {
777 778 779 780
                    confirmAction(actionStartMission)
                }
            }

781 782 783 784 785 786
            onShowContinueMissionChanged: {
                if (showContinueMission) {
                    confirmAction(actionContinueMission)
                }
            }

787 788 789 790 791
            onShowLandAbortChanged: {
                if (showLandAbort) {
                    confirmAction(actionLandAbort)
                }
            }
792 793 794

            /// Close all dialogs
            function closeAll() {
795
                mainWindow.enableToolbar()
796 797 798 799 800
                rootLoader.sourceComponent  = null
                guidedActionConfirm.visible = false
                guidedActionList.visible    = false
                altitudeSlider.visible      = false
            }
801 802
        }

803
        GuidedActionConfirm {
804 805 806 807
            id:                         guidedActionConfirm
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
808 809
            guidedController:           _guidedController
            altitudeSlider:             _altitudeSlider
810 811
        }

812
        GuidedActionList {
813 814 815 816
            id:                         guidedActionList
            anchors.margins:            _margins
            anchors.bottom:             parent.bottom
            anchors.horizontalCenter:   parent.horizontalCenter
817
            guidedController:           _guidedController
818 819 820
        }

        //-- Altitude slider
DonLakeFlyer's avatar
DonLakeFlyer committed
821
        GuidedAltitudeSlider {
822 823 824 825 826 827
            id:                 altitudeSlider
            anchors.margins:    _margins
            anchors.right:      parent.right
            anchors.topMargin:  ScreenTools.toolbarHeight + _margins
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
828
            z:                  _guidedController.z
829 830 831 832 833
            radius:             ScreenTools.defaultFontPixelWidth / 2
            width:              ScreenTools.defaultFontPixelWidth * 10
            color:              qgcPal.window
            visible:            false
        }
Don Gagne's avatar
Don Gagne committed
834
    }
835

836
    //-- Airspace Indicator
837
    Rectangle {
838 839 840
        id:             airspaceIndicator
        width:          airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
        height:         airspaceRow.height * 1.25
841
        color:          qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
842
        visible:        QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone && !messageArea.visible && !criticalMmessageArea.visible
843 844 845 846 847 848 849
        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 {
850
            id: airspaceRow
851 852
            spacing: ScreenTools.defaultFontPixelWidth
            anchors.centerIn: parent
853
            QGCLabel { text: airspaceIndicator.providerName+":"; anchors.verticalCenter: parent.verticalCenter; }
854 855
            QGCLabel {
                text: {
856
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
857
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
858
                            return qsTr("Approval Pending")
859
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
860
                            return qsTr("Flight Approved")
Gus Grubba's avatar
Gus Grubba committed
861
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitRejected)
862
                            return qsTr("Flight Rejected")
863 864 865 866
                    }
                    return ""
                }
                color: {
867
                    if(airspaceIndicator.flightPermit) {
Gus Grubba's avatar
Gus Grubba committed
868
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitPending)
869
                            return qgcPal.colorOrange
870
                        if(airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitAccepted || airspaceIndicator.flightPermit === AirspaceFlightPlanProvider.PermitNotRequired)
871 872 873 874 875 876 877
                            return qgcPal.colorGreen
                    }
                    return qgcPal.colorRed
                }
                anchors.verticalCenter: parent.verticalCenter;
            }
        }
Gus Grubba's avatar
Gus Grubba committed
878
        property var  flightPermit: QGroundControl.airmapSupported ? QGroundControl.airspaceManager.flightPlan.flightPermitStatus : null
879
        property string  providerName: QGroundControl.airspaceManager.providerName
880 881
    }

882
    //-- Checklist GUI
883 884
    Component {
        id: checklistDropPanel
885 886 887
        PreFlightCheckList {
            model: preFlightCheckModel
        }
888
    }
889
}