PlanView.qml 53 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
    id: _root
32

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

35 36
    readonly property int   _decimalPlaces:             8
    readonly property real  _margin:                    ScreenTools.defaultFontPixelHeight * 0.5
37
    readonly property real  _toolsMargin:               ScreenTools.defaultFontPixelWidth * 0.75
Gus Grubba's avatar
Gus Grubba committed
38
    readonly property real  _radius:                    ScreenTools.defaultFontPixelWidth  * 0.5
39 40 41
    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
42

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

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

59 60 61 62
    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?")
63

64
    function mapCenter() {
65
        var coordinate = editorMap.center
66
        coordinate.latitude  = coordinate.latitude.toFixed(_decimalPlaces)
67
        coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
68
        coordinate.altitude  = coordinate.altitude.toFixed(_decimalPlaces)
69 70 71
        return coordinate
    }

72
    function updateAirspace(reset) {
73 74 75 76
        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) {
77
                QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
78 79 80 81
            }
        }
    }

82 83 84 85 86
    property bool _firstMissionLoadComplete:    false
    property bool _firstFenceLoadComplete:      false
    property bool _firstRallyLoadComplete:      false
    property bool _firstLoadComplete:           false

87
    MapFitFunctions {
88
        id:                         mapFitFunctions  // The name for this id cannot be changed without breaking references outside of this code. Beware!
89 90
        map:                        editorMap
        usePlannedHomePosition:     true
91
        planMasterController:       _planMasterController
92 93
    }

94
    on_AirspaceEnabledChanged: {
95
        if(QGroundControl.airmapSupported) {
96 97
            if(_airspaceEnabled) {
                planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
98
                updateAirspace(true)
99 100 101
            } else {
                planControlColapsed = false
            }
102
        } else {
Gus Grubba's avatar
Gus Grubba committed
103 104 105 106
            planControlColapsed = false
        }
    }

107 108 109 110 111 112
    onVisibleChanged: {
        if (visible && !_planMasterController.containsItems) {
            toolStrip.simulateClick(toolStrip.fileButtonIndex)
        }
    }

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

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

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

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

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

175
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
176
        id: _planMasterController
177

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

184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
        function waitingOnIncompleteDataMessage(save) {
            var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
            mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan has incomplete items. Complete all items and %1 again.").arg(saveOrUpload))
        }

        function waitingOnTerrainDataMessage(save) {
            var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
            mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
        }

        function checkReadyForSaveUpload(save) {
            if (readyForSaveState() == VisualMissionItem.NotReadyForSaveData) {
                waitingOnIncompleteDataMessage(save)
                return false
            } else if (readyForSaveState() == VisualMissionItem.NotReadyForSaveTerrain) {
                waitingOnTerrainDataMessage(save)
                return false
            }
            return true
203 204
        }

205
        function upload() {
206
            if (!checkReadyForSaveUpload(false /* save */)) {
207 208
                return
            }
Gus Grubba's avatar
Gus Grubba committed
209
            if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
210
                mainWindow.showComponentDialog(activeMissionUploadDialogComponent, qsTr("Plan Upload"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
211
            } else {
212 213
                sendToVehicle()
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
214 215
        }

216
        function loadFromSelectedFile() {
217
            fileDialog.title =          qsTr("Select Plan File")
DonLakeFlyer's avatar
DonLakeFlyer committed
218
            fileDialog.planFiles =      true
219
            fileDialog.selectExisting = true
Gus Grubba's avatar
Gus Grubba committed
220
            fileDialog.nameFilters =    _planMasterController.loadNameFilters
221 222
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
223
            fileDialog.openForLoad()
224 225 226
        }

        function saveToSelectedFile() {
227
            if (!checkReadyForSaveUpload(true /* save */)) {
228 229
                return
            }
230
            fileDialog.title =          qsTr("Save Plan")
231
            fileDialog.planFiles =      true
232
            fileDialog.selectExisting = false
Gus Grubba's avatar
Gus Grubba committed
233
            fileDialog.nameFilters =    _planMasterController.saveNameFilters
234 235
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
236
            fileDialog.openForSave()
237 238
        }

239
        function fitViewportToItems() {
240
            mapFitFunctions.fitMapViewportToMissionItems()
241
        }
242 243

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

257 258
    Connections {
        target: _missionController
259

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

268 269 270 271 272 273 274 275 276
    function insertSimpleItemAfterCurrent(coordinate) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertSimpleMissionItem(coordinate, nextIndex, true /* makeCurrentItem */)
    }

    function insertROIAfterCurrent(coordinate) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertROIMissionItem(coordinate, nextIndex, true /* makeCurrentItem */)
        _addROIOnClick = false
277 278
    }

279 280 281
    function insertCancelROIAfterCurrent() {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertCancelROIMissionItem(nextIndex, true /* makeCurrentItem */)
282 283 284
        _addROIOnClick = false
    }

285 286 287 288 289
    function insertComplexItemAfterCurrent(complexItemName) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertComplexMissionItem(complexItemName, mapCenter(), nextIndex, true /* makeCurrentItem */)
    }

