PlanView.qml 49.8 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
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
12
import QtQuick.Dialogs  1.2
13 14 15
import QtLocation       5.3
import QtPositioning    5.3
import QtQuick.Layouts  1.2
16
import QtQuick.Window   2.2
Don Gagne's avatar
Don Gagne committed
17

18 19 20 21 22 23 24 25 26 27 28
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
29

30
Item {
31

Gus Grubba's avatar
Gus Grubba committed
32 33
    property bool planControlColapsed: false

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

Gus Grubba's avatar
Gus Grubba committed
42
    property bool   _airspaceEnabled:                    QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
Gus Grubba's avatar
Gus Grubba committed
43 44 45 46 47 48 49 50
    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
51
    property int    _editingLayer:                      bar.currentIndex ? _layers[bar.currentIndex] : _layerMission
Gus Grubba's avatar
Gus Grubba committed
52
    property int    _toolStripBottom:                   toolStrip.height + toolStrip.y
53
    property var    _appSettings:                       QGroundControl.settingsManager.appSettings
54

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

57 58 59 60
    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?")
61

62 63
    function addComplexItem(complexItemName) {
        var coordinate = editorMap.center
64
        coordinate.latitude  = coordinate.latitude.toFixed(_decimalPlaces)
65
        coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
66
        coordinate.altitude  = coordinate.altitude.toFixed(_decimalPlaces)
67
        insertComplexMissionItem(complexItemName, coordinate, _missionController.visualItems.count)
68 69 70
    }

    function insertComplexMissionItem(complexItemName, coordinate, index) {
71
        var sequenceNumber = _missionController.insertComplexMissionItem(complexItemName, coordinate, index)
72
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
73 74
    }

75 76
    function insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index) {
        var sequenceNumber = _missionController.insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index)
77 78 79
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
    }

80
    function updateAirspace(reset) {
81 82 83 84
        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) {
85
                QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
86 87 88 89
            }
        }
    }

90 91 92 93 94
    property bool _firstMissionLoadComplete:    false
    property bool _firstFenceLoadComplete:      false
    property bool _firstRallyLoadComplete:      false
    property bool _firstLoadComplete:           false

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

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

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

    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()
130
                _missionController.applyDefaultMissionAltitude()
DonLakeFlyer's avatar
DonLakeFlyer committed
131 132 133 134
            }
        }
    }

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
    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
154
                        activeVehicle.flightMode = activeVehicle.pauseFlightMode
155
                        _planMasterController.sendToVehicle()
156
                        hideDialog()
157 158 159 160 161 162
                    }
                }
            }
        }
    }

Gus Grubba's avatar
Gus Grubba committed
163
    Connections {
164
        target: QGroundControl.airspaceManager
165
        onAirspaceVisibleChanged: {
166
            planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Gus Grubba's avatar
Gus Grubba committed
167 168 169
        }
    }

170 171 172 173 174 175 176
    Component {
        id: noItemForKML
        QGCViewMessage {
            message:    qsTr("You need at least one item to create a KML.")
        }
    }

177
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
178
        id: _planMasterController
179

180
        Component.onCompleted: {
181
            _planMasterController.start(false /* flyView */)
182
            _missionController.setCurrentPlanViewIndex(0, true)
Gus Grubba's avatar
Gus Grubba committed
183
            mainWindow.planMasterControllerPlan = _planMasterController
184 185
        }

