PlanView.qml 47.3 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.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10


11 12
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
13
import QtQuick.Dialogs  1.2
14 15 16
import QtLocation       5.3
import QtPositioning    5.3
import QtQuick.Layouts  1.2
17
import QtQuick.Window   2.2
Don Gagne's avatar
Don Gagne committed
18

19 20 21 22 23 24 25 26 27 28 29
import QGroundControl                   1.0
import QGroundControl.FlightMap         1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactSystem        1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0
import QGroundControl.Controllers       1.0
import QGroundControl.ShapeFileHelper   1.0
import QGroundControl.Airspace          1.0
import QGroundControl.Airmap            1.0
Don Gagne's avatar
Don Gagne committed
30 31

/// Mission Editor
Don Gagne's avatar
Don Gagne committed
32

33
Item {
34

Gus Grubba's avatar
Gus Grubba committed
35 36
    property bool planControlColapsed: false

37
    readonly property int   _decimalPlaces:             8
Gus Grubba's avatar
Gus Grubba committed
38
    readonly property real  _horizontalMargin:          ScreenTools.defaultFontPixelWidth  * 0.5
39
    readonly property real  _margin:                    ScreenTools.defaultFontPixelHeight * 0.5
Gus Grubba's avatar
Gus Grubba committed
40
    readonly property real  _radius:                    ScreenTools.defaultFontPixelWidth  * 0.5
41
    readonly property real  _rightPanelWidth:           Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
Gus Grubba's avatar
Gus Grubba committed
42
    readonly property real  _toolButtonTopMargin:       ScreenTools.defaultFontPixelHeight * 0.5
43 44
    readonly property var   _defaultVehicleCoordinate:  QtPositioning.coordinate(37.803784, -122.462276)
    readonly property bool  _waypointsOnlyMode:         QGroundControl.corePlugin.options.missionWaypointsOnly
45

Gus Grubba's avatar
Gus Grubba committed
46
    property bool   _airspaceEnabled:                    QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
Gus Grubba's avatar
Gus Grubba committed
47 48 49 50 51 52 53 54
    property var    _missionController:                 _planMasterController.missionController
    property var    _geoFenceController:                _planMasterController.geoFenceController
    property var    _rallyPointController:              _planMasterController.rallyPointController
    property var    _visualItems:                       _missionController.visualItems
    property bool   _lightWidgetBorders:                editorMap.isSatelliteMap
    property bool   _addWaypointOnClick:                false
    property bool   _addROIOnClick:                     false
    property bool   _singleComplexItem:                 _missionController.complexMissionItemNames.length === 1
Gus Grubba's avatar
Gus Grubba committed
55
    property int    _editingLayer:                      bar.currentIndex ? _layers[bar.currentIndex] : _layerMission
Gus Grubba's avatar
Gus Grubba committed
56
    property int    _toolStripBottom:                   toolStrip.height + toolStrip.y
57
    property var    _appSettings:                       QGroundControl.settingsManager.appSettings
58

Gus Grubba's avatar
Gus Grubba committed
59 60
    readonly property var       _layers:                [_layerMission, _layerGeoFence, _layerRallyPoints]

61 62 63 64
    readonly property int       _layerMission:              1
    readonly property int       _layerGeoFence:             2
    readonly property int       _layerRallyPoints:          3
    readonly property string    _armedVehicleUploadPrompt:  qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
65

66 67
    function addComplexItem(complexItemName) {
        var coordinate = editorMap.center
68
        coordinate.latitude  = coordinate.latitude.toFixed(_decimalPlaces)
69
        coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
70
        coordinate.altitude  = coordinate.altitude.toFixed(_decimalPlaces)
71
        insertComplexMissionItem(complexItemName, coordinate, _missionController.visualItems.count)
72 73 74
    }

    function insertComplexMissionItem(complexItemName, coordinate, index) {
75
        var sequenceNumber = _missionController.insertComplexMissionItem(complexItemName, coordinate, index)
76
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
77 78
    }

79 80
    function insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index) {
        var sequenceNumber = _missionController.insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index)
81 82 83
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
    }

84
    function updateAirspace(reset) {
85 86 87 88
        if(_airspaceEnabled) {
            var coordinateNW = editorMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */)
            var coordinateSE = editorMap.toCoordinate(Qt.point(width,height), false /* clipToViewPort */)
            if(coordinateNW.isValid && coordinateSE.isValid) {
89
                QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
90 91 92 93
            }
        }
    }

94 95 96 97 98
    property bool _firstMissionLoadComplete:    false
    property bool _firstFenceLoadComplete:      false
    property bool _firstRallyLoadComplete:      false
    property bool _firstLoadComplete:           false

99
    MapFitFunctions {
100
        id:                         mapFitFunctions  // The name for this id cannot be changed without breaking references outside of this code. Beware!
101 102
        map:                        editorMap
        usePlannedHomePosition:     true
103
        planMasterController:       _planMasterController
104 105
    }