290 291 292 293 294
    function selectNextNotReady() {
        var foundCurrent = false
        for (var i=0; i<_missionController.visualItems.count; i++) {
            var vmi = _missionController.visualItems.get(i)
            if (vmi.readyForSaveState === VisualMissionItem.NotReadyForSaveData) {
295
                _missionController.setCurrentPlanViewSeqNum(vmi.sequenceNumber, true)
296 297 298 299 300
                break
            }
        }
    }

301 302
    property int _moveDialogMissionItemIndex

303 304
    QGCFileDialog {
        id:             fileDialog
Gus Grubba's avatar
Gus Grubba committed
305
        folder:         _appSettings ? _appSettings.missionSavePath : ""
306

307 308
        property bool planFiles: true    ///< true: working with plan files, false: working with kml file

309
        onAcceptedForSave: {
310
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
311
                _planMasterController.saveToFile(file)
312
            } else {
Gus Grubba's avatar
Gus Grubba committed
313
                _planMasterController.saveToKml(file)
314
            }
315
            close()
316 317
        }

318
        onAcceptedForLoad: {
319 320 321
            _planMasterController.loadFromFile(file)
            _planMasterController.fitViewportToItems()
            _missionController.setCurrentPlanViewSeqNum(0, true)
322
            close()
323 324 325
        }
    }

326 327 328 329 330
    Component {
        id: moveDialog
        QGCViewDialog {
            function accept() {
                var toIndex = toCombo.currentIndex
Gus Grubba's avatar
Gus Grubba committed
331
                if (toIndex === 0) {
332 333
                    toIndex = 1
                }
334
                _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
335 336 337 338 339 340 341 342 343 344 345
                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
346
                    text:           qsTr("Move the selected mission item to the be after following mission item:")
347 348 349 350
                }

                QGCComboBox {
                    id:             toCombo
351
                    model:          _visualItems.count
352 353 354 355 356 357
                    currentIndex:   _moveDialogMissionItemIndex
                }
            }
        }
    }