186
        function waitingOnDataMessage() {
187
            mainWindow.showMessageDialog(qsTr("Unable to Save/Upload"), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
188 189
        }

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

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

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

226
        function fitViewportToItems() {
227
            mapFitFunctions.fitMapViewportToMissionItems()
228
        }
229

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

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

255 256
    Connections {
        target: _missionController
257

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

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

274 275 276 277 278 279 280
    /// 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
281
        toolStrip.lastClickedButton.checked = false
282 283
    }

284 285
    property int _moveDialogMissionItemIndex

286 287
    QGCFileDialog {
        id:             fileDialog
Gus Grubba's avatar
Gus Grubba committed
288
        folder:         _appSettings ? _appSettings.missionSavePath : ""
289

290 291
        property bool planFiles: true    ///< true: working with plan files, false: working with kml file

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

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

326
    property string polygonSelectPatternFile
327
    Component {
328
        id: patternPolygonSelectDialog
329 330 331 332 333 334 335 336
        QGCViewDialog {
            function accept() {
                var complexItemName
                if (surveyRadio.checked) {
                    complexItemName = _missionController.surveyComplexItemName
                } else {
                    complexItemName = _missionController.structureScanComplexItemName
                }
337
                insertComplexMissionItemFromKMLOrSHP(complexItemName, polygonSelectPatternFile, -1)
338 339 340 341 342 343 344 345 346 347
                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
348
                    text:           qsTr("Create which pattern type?")
349 350 351 352 353 354 355 356 357 358 359 360 361
                }
                QGCRadioButton {
                    id:             surveyRadio
                    text:           qsTr("Survey")
                    checked:        true
                }
                QGCRadioButton {
                    text:           qsTr("Structure Scan")
                }
            }
        }
    }

362 363 364 365 366
    Component {
        id: moveDialog
        QGCViewDialog {
            function accept() {
                var toIndex = toCombo.currentIndex
Gus Grubba's avatar
Gus Grubba committed
367
                if (toIndex === 0) {
368 369
                    toIndex = 1
                }
370
                _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
371 372 373 374 375 376 377 378 379 380 381
                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
382
                    text:           qsTr("Move the selected mission item to the be after following mission item:")
383 384 385 386
                }

                QGCComboBox {
                    id:             toCombo
387
                    model:          _visualItems.count
388 389 390 391 392 393
                    currentIndex:   _moveDialogMissionItemIndex
                }
            }
        }
    }

394
    Item {
Don Gagne's avatar
Don Gagne committed
395
        id:             panel
396
        anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
397

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

406
            // This is the center rectangle of the map which is not obscured by tools
DonLakeFlyer's avatar
DonLakeFlyer committed
407
            property rect centerViewport:   Qt.rect(_leftToolWidth + _margin, _toolsTopMargin, editorMap.width - _leftToolWidth - _rightToolWidth - (_margin * 2), mapScale.y - _margin - _toolsTopMargin)
408

409 410
            property real _leftToolWidth:       toolStrip.x + toolStrip.width
            property real _rightToolWidth:      rightPanel.width + rightPanel.anchors.rightMargin
411

412
            readonly property real animationDuration: 500
413

414 415
            // Initial map position duplicates Fly view position
            Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition
416

417 418 419 420 421 422
            Behavior on zoomLevel {
                NumberAnimation {
                    duration:       editorMap.animationDuration
                    easing.type:    Easing.InOutQuad
                }
            }
423

424 425
            QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }

426 427
            onZoomLevelChanged: updateAirspace(false)
            onCenterChanged:    updateAirspace(false)
428