106
    on_AirspaceEnabledChanged: {
107
        if(QGroundControl.airmapSupported) {
108 109
            if(_airspaceEnabled) {
                planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
110
                updateAirspace(true)
111 112 113
            } else {
                planControlColapsed = false
            }
114
        } else {
Gus Grubba's avatar
Gus Grubba committed
115 116 117 118
            planControlColapsed = false
        }
    }

DonLakeFlyer's avatar
DonLakeFlyer committed
119
    Connections {
Gus Grubba's avatar
Gus Grubba committed
120
        target: _appSettings ? _appSettings.defaultMissionItemAltitude : null
DonLakeFlyer's avatar
DonLakeFlyer committed
121 122
        onRawValueChanged: {
            if (_visualItems.count > 1) {
123
                mainWindow.showComponentDialog(applyNewAltitude, qsTr("Apply new alititude"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
DonLakeFlyer's avatar
DonLakeFlyer committed
124 125 126 127 128 129 130 131 132 133
            }
        }
    }

    Component {
        id: applyNewAltitude
        QGCViewMessage {
            message:    qsTr("You have changed the default altitude for mission items. Would you like to apply that altitude to all the items in the current mission?")
            function accept() {
                hideDialog()
134
                _missionController.applyDefaultMissionAltitude()
DonLakeFlyer's avatar
DonLakeFlyer committed
135 136 137 138
            }
        }
    }

139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    Component {
        id: activeMissionUploadDialogComponent
        QGCViewDialog {
            Column {
                anchors.fill:   parent
                spacing:        ScreenTools.defaultFontPixelHeight
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("Your vehicle is currently flying a mission. In order to upload a new or modified mission the current mission will be paused.")
                }
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("After the mission is uploaded you can adjust the current waypoint and start the mission.")
                }
                QGCButton {
                    text:       qsTr("Pause and Upload")
                    onClicked: {
Gus Grubba's avatar
Gus Grubba committed
158
                        activeVehicle.flightMode = activeVehicle.pauseFlightMode
159
                        _planMasterController.sendToVehicle()
160
                        hideDialog()
161 162 163 164 165 166
                    }
                }
            }
        }
    }

Gus Grubba's avatar
Gus Grubba committed
167
    Connections {
168
        target: QGroundControl.airspaceManager
169
        onAirspaceVisibleChanged: {
170
            planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Gus Grubba's avatar
Gus Grubba committed
171 172 173
        }
    }

174 175 176 177 178 179 180
    Component {
        id: noItemForKML
        QGCViewMessage {
            message:    qsTr("You need at least one item to create a KML.")
        }
    }

181
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
182
        id: _planMasterController
183

184
        Component.onCompleted: {
185
            _planMasterController.start(false /* flyView */)
186
            _missionController.setCurrentPlanViewIndex(0, true)
Gus Grubba's avatar
Gus Grubba committed
187
            mainWindow.planMasterControllerPlan = _planMasterController
188 189
        }