358
    Item {
Don Gagne's avatar
Don Gagne committed
359
        id:             panel
360
        anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
361

362
        FlightMap {
363 364 365 366 367
            id:                         editorMap
            anchors.fill:               parent
            mapName:                    "MissionEditor"
            allowGCSLocationCenter:     true
            allowVehicleLocationCenter: true
368
            planView:                   true
Don Gagne's avatar
Don Gagne committed
369

370
            // This is the center rectangle of the map which is not obscured by tools
371
            property rect centerViewport:   Qt.rect(_leftToolWidth + _margin, _toolsMargin, editorMap.width - _leftToolWidth - _rightToolWidth - (_margin * 2), mapScale.y - _margin - _toolsMargin)
372

373 374
            property real _leftToolWidth:       toolStrip.x + toolStrip.width
            property real _rightToolWidth:      rightPanel.width + rightPanel.anchors.rightMargin
375

376
            readonly property real animationDuration: 500
377

378 379
            // Initial map position duplicates Fly view position
            Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition
380

381 382 383 384 385 386
            Behavior on zoomLevel {
                NumberAnimation {
                    duration:       editorMap.animationDuration
                    easing.type:    Easing.InOutQuad
                }
            }
387

388 389
            QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }

390 391
            onZoomLevelChanged: updateAirspace(false)
            onCenterChanged:    updateAirspace(false)
392

393 394 395
            MouseArea {
                anchors.fill: parent
                onClicked: {
396 397
                    // Take focus to close any previous editing
                    editorMap.focus = true
398 399 400 401
                    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)
402

403 404 405
                    switch (_editingLayer) {
                    case _layerMission:
                        if (_addWaypointOnClick) {
406
                            insertSimpleItemAfterCurrent(coordinate)
407 408
                        } else if (_addROIOnClick) {
                            _addROIOnClick = false
409
                            insertROIAfterCurrent(coordinate)
410
                        }
411

412 413
                        break
                    case _layerRallyPoints:
Gus Grubba's avatar
Gus Grubba committed
414
                        if (_rallyPointController.supported && _addWaypointOnClick) {
415
                            _rallyPointController.addPoint(coordinate)
416
                        }
417
                        break
Don Gagne's avatar
Don Gagne committed
418
                    }
Don Gagne's avatar
Don Gagne committed
419
                }
420
            }
Don Gagne's avatar
Don Gagne committed
421

422 423
            // Add the mission item visuals to the map
            Repeater {
424
                model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
425 426
                delegate: MissionItemMapVisual {
                    map:        editorMap
427
                    onClicked:  _missionController.setCurrentPlanViewSeqNum(sequenceNumber, false)
428
                    visible:    _editingLayer == _layerMission
429
                }
430
            }
431

432 433
            // Add lines between waypoints
            MissionLineView {
434 435
                showSpecialVisual:  _missionController.isROIBeginCurrentItem
                model:              _editingLayer == _layerMission ? _missionController.waypointLines : undefined
436
            }
437

438
            // Direction arrows in waypoint lines
439 440 441 442 443 444
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.directionArrows : undefined

                delegate: MapLineArrow {
                    fromCoord:      object ? object.coordinate1 : undefined
                    toCoord:        object ? object.coordinate2 : undefined
445 446 447 448
                    arrowPosition:  3
                    z:              QGroundControl.zOrderWaypointLines + 1
                }
            }
449 450 451 452 453 454 455 456 457 458 459 460

            // Incomplete segment lines
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.incompleteComplexItemLines : undefined

                delegate: MapPolyline {
                    path:       [ object.coordinate1, object.coordinate2 ]
                    line.width: 1
                    line.color: "red"
                    z:          QGroundControl.zOrderWaypointLines
                }
            }
461 462 463 464 465 466 467

            // UI for splitting the current segment
            MapQuickItem {
                id:             splitSegmentItem
                anchorPoint.x:  sourceItem.width / 2
                anchorPoint.y:  sourceItem.height / 2
                z:              QGroundControl.zOrderWaypointLines + 1
468
                visible:        _editingLayer == _layerMission
469 470

                sourceItem: SplitIndicator {
471 472 473
                    onClicked:  _missionController.insertSimpleMissionItem(splitSegmentItem.coordinate,
                                                                           _missionController.currentPlanViewVIIndex,
                                                                           true /* makeCurrentItem */)
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
                }

                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()
495 496 497
                }
            }

498 499 500 501 502 503 504
            // Add the vehicles to the map
            MapItemView {
                model: QGroundControl.multiVehicleManager.vehicles
                delegate:
                    VehicleMapItem {
                    vehicle:        object
                    coordinate:     object.coordinate
505
                    map:            editorMap
506 507
                    size:           ScreenTools.defaultFontPixelHeight * 3
                    z:              QGroundControl.zOrderMapItems - 1
508
                }
509
            }
510

511 512
            GeoFenceMapVisuals {
                map:                    editorMap
513
                myGeoFenceController:   _geoFenceController
514
                interactive:            _editingLayer == _layerGeoFence
515
                homePosition:           _missionController.plannedHomePosition
516 517
                planView:               true
            }
518