429 430 431
            MouseArea {
                anchors.fill: parent
                onClicked: {
432 433
                    // Take focus to close any previous editing
                    editorMap.focus = true
434 435 436 437
                    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)
438

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

DonLakeFlyer's avatar
DonLakeFlyer committed
457 458 459 460 461 462 463 464 465 466 467 468
            PlanStartOverlay {
                id:                     startOverlay
                x:                      editorMap.centerViewport.left
                y:                      editorMap.centerViewport.top
                width:                  editorMap.centerViewport.width
                height:                 editorMap.centerViewport.height
                z:                      QGroundControl.zOrderMapItems + 2
                visible:                !_planMasterController.containsItems
                planMasterController:   _planMasterController
                mapControl:             editorMap
            }

469 470
            // Add the mission item visuals to the map
            Repeater {
471
                model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
472 473
                delegate: MissionItemMapVisual {
                    map:        editorMap
474
                    onClicked:  _missionController.setCurrentPlanViewIndex(sequenceNumber, false)
475
                    visible:    _editingLayer == _layerMission
476
                }
477
            }
478

479 480
            // Add lines between waypoints
            MissionLineView {
481
                model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
482
            }
483

484 485 486 487 488 489
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.directionArrows : undefined

                delegate: MapLineArrow {
                    fromCoord:      object ? object.coordinate1 : undefined
                    toCoord:        object ? object.coordinate2 : undefined
490 491 492 493 494 495 496 497 498 499 500 501 502
                    arrowPosition:  3
                    z:              QGroundControl.zOrderWaypointLines + 1
                }
            }

            // UI for splitting the current segment
            MapQuickItem {
                id:             splitSegmentItem
                anchorPoint.x:  sourceItem.width / 2
                anchorPoint.y:  sourceItem.height / 2
                z:              QGroundControl.zOrderWaypointLines + 1

                sourceItem: SplitIndicator {
Don Gagne's avatar
Don Gagne committed
503
                    onClicked:  insertSimpleMissionItem(splitSegmentItem.coordinate, _missionController.visualItemIndexFromSequenceNumber(_missionController.currentPlanViewIndex))
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
                }

                function _updateSplitCoord() {
                    if (_missionController.splitSegment) {
                        var distance = _missionController.splitSegment.coordinate1.distanceTo(_missionController.splitSegment.coordinate2)
                        var azimuth = _missionController.splitSegment.coordinate1.azimuthTo(_missionController.splitSegment.coordinate2)
                        splitSegmentItem.coordinate = _missionController.splitSegment.coordinate1.atDistanceAndAzimuth(distance / 2, azimuth)
                    } else {
                        coordinate = QtPositioning.coordinate()
                    }
                }

                Connections {
                    target:                 _missionController
                    onSplitSegmentChanged:  splitSegmentItem._updateSplitCoord()
                }

                Connections {
                    target:                 _missionController.splitSegment
                    onCoordinate1Changed:   splitSegmentItem._updateSplitCoord()
                    onCoordinate2Changed:   splitSegmentItem._updateSplitCoord()
525 526 527
                }
            }

528 529 530 531 532 533 534
            // Add the vehicles to the map
            MapItemView {
                model: QGroundControl.multiVehicleManager.vehicles
                delegate:
                    VehicleMapItem {
                    vehicle:        object
                    coordinate:     object.coordinate
535
                    map:            editorMap
536 537
                    size:           ScreenTools.defaultFontPixelHeight * 3
                    z:              QGroundControl.zOrderMapItems - 1
538
                }
539
            }
540

541 542
            GeoFenceMapVisuals {
                map:                    editorMap
543
                myGeoFenceController:   _geoFenceController
544
                interactive:            _editingLayer == _layerGeoFence
545
                homePosition:           _missionController.plannedHomePosition
546 547
                planView:               true
            }
548

549 550
            RallyPointMapVisuals {
                map:                    editorMap
551
                myRallyPointController: _rallyPointController
552 553
                interactive:            _editingLayer == _layerRallyPoints
                planView:               true
554
            }
555

556 557
            // Airspace overlap support
            MapItemView {
558
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.circles : []
559 560 561
                delegate: MapCircle {
                    center:         object.center
                    radius:         object.radius
562
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
563 564
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
565 566 567 568
                }
            }

            MapItemView {
569
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : []
570 571
                delegate: MapPolygon {
                    path:           object.polygon
572
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
573 574
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
575 576
                }
            }
577
        }
578

579 580
        //-----------------------------------------------------------
        // Left tool strip