190
        function waitingOnDataMessage() {
191
            mainWindow.showMessageDialog(qsTr("Unable to Save/Upload"), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
192 193
        }

194
        function upload() {
195 196 197 198
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
Gus Grubba's avatar
Gus Grubba committed
199
            if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
200
                mainWindow.showComponentDialog(activeMissionUploadDialogComponent, qsTr("Plan Upload"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
201
            } else {
202 203
                sendToVehicle()
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
204 205
        }

206
        function loadFromSelectedFile() {
207
            fileDialog.title =          qsTr("Select Plan File")
DonLakeFlyer's avatar
DonLakeFlyer committed
208
            fileDialog.planFiles =      true
209
            fileDialog.selectExisting = true
Gus Grubba's avatar
Gus Grubba committed
210
            fileDialog.nameFilters =    _planMasterController.loadNameFilters
211 212
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
213
            fileDialog.openForLoad()
214 215 216
        }

        function saveToSelectedFile() {
217 218 219 220
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
221
            fileDialog.title =          qsTr("Save Plan")
222
            fileDialog.planFiles =      true
223
            fileDialog.selectExisting = false
Gus Grubba's avatar
Gus Grubba committed
224
            fileDialog.nameFilters =    _planMasterController.saveNameFilters
225 226
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
227
            fileDialog.openForSave()
228 229
        }

230
        function fitViewportToItems() {
231
            mapFitFunctions.fitMapViewportToMissionItems()
232
        }
233

234 235
        function loadShapeFromSelectedFile() {
            fileDialog.title =          qsTr("Load Shape")
236 237
            fileDialog.planFiles =      false
            fileDialog.selectExisting = true
238 239 240
            fileDialog.nameFilters =    ShapeFileHelper.fileDialogKMLOrSHPFilters
            fileDialog.fileExtension =  _appSettings.kmlFileExtension
            fileDialog.fileExtension2 = _appSettings.shpFileExtension
241 242 243
            fileDialog.openForLoad()
        }

244
        function saveKmlToSelectedFile() {
245 246 247 248
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
249
            fileDialog.title =          qsTr("Save KML")
250
            fileDialog.planFiles =      false
251
            fileDialog.selectExisting = false
252 253
            fileDialog.nameFilters =    ShapeFileHelper.fileDialogKMLFilters
            fileDialog.fileExtension =  _appSettings.kmlFileExtension
254
            fileDialog.fileExtension2 = ""
255 256
            fileDialog.openForSave()
        }
257
    }
258

259 260
    Connections {
        target: _missionController
261
        onNewItemsFromVehicle: {
Gus Grubba's avatar
Gus Grubba committed
262
            if (_visualItems && _visualItems.count !== 1) {
263 264
                mapFitFunctions.fitMapViewportToMissionItems()
            }
265
            _missionController.setCurrentPlanViewIndex(0, true)
266 267
        }
    }
268

269 270 271 272
    /// Inserts a new simple mission item
    ///     @param coordinate Location to insert item
    ///     @param index Insert item at this index
    function insertSimpleMissionItem(coordinate, index) {
273
        var sequenceNumber = _missionController.insertSimpleMissionItem(coordinate, index)
274
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
275 276
    }

277 278 279 280 281 282 283
    /// Inserts a new ROI mission item
    ///     @param coordinate Location to insert item
    ///     @param index Insert item at this index
    function insertROIMissionItem(coordinate, index) {
        var sequenceNumber = _missionController.insertROIMissionItem(coordinate, index)
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
        _addROIOnClick = false
284
        toolStrip.lastClickedButton.checked = false
285 286
    }

287 288
    property int _moveDialogMissionItemIndex

289 290
    QGCFileDialog {
        id:             fileDialog
Gus Grubba's avatar
Gus Grubba committed
291
        folder:         _appSettings ? _appSettings.missionSavePath : ""
292

293 294
        property bool planFiles: true    ///< true: working with plan files, false: working with kml file

295
        onAcceptedForSave: {
296
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
297
                _planMasterController.saveToFile(file)
298
            } else {
Gus Grubba's avatar
Gus Grubba committed
299
                _planMasterController.saveToKml(file)
300
            }
301
            close()
302 303
        }

304
        onAcceptedForLoad: {
305
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
306 307
                _planMasterController.loadFromFile(file)
                _planMasterController.fitViewportToItems()
308 309
                _missionController.setCurrentPlanViewIndex(0, true)
            } else {
310 311
                var retList = ShapeFileHelper.determineShapeType(file)
                if (retList[0] == ShapeFileHelper.Error) {
312
                    mainWindow.showMessageDialog("Error", retList[1])
313
                } else if (retList[0] == ShapeFileHelper.Polygon) {
Gus Grubba's avatar
Gus Grubba committed
314
                     var editVehicle = activeVehicle ? activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
315 316 317 318
                    if (editVehicle.fixedWing) {
                        insertComplexMissionItemFromKMLOrSHP(_missionController.surveyComplexItemName, file, -1)
                    } else {
                        polygonSelectPatternFile = file
319
                        mainWindow.showComponentDialog(patternPolygonSelectDialog, fileDialog.title, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
320
                    }
321 322
                } else if (retList[0] == ShapeFileHelper.Polyline) {
                    insertComplexMissionItemFromKMLOrSHP(_missionController.corridorScanComplexItemName, file, -1)
323 324
                }
            }
325
            close()
326 327 328
        }
    }

329
    property string polygonSelectPatternFile
330
    Component {
331
        id: patternPolygonSelectDialog
332 333 334 335 336 337 338 339
        QGCViewDialog {
            function accept() {
                var complexItemName
                if (surveyRadio.checked) {
                    complexItemName = _missionController.surveyComplexItemName
                } else {
                    complexItemName = _missionController.structureScanComplexItemName
                }
340
                insertComplexMissionItemFromKMLOrSHP(complexItemName, polygonSelectPatternFile, -1)
341 342 343 344 345 346 347 348 349 350
                hideDialog()
            }
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight
                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
351
                    text:           qsTr("Create which pattern type?")
352 353 354 355 356 357 358 359 360 361 362 363 364
                }
                QGCRadioButton {
                    id:             surveyRadio
                    text:           qsTr("Survey")
                    checked:        true
                }
                QGCRadioButton {
                    text:           qsTr("Structure Scan")
                }
            }
        }
    }

365 366 367 368 369
    Component {
        id: moveDialog
        QGCViewDialog {
            function accept() {
                var toIndex = toCombo.currentIndex
Gus Grubba's avatar
Gus Grubba committed
370
                if (toIndex === 0) {
371 372
                    toIndex = 1
                }
373
                _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
374 375 376 377 378 379 380 381 382 383 384
                hideDialog()
            }
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
385
                    text:           qsTr("Move the selected mission item to the be after following mission item:")
386 387 388 389
                }

                QGCComboBox {
                    id:             toCombo
390
                    model:          _visualItems.count
391 392 393 394 395 396
                    currentIndex:   _moveDialogMissionItemIndex
                }
            }
        }
    }