519 520
            RallyPointMapVisuals {
                map:                    editorMap
521
                myRallyPointController: _rallyPointController
522 523
                interactive:            _editingLayer == _layerRallyPoints
                planView:               true
524
            }
525

526 527
            // Airspace overlap support
            MapItemView {
528
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.circles : []
529 530 531
                delegate: MapCircle {
                    center:         object.center
                    radius:         object.radius
532
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
533 534
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
535 536 537 538
                }
            }

            MapItemView {
539
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : []
540 541
                delegate: MapPolygon {
                    path:           object.polygon
542
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
543 544
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
545 546
                }
            }
547
        }
548

549 550
        //-----------------------------------------------------------
        // Left tool strip
Gus Grubba's avatar
Gus Grubba committed
551
        ToolStrip {
552
            id:                 toolStrip
553
            anchors.margins:    _toolsMargin
554 555 556
            anchors.left:       parent.left
            anchors.top:        parent.top
            z:                  QGroundControl.zOrderWidgets
557
            maxHeight:          parent.height - toolStrip.y
558

559 560 561 562 563 564 565 566
            //readonly property int flyButtonIndex:       0
            readonly property int fileButtonIndex:      0
            readonly property int takeoffButtonIndex:   1
            readonly property int waypointButtonIndex:  2
            readonly property int roiButtonIndex:       3
            readonly property int patternButtonIndex:   4
            readonly property int landButtonIndex:      5
            readonly property int centerButtonIndex:    6
567

568 569
            property bool _isRallyLayer:    _editingLayer == _layerRallyPoints
            property bool _isMissionLayer:  _editingLayer == _layerMission
570

Gus Grubba's avatar
Gus Grubba committed
571
            model: [
572
                /*{
Gus Grubba's avatar
Gus Grubba committed
573 574 575 576
                    name:               qsTr("Fly"),
                    iconSource:         "/qmlimages/PaperPlane.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
577
                },*/
578
                {
Gus Grubba's avatar
Gus Grubba committed
579 580 581 582 583 584 585 586
                    name:               qsTr("File"),
                    iconSource:         "/qmlimages/MapSync.svg",
                    buttonEnabled:      !_planMasterController.syncInProgress,
                    buttonVisible:      true,
                    showAlternateIcon:  _planMasterController.dirty,
                    alternateIconSource:"/qmlimages/MapSyncChanged.svg",
                    dropPanelComponent: syncDropPanel
                },
587 588 589 590
                {
                    name:               qsTr("Takeoff"),
                    iconSource:         "/res/takeoff.svg",
                    buttonEnabled:      _missionController.isInsertTakeoffValid,
591
                    buttonVisible:      _isMissionLayer
592
                },
Gus Grubba's avatar
Gus Grubba committed
593 594 595
                {
                    name:               _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
596 597
                    buttonEnabled:      _isRallyLayer ? true : _missionController.flyThroughCommandsAllowed,
                    buttonVisible:      _isRallyLayer || _isMissionLayer,
Gus Grubba's avatar
Gus Grubba committed
598 599 600 601
                    toggle:             true,
                    checked:            _addWaypointOnClick
                },
                {
602
                    name:               _missionController.isROIActive ? qsTr("Cancel ROI") : qsTr("ROI"),
Gus Grubba's avatar
Gus Grubba committed
603 604
                    iconSource:         "/qmlimages/MapAddMission.svg",
                    buttonEnabled:      true,
605
                    buttonVisible:      _isMissionLayer,
606
                    toggle:             !_missionController.isROIActive
Gus Grubba's avatar
Gus Grubba committed
607 608 609 610
                },
                {
                    name:               _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
                    iconSource:         "/qmlimages/MapDrawShape.svg",
611 612
                    buttonEnabled:      _missionController.flyThroughCommandsAllowed,
                    buttonVisible:      _isMissionLayer,
Gus Grubba's avatar
Gus Grubba committed
613 614
                    dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
                },
615 616 617 618
                {
                    name:               _planMasterController.controllerVehicle.fixedWing ? qsTr("Land") : qsTr("Return"),
                    iconSource:         "/res/rtl.svg",
                    buttonEnabled:      _missionController.isInsertLandValid,
619
                    buttonVisible:      _isMissionLayer
620
                },
Gus Grubba's avatar
Gus Grubba committed
621 622 623 624 625 626 627 628
                {
                    name:               qsTr("Center"),
                    iconSource:         "/qmlimages/MapCenter.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    dropPanelComponent: centerMapDropPanel
                }
            ]
629

630 631 632 633 634
            function allAddClickBoolsOff() {
                _addROIOnClick =        false
                _addWaypointOnClick =   false
            }

Gus Grubba's avatar
Gus Grubba committed
635 636
            onClicked: {
                switch (index) {
637
                /*case flyButtonIndex:
638
                    mainWindow.showFlyView()
639
                    break*/
640
                case takeoffButtonIndex:
641
                    allAddClickBoolsOff()
642 643 644
                    _missionController.insertTakeoffItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */)
                    break
                case waypointButtonIndex:
645 646
                    if (_addWaypointOnClick) {
                        allAddClickBoolsOff()
Gus Grubba's avatar
Gus Grubba committed
647 648
                        setChecked(index, false)
                    } else {
649
                        allAddClickBoolsOff()
650
                        _addWaypointOnClick = checked
Gus Grubba's avatar
Gus Grubba committed
651 652
                    }
                    break
653
                case roiButtonIndex:
654 655 656
                    if (_addROIOnClick) {
                        allAddClickBoolsOff()
                        setChecked(index, false)
657
                    } else {
658 659 660 661 662 663
                        allAddClickBoolsOff()
                        if (_missionController.isROIActive) {
                            insertCancelROIAfterCurrent()
                        } else {
                            _addROIOnClick = checked
                        }
664
                    }
Gus Grubba's avatar
Gus Grubba committed
665
                    break
666
                case patternButtonIndex:
667
                    allAddClickBoolsOff()
Gus Grubba's avatar
Gus Grubba committed
668
                    if (_singleComplexItem) {
669
                        insertComplexItemAfterCurrent(_missionController.complexMissionItemNames[0])
Gus Grubba's avatar
Gus Grubba committed
670 671
                    }
                    break
672
                case landButtonIndex:
673
                    allAddClickBoolsOff()
674 675
                    _missionController.insertLandItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */)
                    break
676 677
                }
            }