Gus Grubba's avatar
Gus Grubba committed
581
        ToolStrip {
582
            id:                 toolStrip
583
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
584
            anchors.left:       parent.left
DonLakeFlyer's avatar
DonLakeFlyer committed
585
            anchors.topMargin:  _toolsTopMargin
586 587
            anchors.top:        parent.top
            z:                  QGroundControl.zOrderWidgets
Gus Grubba's avatar
Gus Grubba committed
588
            maxHeight:          mapScale.y - toolStrip.y
589

Gus Grubba's avatar
Gus Grubba committed
590
            property bool _isRally:     _editingLayer == _layerRallyPoints
591

Gus Grubba's avatar
Gus Grubba committed
592 593 594 595 596 597
            model: [
                {
                    name:               qsTr("Fly"),
                    iconSource:         "/qmlimages/PaperPlane.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
598
                },
599
                {
Gus Grubba's avatar
Gus Grubba committed
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
                    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
                }
            ]
638

Gus Grubba's avatar
Gus Grubba committed
639 640
            onClicked: {
                switch (index) {
641 642 643 644
                case 0:
                    mainWindow.showFlyView()
                    break;
                case 2:
Gus Grubba's avatar
Gus Grubba committed
645 646 647 648 649 650
                    if(_addWaypointOnClick) {
                        //-- Toggle it off
                        _addWaypointOnClick = false
                        _addROIOnClick = false
                        setChecked(index, false)
                    } else {
651
                        _addWaypointOnClick = checked
652
                        _addROIOnClick = false
Gus Grubba's avatar
Gus Grubba committed
653 654
                    }
                    break
655
                case 3:
Gus Grubba's avatar
Gus Grubba committed
656 657 658
                    _addROIOnClick = checked
                    _addWaypointOnClick = false
                    break
659
                case 4:
Gus Grubba's avatar
Gus Grubba committed
660 661 662 663
                    if (_singleComplexItem) {
                        addComplexItem(_missionController.complexMissionItemNames[0])
                    }
                    break
664 665
                }
            }
Gus Grubba's avatar
Gus Grubba committed
666
        }
667

Gus Grubba's avatar
Gus Grubba committed
668
        //-----------------------------------------------------------
669 670 671
        // Right pane for mission editing controls
        Rectangle {
            id:                 rightPanel
672
            height:             parent.height
673 674
            width:              _rightPanelWidth
            color:              qgcPal.window
675
            opacity:            planExpanded.visible ? 0.2 : 0
Gus Grubba's avatar
Gus Grubba committed
676 677 678
            anchors.bottom:     parent.bottom
            anchors.right:      parent.right
            anchors.rightMargin: ScreenTools.defaultFontPixelWidth
679
        }
Gus Grubba's avatar
Gus Grubba committed
680 681
        //-------------------------------------------------------
        // Right Panel Controls