397
    Item {
Don Gagne's avatar
Don Gagne committed
398
        id:             panel
399
        anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
400

401
        FlightMap {
402 403 404 405 406
            id:                         editorMap
            anchors.fill:               parent
            mapName:                    "MissionEditor"
            allowGCSLocationCenter:     true
            allowVehicleLocationCenter: true
407
            planView:                   true
Don Gagne's avatar
Don Gagne committed
408

409
            // This is the center rectangle of the map which is not obscured by tools
410
            property rect centerViewport:   Qt.rect(_leftToolWidth, 0, editorMap.width - _leftToolWidth - _rightPanelWidth, editorMap.height - _statusHeight)
411

412 413
            property real _leftToolWidth:   toolStrip.x + toolStrip.width
            property real _statusHeight:    waypointValuesDisplay.visible ? editorMap.height - waypointValuesDisplay.y : 0
414

415
            readonly property real animationDuration: 500
416

417 418
            // Initial map position duplicates Fly view position
            Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition
419

420 421 422 423 424 425
            Behavior on zoomLevel {
                NumberAnimation {
                    duration:       editorMap.animationDuration
                    easing.type:    Easing.InOutQuad
                }
            }
426

427 428
            QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }

429 430
            onZoomLevelChanged: updateAirspace(false)
            onCenterChanged:    updateAirspace(false)
431

432 433 434
            MouseArea {
                anchors.fill: parent
                onClicked: {
435 436
                    // Take focus to close any previous editing
                    editorMap.focus = true
437 438 439 440
                    var coordinate = editorMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
                    coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
                    coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
                    coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
441

442 443 444
                    switch (_editingLayer) {
                    case _layerMission:
                        if (_addWaypointOnClick) {
445
                            insertSimpleMissionItem(coordinate, _missionController.visualItems.count)
446 447 448
                        } else if (_addROIOnClick) {
                            _addROIOnClick = false
                            insertROIMissionItem(coordinate, _missionController.visualItems.count)
449
                        }
450 451
                        break
                    case _layerRallyPoints:
Gus Grubba's avatar
Gus Grubba committed
452
                        if (_rallyPointController.supported && _addWaypointOnClick) {
453
                            _rallyPointController.addPoint(coordinate)
454
                        }
455
                        break
Don Gagne's avatar
Don Gagne committed
456
                    }
Don Gagne's avatar
Don Gagne committed
457
                }
458
            }
Don Gagne's avatar
Don Gagne committed
459

460 461
            // Add the mission item visuals to the map
            Repeater {
462
                model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
463 464
                delegate: MissionItemMapVisual {
                    map:        editorMap
465
                    onClicked:  _missionController.setCurrentPlanViewIndex(sequenceNumber, false)
466
                    visible:    _editingLayer == _layerMission
467
                }
468
            }
469

470 471
            // Add lines between waypoints
            MissionLineView {
472
                model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
473
            }
474

475 476 477 478 479 480 481
            // Add the vehicles to the map
            MapItemView {
                model: QGroundControl.multiVehicleManager.vehicles
                delegate:
                    VehicleMapItem {
                    vehicle:        object
                    coordinate:     object.coordinate
482
                    map:            editorMap
483 484
                    size:           ScreenTools.defaultFontPixelHeight * 3
                    z:              QGroundControl.zOrderMapItems - 1
485
                }
486
            }
487

488 489
            GeoFenceMapVisuals {
                map:                    editorMap
490
                myGeoFenceController:   _geoFenceController
491
                interactive:            _editingLayer == _layerGeoFence
492
                homePosition:           _missionController.plannedHomePosition
493 494
                planView:               true
            }
495

496 497
            RallyPointMapVisuals {
                map:                    editorMap
498
                myRallyPointController: _rallyPointController
499 500
                interactive:            _editingLayer == _layerRallyPoints
                planView:               true
501
            }
502

503 504
            // Airspace overlap support
            MapItemView {
505
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.circles : []
506 507 508
                delegate: MapCircle {
                    center:         object.center
                    radius:         object.radius
509
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
510 511
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
512 513 514 515
                }
            }

            MapItemView {
516
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : []
517 518
                delegate: MapPolygon {
                    path:           object.polygon
519
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
520 521
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
522 523
                }
            }
524
        }
525

526 527
        //-----------------------------------------------------------
        // Left tool strip