678 679 680 681

            onDropped: {
                allAddClickBoolsOff()
            }
Gus Grubba's avatar
Gus Grubba committed
682
        }
683

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

        MissionItemStatus {
            id:                 waypointValuesDisplay
880 881 882
            anchors.margins:    _toolsMargin
            anchors.left:       toolStrip.right
            anchors.bottom:     mapScale.top
883
            height:             ScreenTools.defaultFontPixelHeight * 7
884
            maxWidth:           rightPanel.x - x - anchors.margins
885
            missionItems:       _missionController.visualItems
886
            visible:            _internalVisible && _editingLayer === _layerMission && QGroundControl.corePlugin.options.showMissionStatus
887

888 889
            onSetCurrentSeqNum: _missionController.setCurrentPlanViewSeqNum(seqNum, true)

890
            property bool _internalVisible: _planViewSettings.showMissionItemStatus.rawValue
891 892 893

            function toggleVisible() {
                _internalVisible = !_internalVisible
894
                _planViewSettings.showMissionItemStatus.rawValue = _internalVisible
895
            }
896
        }
897 898 899 900 901 902 903 904 905 906 907 908 909


        MapScale {
            id:                     mapScale
            anchors.margins:        _toolsMargin
            anchors.bottom:         parent.bottom
            anchors.left:           toolStrip.right
            mapControl:             editorMap
            buttonsOnLeft:          true
            terrainButtonVisible:   _editingLayer === _layerMission
            terrainButtonChecked:   waypointValuesDisplay.visible
            onTerrainButtonClicked: waypointValuesDisplay.toggleVisible()
        }
Gus Grubba's avatar
Gus Grubba committed
910
    }
911