682
        Item {
Gus Grubba's avatar
Gus Grubba committed
683
            anchors.fill:           rightPanel
DonLakeFlyer's avatar
DonLakeFlyer committed
684
            anchors.topMargin:      _toolsTopMargin
Gus Grubba's avatar
Gus Grubba committed
685 686 687
            DeadMouseArea {
                anchors.fill:   parent
            }
Gus Grubba's avatar
Gus Grubba committed
688 689
            Column {
                id:                 rightControls
Gus Grubba's avatar
Gus Grubba committed
690
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
691 692
                anchors.left:       parent.left
                anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
693 694 695 696
                anchors.top:        parent.top
                //-------------------------------------------------------
                // Airmap Airspace Control
                AirspaceControl {
Gus Grubba's avatar
Gus Grubba committed
697 698
                    id:             airspaceControl
                    width:          parent.width
699
                    visible:        _airspaceEnabled
700
                    planView:       true
701
                    showColapse:    true
702
                }
Gus Grubba's avatar
Gus Grubba committed
703 704 705 706
                //-------------------------------------------------------
                // Mission Controls (Colapsed)
                Rectangle {
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
707
                    height:     planControlColapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
708 709
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
710
                    visible:    planControlColapsed && _airspaceEnabled
Gus Grubba's avatar
Gus Grubba committed
711 712 713 714 715 716 717
                    Row {
                        id:                     colapsedRow
                        spacing:                ScreenTools.defaultFontPixelWidth
                        anchors.left:           parent.left
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                        QGCColoredImage {
718 719 720 721 722
                            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
723 724 725
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        QGCLabel {
726 727
                            text:               qsTr("Plan")
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
728
                            anchors.verticalCenter: parent.verticalCenter
729 730
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
731 732 733 734
                    QGCColoredImage {
                        width:                  height
                        height:                 ScreenTools.defaultFontPixelWidth * 2.5
                        sourceSize.height:      height
735
                        source:                 QGroundControl.airmapSupported ? "qrc:/airmap/expand.svg" : ""
736
                        color:                  "white"
737
                        visible:                QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
738 739 740 741 742 743
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                    }
                    MouseArea {
                        anchors.fill:   parent
744
                        enabled:        QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
745
                        onClicked: {
746
                            QGroundControl.airspaceManager.airspaceVisible = false
Gus Grubba's avatar
Gus Grubba committed
747 748
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
749
                }
Gus Grubba's avatar
Gus Grubba committed
750 751 752 753 754
                //-------------------------------------------------------
                // Mission Controls (Expanded)
                Rectangle {
                    id:         planExpanded
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
755
                    height:     (!planControlColapsed || !_airspaceEnabled) ? bar.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
756 757
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
Gus Grubba's avatar
Gus Grubba committed
758
                    visible:    (!planControlColapsed || !_airspaceEnabled) && QGroundControl.corePlugin.options.enablePlanViewSelector
Gus Grubba's avatar
Gus Grubba committed
759
                    Item {
Gus Grubba's avatar
Gus Grubba committed
760
                        height:             bar.height
Gus Grubba's avatar
Gus Grubba committed
761 762
                        anchors.left:       parent.left
                        anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
763
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
Gus Grubba's avatar
Gus Grubba committed
764
                        anchors.verticalCenter: parent.verticalCenter
Gus Grubba's avatar
Gus Grubba committed
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
                        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
782 783 784 785 786 787 788 789 790 791 792 793
                            }
                        }
                    }
                }
            }
            //-------------------------------------------------------
            // 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
794
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
795 796 797 798
                anchors.bottom:         parent.bottom
                anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25
                visible:                _editingLayer == _layerMission && !planControlColapsed
                QGCListView {
Gus Grubba's avatar
Gus Grubba committed
799 800 801 802 803 804 805 806
                    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
807
                    highlightMoveDuration: 250
Gus Grubba's avatar
Gus Grubba committed
808
                    visible:            _editingLayer == _layerMission && !planControlColapsed
Gus Grubba's avatar
Gus Grubba committed
809 810
                    //-- List Elements
                    delegate: MissionItemEditor {
Gus Grubba's avatar
Gus Grubba committed
811
                        map:            editorMap
Gus Grubba's avatar
Gus Grubba committed
812
                        masterController:  _planMasterController
Gus Grubba's avatar
Gus Grubba committed
813 814 815 816
                        missionItem:    object
                        width:          parent.width
                        readOnly:       false
                        onClicked:      _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false)
Gus Grubba's avatar
Gus Grubba committed
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
                        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
833
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Don Gagne's avatar
Don Gagne committed
834
                anchors.bottom:         parent.bottom
Gus Grubba's avatar
Gus Grubba committed
835 836 837 838 839 840 841 842 843 844
                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
845
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
846 847 848 849 850 851 852 853
                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
854
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
855 856 857 858 859
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints && _rallyPointController.points.count
                rallyPoint:             _rallyPointController.currentRallyPoint
                controller:             _rallyPointController
860
            }
Gus Grubba's avatar
Gus Grubba committed
861
        }
862 863

        MapScale {
864 865 866 867 868 869 870 871 872 873 874
            id:                     mapScale
            anchors.margins:        ScreenTools.defaultFontPixelHeight * (0.66)
            anchors.bottom:         waypointValuesDisplay.visible ? waypointValuesDisplay.top : parent.bottom
            anchors.left:           parent.left
            mapControl:             editorMap
            buttonsOnLeft:          true
            terrainButtonVisible:   true
            visible:                _toolStripBottom < y && _editingLayer === _layerMission
            terrainButtonChecked:   waypointValuesDisplay.visible

            onTerrainButtonClicked: waypointValuesDisplay.toggleVisible()
875 876 877 878 879 880
        }

        MissionItemStatus {
            id:                 waypointValuesDisplay
            anchors.margins:    ScreenTools.defaultFontPixelWidth
            anchors.left:       parent.left
881
            height:             ScreenTools.defaultFontPixelHeight * 7
882
            maxWidth:           parent.width - rightPanel.width - x
883
            anchors.bottom:     parent.bottom
884
            missionItems:       _missionController.visualItems
885 886 887 888 889 890 891
            visible:            _internalVisible && _editingLayer === _layerMission && (_toolStripBottom + mapScale.height) < y && QGroundControl.corePlugin.options.showMissionStatus

            property bool _internalVisible: false

            function toggleVisible() {
                _internalVisible = !_internalVisible
            }
892
        }
Gus Grubba's avatar
Gus Grubba committed
893
    }
894

895 896 897 898
    Component {
        id: syncLoadFromVehicleOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
Don Gagne's avatar
Don Gagne committed
899
            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?")
900 901
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
902
                _planMasterController.loadFromVehicle()
903 904 905 906 907 908 909 910
            }
        }
    }

    Component {
        id: syncLoadFromFileOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
DonLakeFlyer's avatar
DonLakeFlyer committed
911
            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?")
912 913
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
914
                _planMasterController.loadFromSelectedFile()
915 916 917 918
            }
        }
    }