Gus Grubba's avatar
Gus Grubba committed
528
        ToolStrip {
529
            id:                 toolStrip
530
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
531 532 533 534
            anchors.left:       parent.left
            anchors.topMargin:  ScreenTools.defaultFontPixelHeight * 0.5
            anchors.top:        parent.top
            z:                  QGroundControl.zOrderWidgets
Gus Grubba's avatar
Gus Grubba committed
535
            maxHeight:          mapScale.y - toolStrip.y
536

Gus Grubba's avatar
Gus Grubba committed
537 538
            property bool _isRally:     _editingLayer == _layerRallyPoints
            property bool _showZoom:    !ScreenTools.isMobile
539

Gus Grubba's avatar
Gus Grubba committed
540 541 542 543 544 545
            model: [
                {
                    name:               qsTr("Fly"),
                    iconSource:         "/qmlimages/PaperPlane.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
546
                },
547
                {
Gus Grubba's avatar
Gus Grubba committed
548 549 550 551 552 553 554 555 556 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
                    name:               qsTr("File"),
                    iconSource:         "/qmlimages/MapSync.svg",
                    buttonEnabled:      !_planMasterController.syncInProgress,
                    buttonVisible:      true,
                    showAlternateIcon:  _planMasterController.dirty,
                    alternateIconSource:"/qmlimages/MapSyncChanged.svg",
                    dropPanelComponent: syncDropPanel
                },
                {
                    name:               _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    toggle:             true,
                    checked:            _addWaypointOnClick
                },
                {
                    name:               qsTr("ROI"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
                    buttonEnabled:      true,
                    buttonVisible:      !_isRally && _waypointsOnlyMode,
                    toggle:             true
                },
                {
                    name:               _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
                    iconSource:         "/qmlimages/MapDrawShape.svg",
                    buttonEnabled:      true,
                    buttonVisible:      !_isRally,
                    dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
                },
                {
                    name:               qsTr("Center"),
                    iconSource:         "/qmlimages/MapCenter.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    dropPanelComponent: centerMapDropPanel
                },
                {
                    name:               qsTr("In"),
                    buttonEnabled:      true,
                    buttonVisible:      _showZoom,
                    iconSource:         "/qmlimages/ZoomPlus.svg"
                },
                {
                    name:               qsTr("Out"),
                    buttonEnabled:      true,
                    buttonVisible:      _showZoom,
                    iconSource:         "/qmlimages/ZoomMinus.svg"
                }
            ]
598

Gus Grubba's avatar
Gus Grubba committed
599 600
            onClicked: {
                switch (index) {
601 602 603 604
                case 0:
                    mainWindow.showFlyView()
                    break;
                case 2:
Gus Grubba's avatar
Gus Grubba committed
605 606 607 608 609 610
                    if(_addWaypointOnClick) {
                        //-- Toggle it off
                        _addWaypointOnClick = false
                        _addROIOnClick = false
                        setChecked(index, false)
                    } else {
611
                        _addWaypointOnClick = checked
612
                        _addROIOnClick = false
Gus Grubba's avatar
Gus Grubba committed
613 614
                    }
                    break
615
                case 3:
Gus Grubba's avatar
Gus Grubba committed
616 617 618
                    _addROIOnClick = checked
                    _addWaypointOnClick = false
                    break
619
                case 4:
Gus Grubba's avatar
Gus Grubba committed
620 621 622 623 624
                    if (_singleComplexItem) {
                        addComplexItem(_missionController.complexMissionItemNames[0])
                    }
                    break
                case 6:
625 626 627
                    editorMap.zoomLevel += 0.5
                    break
                case 7:
Gus Grubba's avatar
Gus Grubba committed
628 629
                    editorMap.zoomLevel -= 0.5
                    break
630 631
                }
            }
Gus Grubba's avatar
Gus Grubba committed
632
        }
633

Gus Grubba's avatar
Gus Grubba committed
634
        //-----------------------------------------------------------
635 636 637
        // Right pane for mission editing controls
        Rectangle {
            id:                 rightPanel
638
            height:             parent.height
639 640
            width:              _rightPanelWidth
            color:              qgcPal.window
641
            opacity:            planExpanded.visible ? 0.2 : 0
Gus Grubba's avatar
Gus Grubba committed
642 643 644
            anchors.bottom:     parent.bottom
            anchors.right:      parent.right
            anchors.rightMargin: ScreenTools.defaultFontPixelWidth
645
        }
Gus Grubba's avatar
Gus Grubba committed
646 647
        //-------------------------------------------------------
        // Right Panel Controls
648
        Item {
Gus Grubba's avatar
Gus Grubba committed
649
            anchors.fill:           rightPanel
Gus Grubba's avatar
Gus Grubba committed
650
            anchors.topMargin:      _toolButtonTopMargin
Gus Grubba's avatar
Gus Grubba committed
651 652 653
            DeadMouseArea {
                anchors.fill:   parent
            }
Gus Grubba's avatar
Gus Grubba committed
654 655
            Column {
                id:                 rightControls
Gus Grubba's avatar
Gus Grubba committed
656
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
657 658
                anchors.left:       parent.left
                anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
659 660 661 662
                anchors.top:        parent.top
                //-------------------------------------------------------
                // Airmap Airspace Control
                AirspaceControl {
Gus Grubba's avatar
Gus Grubba committed
663 664
                    id:             airspaceControl
                    width:          parent.width
665
                    visible:        _airspaceEnabled
666
                    planView:       true
667
                    showColapse:    true
668
                }
Gus Grubba's avatar
Gus Grubba committed
669 670 671 672
                //-------------------------------------------------------
                // Mission Controls (Colapsed)
                Rectangle {
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
673
                    height:     planControlColapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
674 675
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
676
                    visible:    planControlColapsed && _airspaceEnabled
Gus Grubba's avatar
Gus Grubba committed
677 678 679 680 681 682 683
                    Row {
                        id:                     colapsedRow
                        spacing:                ScreenTools.defaultFontPixelWidth
                        anchors.left:           parent.left
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                        QGCColoredImage {
684 685 686 687 688
                            width:              height
                            height:             ScreenTools.defaultFontPixelWidth * 2.5
                            sourceSize.height:  height
                            source:             "qrc:/res/waypoint.svg"
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
689 690 691
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        QGCLabel {
692 693
                            text:               qsTr("Plan")
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
694
                            anchors.verticalCenter: parent.verticalCenter
695 696
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
697 698 699 700
                    QGCColoredImage {
                        width:                  height
                        height:                 ScreenTools.defaultFontPixelWidth * 2.5
                        sourceSize.height:      height
701
                        source:                 QGroundControl.airmapSupported ? "qrc:/airmap/expand.svg" : ""
702
                        color:                  "white"
703
                        visible:                QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
704 705 706 707 708 709
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                    }
                    MouseArea {
                        anchors.fill:   parent
710
                        enabled:        QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
711
                        onClicked: {
712
                            QGroundControl.airspaceManager.airspaceVisible = false
Gus Grubba's avatar
Gus Grubba committed
713 714
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
715
                }
Gus Grubba's avatar
Gus Grubba committed
716 717 718 719 720
                //-------------------------------------------------------
                // Mission Controls (Expanded)
                Rectangle {
                    id:         planExpanded
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
721
                    height:     (!planControlColapsed || !_airspaceEnabled) ? bar.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
722 723
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
Gus Grubba's avatar
Gus Grubba committed
724
                    visible:    (!planControlColapsed || !_airspaceEnabled) && QGroundControl.corePlugin.options.enablePlanViewSelector
Gus Grubba's avatar
Gus Grubba committed
725
                    Item {
Gus Grubba's avatar
Gus Grubba committed
726
                        height:             bar.height
Gus Grubba's avatar
Gus Grubba committed
727 728
                        anchors.left:       parent.left
                        anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
729
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
Gus Grubba's avatar
Gus Grubba committed
730
                        anchors.verticalCenter: parent.verticalCenter
Gus Grubba's avatar
Gus Grubba committed
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
                        QGCTabBar {
                            id:             bar
                            width:          parent.width
                            anchors.centerIn: parent
                            Component.onCompleted: {
                                currentIndex = 0
                            }
                            QGCTabButton {
                                text:       qsTr("Mission")
                            }
                            QGCTabButton {
                                text:       qsTr("Fence")
                                enabled:    _geoFenceController.supported
                            }
                            QGCTabButton {
                                text:       qsTr("Rally")
                                enabled:    _rallyPointController.supported
Gus Grubba's avatar
Gus Grubba committed
748 749 750 751 752 753 754 755 756 757 758 759
                            }
                        }
                    }
                }
            }
            //-------------------------------------------------------
            // Mission Item Editor
            Item {
                id:                     missionItemEditor
                anchors.left:           parent.left
                anchors.right:          parent.right
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
760
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
761 762 763 764
                anchors.bottom:         parent.bottom
                anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25
                visible:                _editingLayer == _layerMission && !planControlColapsed
                QGCListView {
Gus Grubba's avatar
Gus Grubba committed
765 766 767 768 769 770 771 772
                    id:                 missionItemEditorListView
                    anchors.fill:       parent
                    spacing:            ScreenTools.defaultFontPixelHeight / 4
                    orientation:        ListView.Vertical
                    model:              _missionController.visualItems
                    cacheBuffer:        Math.max(height * 2, 0)
                    clip:               true
                    currentIndex:       _missionController.currentPlanViewIndex
Gus Grubba's avatar
Gus Grubba committed
773
                    highlightMoveDuration: 250
Gus Grubba's avatar
Gus Grubba committed
774
                    visible:            _editingLayer == _layerMission && !planControlColapsed
Gus Grubba's avatar
Gus Grubba committed
775 776
                    //-- List Elements
                    delegate: MissionItemEditor {
Gus Grubba's avatar
Gus Grubba committed
777
                        map:            editorMap
Gus Grubba's avatar
Gus Grubba committed
778
                        masterController:  _planMasterController
Gus Grubba's avatar
Gus Grubba committed
779 780 781 782
                        missionItem:    object
                        width:          parent.width
                        readOnly:       false
                        onClicked:      _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false)
Gus Grubba's avatar
Gus Grubba committed
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
                        onRemove: {
                            var removeIndex = index
                            _missionController.removeMissionItem(removeIndex)
                            if (removeIndex >= _missionController.visualItems.count) {
                                removeIndex--
                            }
                            _missionController.setCurrentPlanViewIndex(removeIndex, true)
                        }
                        onInsertWaypoint:       insertSimpleMissionItem(editorMap.center, index)
                        onInsertComplexItem:    insertComplexMissionItem(complexItemName, editorMap.center, index)
                    }
                }
            }
            // GeoFence Editor
            GeoFenceEditor {
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
799
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Don Gagne's avatar
Don Gagne committed
800
                anchors.bottom:         parent.bottom
Gus Grubba's avatar
Gus Grubba committed
801 802 803 804 805 806 807 808 809 810
                anchors.left:           parent.left
                anchors.right:          parent.right
                myGeoFenceController:   _geoFenceController
                flightMap:              editorMap
                visible:                _editingLayer == _layerGeoFence
            }
            // Rally Point Editor
            RallyPointEditorHeader {
                id:                     rallyPointHeader
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
811
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
812 813 814 815 816 817 818 819
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints
                controller:             _rallyPointController
            }
            RallyPointItemEditor {
                id:                     rallyPointEditor
                anchors.top:            rallyPointHeader.bottom
Gus Grubba's avatar
Gus Grubba committed
820
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
821 822 823 824 825
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints && _rallyPointController.points.count
                rallyPoint:             _rallyPointController.currentRallyPoint
                controller:             _rallyPointController
826
            }
Gus Grubba's avatar
Gus Grubba committed
827
        }
828 829 830 831 832 833 834

        MapScale {
            id:                 mapScale
            anchors.margins:    ScreenTools.defaultFontPixelHeight * (0.66)
            anchors.bottom:     waypointValuesDisplay.visible ? waypointValuesDisplay.top : parent.bottom
            anchors.left:       parent.left
            mapControl:         editorMap
835
            visible:            _toolStripBottom < y
836 837 838 839 840 841
        }

        MissionItemStatus {
            id:                 waypointValuesDisplay
            anchors.margins:    ScreenTools.defaultFontPixelWidth
            anchors.left:       parent.left
842
            height:             ScreenTools.defaultFontPixelHeight * 7
843
            maxWidth:           parent.width - rightPanel.width - x
844
            anchors.bottom:     parent.bottom
845
            missionItems:       _missionController.visualItems
846
            visible:            _editingLayer === _layerMission && (_toolStripBottom + mapScale.height) < y && QGroundControl.corePlugin.options.showMissionStatus
847
        }
Gus Grubba's avatar
Gus Grubba committed
848
    }
849

850 851 852 853
    Component {
        id: syncLoadFromVehicleOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
Don Gagne's avatar
Don Gagne committed
854
            message:   qsTr("You have unsaved/unsent changes. Loading from the Vehicle will lose these changes. Are you sure you want to load from the Vehicle?")
855 856
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
857
                _planMasterController.loadFromVehicle()
858 859 860 861 862 863 864 865
            }
        }
    }

    Component {
        id: syncLoadFromFileOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
DonLakeFlyer's avatar
DonLakeFlyer committed
866
            message:   qsTr("You have unsaved/unsent changes. Loading from a file will lose these changes. Are you sure you want to load from a file?")
867 868
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
869
                _planMasterController.loadFromSelectedFile()
870 871 872 873
            }
        }
    }