912 913 914 915
    Component {
        id: syncLoadFromVehicleOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
Don Gagne's avatar
Don Gagne committed
916
            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?")
917 918
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
919
                _planMasterController.loadFromVehicle()
920 921 922 923 924 925 926 927
            }
        }
    }

    Component {
        id: syncLoadFromFileOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
DonLakeFlyer's avatar
DonLakeFlyer committed
928
            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?")
929 930
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
931
                _planMasterController.loadFromSelectedFile()
932 933 934 935
            }
        }
    }

936 937
    property var createPlanRemoveAllPromptDialogMapCenter
    property var createPlanRemoveAllPromptDialogPlanCreator
938
    Component {
939
        id: createPlanRemoveAllPromptDialog
940
        QGCViewMessage {
941
            message: qsTr("Are you sure you want to remove current plan and create a new plan? ")
942
            function accept() {
943
                createPlanRemoveAllPromptDialogPlanCreator.createPlan(createPlanRemoveAllPromptDialogMapCenter)
944 945 946 947 948
                hideDialog()
            }
        }
    }

949 950 951 952 953
    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
954
                _planMasterController.removeAllFromVehicle()
955
                _missionController.setCurrentPlanViewSeqNum(0, true)
956 957 958 959 960
                hideDialog()
            }
        }
    }

961 962 963 964 965 966 967 968 969 970 971
    //- ToolStrip DropPanel Components

    Component {
        id: centerMapDropPanel

        CenterMapDropPanel {
            map:            editorMap
            fitFunctions:   mapFitFunctions
        }
    }

972 973 974 975 976 977 978 979 980
    Component {
        id: patternDropPanel

        ColumnLayout {
            spacing:    ScreenTools.defaultFontPixelWidth * 0.5

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

            Repeater {
981
                model: _missionController.complexMissionItemNames
982 983 984 985 986 987

                QGCButton {
                    text:               modelData
                    Layout.fillWidth:   true

                    onClicked: {
988
                        insertComplexItemAfterCurrent(modelData)
989 990 991 992 993 994
                        dropPanel.hide()
                    }
                }
            }
        } // Column
    }