919 920 921
    Component {
        id: removeAllPromptDialog
        QGCViewMessage {
922
            message: qsTr("Are you sure you want to remove all items and create a new plan? ") +
923
                     (_planMasterController.offline ? "" : qsTr("This will also remove all items from the vehicle."))
924
            function accept() {
925
                if (_planMasterController.offline) {
Gus Grubba's avatar
Gus Grubba committed
926
                    _planMasterController.removeAll()
927
                } else {
Gus Grubba's avatar
Gus Grubba committed
928
                    _planMasterController.removeAllFromVehicle()
929
                }
930
                _missionController.setCurrentPlanViewIndex(0, true)
DonLakeFlyer's avatar
DonLakeFlyer committed
931
                startOverlay.visible = true
932 933 934 935 936
                hideDialog()
            }
        }
    }

937 938 939 940 941
    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
942
                _planMasterController.removeAllFromVehicle()
943
                _missionController.setCurrentPlanViewIndex(0, true)
DonLakeFlyer's avatar
DonLakeFlyer committed
944
                startOverlay.visible = true
945 946 947 948 949
                hideDialog()
            }
        }
    }

950 951 952 953 954 955 956 957 958 959 960
    //- ToolStrip DropPanel Components

    Component {
        id: centerMapDropPanel

        CenterMapDropPanel {
            map:            editorMap
            fitFunctions:   mapFitFunctions
        }
    }

961 962 963 964 965 966 967 968 969
    Component {
        id: patternDropPanel

        ColumnLayout {
            spacing:    ScreenTools.defaultFontPixelWidth * 0.5

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

            Repeater {
970
                model: _missionController.complexMissionItemNames
971 972 973 974 975 976

                QGCButton {
                    text:               modelData
                    Layout.fillWidth:   true

                    onClicked: {
977
                        addComplexItem(modelData)
978 979 980 981
                        dropPanel.hide()
                    }
                }
            }
982 983 984 985 986 987 988 989 990 991 992 993 994

            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
995
                enabled:            !_planMasterController.syncInProgress
996
                onClicked: {
Gus Grubba's avatar
Gus Grubba committed
997
                    _planMasterController.loadShapeFromSelectedFile()
998 999 1000
                    dropPanel.hide()
                }
            }
1001 1002
        } // Column
    }