874 875 876
    Component {
        id: removeAllPromptDialog
        QGCViewMessage {
877
            message: qsTr("Are you sure you want to remove all items and create a new plan? ") +
878
                     (_planMasterController.offline ? "" : qsTr("This will also remove all items from the vehicle."))
879
            function accept() {
880
                if (_planMasterController.offline) {
Gus Grubba's avatar
Gus Grubba committed
881
                    _planMasterController.removeAll()
882
                } else {
Gus Grubba's avatar
Gus Grubba committed
883
                    _planMasterController.removeAllFromVehicle()
884
                }
885 886 887 888 889
                hideDialog()
            }
        }
    }

890 891 892 893 894
    Component {
        id: clearVehicleMissionDialog
        QGCViewMessage {
            message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?")
            function accept() {
Gus Grubba's avatar
Gus Grubba committed
895
                _planMasterController.removeAllFromVehicle()
896 897 898 899 900
                hideDialog()
            }
        }
    }

901 902 903 904 905 906 907 908 909 910 911
    //- ToolStrip DropPanel Components

    Component {
        id: centerMapDropPanel

        CenterMapDropPanel {
            map:            editorMap
            fitFunctions:   mapFitFunctions
        }
    }

912 913 914 915 916 917 918 919 920
    Component {
        id: patternDropPanel

        ColumnLayout {
            spacing:    ScreenTools.defaultFontPixelWidth * 0.5

            QGCLabel { text: qsTr("Create complex pattern:") }

            Repeater {
921
                model: _missionController.complexMissionItemNames
922 923 924 925 926 927

                QGCButton {
                    text:               modelData
                    Layout.fillWidth:   true

                    onClicked: {
928
                        addComplexItem(modelData)
929 930 931 932
                        dropPanel.hide()
                    }
                }
            }
933 934 935 936 937 938 939 940 941 942 943 944 945

            Rectangle {
                width:              parent.width * 0.8
                height:             1
                color:              qgcPal.text
                opacity:            0.5
                Layout.fillWidth:   true
                Layout.columnSpan:  2
            }

            QGCButton {
                text:               qsTr("Load KML/SHP...")
                Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
946
                enabled:            !_planMasterController.syncInProgress
947
                onClicked: {
Gus Grubba's avatar
Gus Grubba committed
948
                    _planMasterController.loadShapeFromSelectedFile()
949 950 951
                    dropPanel.hide()
                }
            }
952 953
        } // Column
    }