995 996

    Component {
997
        id: syncDropPanel
998

999
        ColumnLayout {
1000 1001
            id:         columnHolder
            spacing:    _margin
1002

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

1005
            QGCLabel {
1006
                id:                 unsavedChangedLabel
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
                text:               activeVehicle ?
                                        qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file.") :
                                        qsTr("You have unsaved changes.")
                visible:            _planMasterController.dirty
            }

            SectionHeader {
                id:                 createSection
                Layout.fillWidth:   true
                text:               qsTr("Create Plan")
1019
                showSpacer:         false
1020 1021
            }

1022 1023
            GridLayout {
                columns:            2
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
                columnSpacing:      _margin
                rowSpacing:         _margin
                Layout.fillWidth:   true
                visible:            createSection.visible

                Repeater {
                    model: _planMasterController.planCreators

                    Rectangle {
                        id:     button
                        width:  ScreenTools.defaultFontPixelHeight * 7
                        height: planCreatorNameLabel.y + planCreatorNameLabel.height
                        color:  button.pressed || button.highlighted ? qgcPal.buttonHighlight : qgcPal.button

                        property bool highlighted: mouseArea.containsMouse
                        property bool pressed:     mouseArea.pressed

                        Image {
                            id:                 planCreatorImage
                            anchors.left:       parent.left
                            anchors.right:      parent.right
                            source:             object.imageResource
                            sourceSize.width:   width
                            fillMode:           Image.PreserveAspectFit
                            mipmap:             true
                        }

                        QGCLabel {
                            id:                     planCreatorNameLabel
                            anchors.top:            planCreatorImage.bottom
                            anchors.left:           parent.left
                            anchors.right:          parent.right
                            horizontalAlignment:    Text.AlignHCenter
                            text:                   object.name
                            color:                  button.pressed || button.highlighted ? qgcPal.buttonHighlightText : qgcPal.buttonText
                        }

                        QGCMouseArea {
                            id:                 mouseArea
                            anchors.fill:       parent
                            hoverEnabled:       true
                            preventStealing:    true
                            onClicked:          {
                                if (_planMasterController.containsItems) {
                                    createPlanRemoveAllPromptDialogMapCenter = _mapCenter()
                                    createPlanRemoveAllPromptDialogPlanCreator = object
                                    mainWindow.showComponentDialog(createPlanRemoveAllPromptDialog, qsTr("Create Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
                                } else {
                                    object.createPlan(_mapCenter())
                                }
                                dropPanel.hide()
                            }

                            function _mapCenter() {
                                var centerPoint = Qt.point(editorMap.centerViewport.left + (editorMap.centerViewport.width / 2), editorMap.centerViewport.top + (editorMap.centerViewport.height / 2))
                                return editorMap.toCoordinate(centerPoint, false /* clipToViewPort */)
                            }
                        }
                    }
                }
            }

            SectionHeader {
                id:                 storageSection
                Layout.fillWidth:   true
                text:               qsTr("Storage")
            }

            GridLayout {
                columns:            3
1094 1095
                rowSpacing:         _margin
                columnSpacing:      ScreenTools.defaultFontPixelWidth
1096
                visible:            storageSection.visible
1097

1098
                /*QGCButton {
1099
                    text:               qsTr("New...")
1100
                    Layout.fillWidth:   true
1101
                    onClicked:  {
1102
                        dropPanel.hide()
1103 1104 1105
                        if (_planMasterController.containsItems) {
                            mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
                        }
1106
                    }
1107
                }*/
1108

1109
                QGCButton {
1110
                    text:               qsTr("Open...")
1111
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1112
                    enabled:            !_planMasterController.syncInProgress
1113 1114
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1115
                        if (_planMasterController.dirty) {
1116
                            mainWindow.showComponentDialog(syncLoadFromFileOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1117
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1118
                            _planMasterController.loadFromSelectedFile()
1119 1120 1121
                        }
                    }
                }
1122

1123
                QGCButton {
1124
                    text:               qsTr("Save")
1125
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1126
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.currentPlanFile !== ""
1127 1128
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1129 1130
                        if(_planMasterController.currentPlanFile !== "") {
                            _planMasterController.saveToCurrent()
1131
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1132
                            _planMasterController.saveToSelectedFile()
1133
                        }
1134 1135 1136 1137
                    }
                }

                QGCButton {
1138
                    text:               qsTr("Save As...")
1139
                    Layout.fillWidth:   true
1140
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.containsItems
1141 1142
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1143
                        _planMasterController.saveToSelectedFile()
1144 1145 1146 1147
                    }
                }

                QGCButton {
1148 1149
                    Layout.columnSpan:  3
                    Layout.fillWidth:   true
1150
                    text:               qsTr("Save Mission Waypoints As KML...")
Gus Grubba's avatar
Gus Grubba committed
1151
                    enabled:            !_planMasterController.syncInProgress && _visualItems.count > 1
1152
                    onClicked: {
1153
                        // First point does not count
1154
                        if (_visualItems.count < 2) {
1155
                            mainWindow.showComponentDialog(noItemForKML, qsTr("KML"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
1156 1157
                            return
                        }
1158
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1159
                        _planMasterController.saveKmlToSelectedFile()
1160 1161
                    }
                }
1162
            }
1163

1164 1165 1166 1167 1168 1169 1170 1171 1172 1173
            SectionHeader {
                id:                 vehicleSection
                Layout.fillWidth:   true
                text:               qsTr("Vehicle")
            }

            RowLayout {
                Layout.fillWidth:   true
                spacing:            _margin
                visible:            vehicleSection.visible
1174

1175
                QGCButton {
1176
                    text:               qsTr("Upload")
1177
                    Layout.fillWidth:   true
1178
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress && _planMasterController.containsItems
1179 1180
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
1181
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1182
                        _planMasterController.upload()
1183 1184
                    }
                }
1185 1186 1187 1188

                QGCButton {
                    text:               qsTr("Download")
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1189
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1190 1191 1192
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1193
                        if (_planMasterController.dirty) {
1194
                            mainWindow.showComponentDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1195
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1196
                            _planMasterController.loadFromVehicle()
1197 1198 1199 1200 1201
                        }
                    }
                }

                QGCButton {
1202
                    text