1003 1004

    Component {
1005
        id: syncDropPanel
1006

1007 1008 1009
        Column {
            id:         columnHolder
            spacing:    _margin
1010

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

1013 1014 1015
            QGCLabel {
                width:      sendSaveGrid.width
                wrapMode:   Text.WordWrap
Gus Grubba's avatar
Gus Grubba committed
1016
                text:       _planMasterController.dirty ?
Gus Grubba's avatar
Gus Grubba committed
1017
                                (activeVehicle ?
1018 1019 1020 1021
                                     qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file:") :
                                     qsTr("You have unsaved changes.")
                                ) :
                                qsTr("Plan File:")
1022 1023
            }

1024 1025 1026 1027 1028 1029
            GridLayout {
                id:                 sendSaveGrid
                columns:            2
                anchors.margins:    _margin
                rowSpacing:         _margin
                columnSpacing:      ScreenTools.defaultFontPixelWidth
1030

1031
                QGCButton {
1032
                    text:               qsTr("New...")
1033
                    Layout.fillWidth:   true
1034
                    enabled:            _planMasterController.containsItems
1035
                    onClicked:  {
1036
                        dropPanel.hide()
1037
                        mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
1038 1039
                    }
                }
1040

1041
                QGCButton {
1042
                    text:               qsTr("Open...")
1043
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1044
                    enabled:            !_planMasterController.syncInProgress
1045 1046
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1047
                        if (_planMasterController.dirty) {
1048
                            mainWindow.showComponentDialog(syncLoadFromFileOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1049
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1050
                            _planMasterController.loadFromSelectedFile()
1051 1052 1053
                        }
                    }
                }
1054

1055
                QGCButton {
1056
                    text:               qsTr("Save")
1057
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1058
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.currentPlanFile !== ""
1059 1060
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1061 1062
                        if(_planMasterController.currentPlanFile !== "") {
                            _planMasterController.saveToCurrent()
1063
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1064
                            _planMasterController.saveToSelectedFile()
1065
                        }
1066 1067 1068 1069
                    }
                }

                QGCButton {
1070
                    text:               qsTr("Save As...")
1071
                    Layout.fillWidth:   true
1072
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.containsItems
1073 1074
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1075
                        _planMasterController.saveToSelectedFile()
1076 1077 1078 1079
                    }
                }

                QGCButton {
1080
                    text:               qsTr("Save Mission Waypoints As KML...")
1081
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1082
                    enabled:            !_planMasterController.syncInProgress && _visualItems.count > 1
1083
                    onClicked: {
1084
                        // First point does not count
1085
                        if (_visualItems.count < 2) {
1086
                            mainWindow.showComponentDialog(noItemForKML, qsTr("KML"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
1087 1088
                            return
                        }
1089
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1090
                        _planMasterController.saveKmlToSelectedFile()
1091 1092
                    }
                }
1093

1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
                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
                }

1104
                QGCButton {
1105
                    text:               qsTr("Upload")
1106
                    Layout.fillWidth:   true
1107
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress && _planMasterController.containsItems
1108 1109
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
1110
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1111
                        _planMasterController.upload()
1112 1113
                    }
                }
1114 1115 1116 1117

                QGCButton {
                    text:               qsTr("Download")
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1118
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1119 1120 1121
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1122
                        if (_planMasterController.dirty) {
1123
                            mainWindow.showComponentDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1124
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1125
                            _planMasterController.loadFromVehicle()
1126 1127 1128 1129 1130 1131 1132 1133
                        }
                    }
                }

                QGCButton {
                    text:               qsTr("Clear Vehicle Mission")
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1134
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1135 1136 1137
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
1138
                        mainWindow.showComponentDialog(clearVehicleMissionDialog, text, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1139 1140 1141
                    }
                }

1142
            }
1143 1144
        }
    }
Gus Grubba's avatar
Gus Grubba committed
1145
}