954 955

    Component {
956
        id: syncDropPanel
957

958 959 960
        Column {
            id:         columnHolder
            spacing:    _margin
961

962
            property string _overwriteText: (_editingLayer == _layerMission) ? qsTr("Mission overwrite") : ((_editingLayer == _layerGeoFence) ? qsTr("GeoFence overwrite") : qsTr("Rally Points overwrite"))
963

964 965 966
            QGCLabel {
                width:      sendSaveGrid.width
                wrapMode:   Text.WordWrap
Gus Grubba's avatar
Gus Grubba committed
967
                text:       _planMasterController.dirty ?
Gus Grubba's avatar
Gus Grubba committed
968
                                (activeVehicle ?
969 970 971 972
                                     qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file:") :
                                     qsTr("You have unsaved changes.")
                                ) :
                                qsTr("Plan File:")
973 974
            }

975 976 977 978 979 980
            GridLayout {
                id:                 sendSaveGrid
                columns:            2
                anchors.margins:    _margin
                rowSpacing:         _margin
                columnSpacing:      ScreenTools.defaultFontPixelWidth
981

982
                QGCButton {
983
                    text:               qsTr("New...")
984
                    Layout.fillWidth:   true
985
                    enabled:            _planMasterController.containsItems
986
                    onClicked:  {
987
                        dropPanel.hide()
988
                        mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
989 990
                    }
                }
991

992
                QGCButton {
993
                    text:               qsTr("Open...")
994
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
995
                    enabled:            !_planMasterController.syncInProgress
996 997
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
998
                        if (_planMasterController.dirty) {
999
                            mainWindow.showComponentDialog(syncLoadFromFileOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1000
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1001
                            _planMasterController.loadFromSelectedFile()
1002 1003 1004
                        }
                    }
                }
1005

1006
                QGCButton {
1007
                    text:               qsTr("Save")
1008
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1009
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.currentPlanFile !== ""
1010 1011
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1012 1013
                        if(_planMasterController.currentPlanFile !== "") {
                            _planMasterController.saveToCurrent()
1014
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1015
                            _planMasterController.saveToSelectedFile()
1016
                        }
1017 1018 1019 1020
                    }
                }

                QGCButton {
1021
                    text:               qsTr("Save As...")
1022
                    Layout.fillWidth:   true
1023
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.containsItems
1024 1025
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1026
                        _planMasterController.saveToSelectedFile()
1027 1028 1029 1030
                    }
                }

                QGCButton {
1031
                    text:               qsTr("Save Mission Waypoints As KML...")
1032
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1033
                    enabled:            !_planMasterController.syncInProgress && _visualItems.count > 1
1034
                    onClicked: {
1035
                        // First point does not count
1036
                        if (_visualItems.count < 2) {
1037
                            mainWindow.showComponentDialog(noItemForKML, qsTr("KML"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
1038 1039
                            return
                        }
1040
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1041
                        _planMasterController.saveKmlToSelectedFile()
1042 1043
                    }
                }
1044

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
                Rectangle {
                    width:              parent.width * 0.8
                    height:             1
                    color:              qgcPal.text
                    opacity:            0.5
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
                }

1055
                QGCButton {
1056
                    text:               qsTr("Upload")
1057
                    Layout.fillWidth:   true
1058
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress && _planMasterController.containsItems
1059 1060
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
1061
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1062
                        _planMasterController.upload()
1063 1064
                    }
                }
1065 1066 1067 1068

                QGCButton {
                    text:               qsTr("Download")
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1069
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1070 1071 1072
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1073
                        if (_planMasterController.dirty) {
1074
                            mainWindow.showComponentDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1075
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1076
                            _planMasterController.loadFromVehicle()
1077 1078 1079 1080 1081 1082 1083 1084
                        }
                    }
                }

                QGCButton {
                    text:               qsTr("Clear Vehicle Mission")
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1085
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1086 1087 1088
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
1089
                        mainWindow.showComponentDialog(clearVehicleMissionDialog, text, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1090 1091 1092
                    }
                }

1093
            }
1094 1095
        }
    }
Gus Grubba's avatar
Gus Grubba committed
1096
}