diff --git a/src/PlanView/MissionItemEditor.qml b/src/PlanView/MissionItemEditor.qml index a582200fb6bb2c858c72305c0cc71cccf0b94968..ecf928a6e37208afc043a67637d02a750bf6ccc3 100644 --- a/src/PlanView/MissionItemEditor.qml +++ b/src/PlanView/MissionItemEditor.qml @@ -33,6 +33,7 @@ Rectangle { property color _outerTextColor: _currentItem ? qgcPal.primaryButtonText : qgcPal.text property bool _noMissionItemsAdded: ListView.view.model.count === 1 property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings + property bool _singleComplexItem: missionController.complexMissionItemNames.length === 1 readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12) readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 @@ -63,7 +64,7 @@ Rectangle { anchors.verticalCenter: commandPicker.verticalCenter anchors.leftMargin: _margin anchors.left: parent.left - text: missionItem.abbreviation.charAt(0) + text: missionItem.homePosition ? "H" : missionItem.sequenceNumber color: _outerTextColor } @@ -97,20 +98,16 @@ Rectangle { onTriggered: insertWaypoint() } - MenuItem { - text: qsTr("Delete") - onTriggered: remove() - } - Menu { - id: normalPatternMenu - title: qsTr("Insert pattern") + id: patternMenu + title: qsTr("Insert pattern") + visible: !_singleComplexItem Instantiator { model: missionController.complexMissionItemNames - onObjectAdded: normalPatternMenu.insertItem(index, object) - onObjectRemoved: normalPatternMenu.removeItem(object) + onObjectAdded: patternMenu.insertItem(index, object) + onObjectRemoved: patternMenu.removeItem(object) MenuItem { text: modelData @@ -119,6 +116,17 @@ Rectangle { } } + MenuItem { + text: qsTr("Insert ") + missionController.complexMissionItemNames[0] + visible: _singleComplexItem + onTriggered: insertComplexItem(missionController.complexMissionItemNames[0]) + } + + MenuItem { + text: qsTr("Delete") + onTriggered: remove() + } + MenuItem { text: qsTr("Change command...") onTriggered: commandPicker.clicked() diff --git a/src/PlanView/PlanToolBar.qml b/src/PlanView/PlanToolBar.qml index 248a2962ea51fa63eece13b2e7d4499bb8790944..3570554c09412bbd85d3caddbac2528f96dabc59 100644 --- a/src/PlanView/PlanToolBar.qml +++ b/src/PlanView/PlanToolBar.qml @@ -111,7 +111,6 @@ Rectangle { } } - RowLayout { anchors.top: parent.top anchors.bottom: parent.bottom @@ -247,7 +246,7 @@ Rectangle { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter text: missionController ? (missionController.dirty ? qsTr("Upload Required") : qsTr("Upload")) : "" - enabled: _activeVehicle + enabled: _activeVehicle && !missionController.syncInProgress visible: _activeVehicle && _manualUpload onClicked: missionController.upload() diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index c04819a558225b5bfe229a0402007947126a6292..0e2267a8f3e49cbdfe4f29392fc631ee716713ef 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -76,7 +76,7 @@ QGCView { function insertComplexMissionItem(complexItemName, coordinate, index) { var sequenceNumber = missionController.insertComplexMissionItem(complexItemName, coordinate, index) - setCurrentItem(sequenceNumber) + setCurrentItem(sequenceNumber, true) } property bool _firstMissionLoadComplete: false @@ -168,7 +168,7 @@ QGCView { Component.onCompleted: { start(true /* editMode */) - setCurrentItem(0) + setCurrentItem(0, true) } function _denyUpload(switchToFly) { @@ -223,7 +223,7 @@ QGCView { if (_visualItems && _visualItems.count != 1) { mapFitFunctions.fitMapViewportToMissionItems() } - setCurrentItem(0) + setCurrentItem(0, true) } } @@ -305,8 +305,8 @@ QGCView { /// Sets a new current mission item /// @param sequenceNumber - index for new item, -1 to clear current item - function setCurrentItem(sequenceNumber) { - if (sequenceNumber !== _currentMissionIndex) { + function setCurrentItem(sequenceNumber, force) { + if (force || sequenceNumber !== _currentMissionIndex) { _currentMissionItem = undefined _currentMissionIndex = -1 for (var i=0; i<_visualItems.count; i++) { @@ -326,9 +326,8 @@ QGCView { /// @param coordinate Location to insert item /// @param index Insert item at this index function insertSimpleMissionItem(coordinate, index) { - setCurrentItem(-1) var sequenceNumber = missionController.insertSimpleMissionItem(coordinate, index) - setCurrentItem(sequenceNumber) + setCurrentItem(sequenceNumber, true) } property int _moveDialogMissionItemIndex @@ -347,7 +346,7 @@ QGCView { onAcceptedForLoad: { _syncDropDownController.loadFromFile(file) _syncDropDownController.fitViewportToItems() - _currentMissionItem = _visualItems.get(0) + setCurrentItem(0, true) close() } } @@ -506,7 +505,7 @@ QGCView { delegate: MissionItemMapVisual { map: editorMap - onClicked: setCurrentItem(sequenceNumber) + onClicked: setCurrentItem(sequenceNumber, false) } } @@ -568,7 +567,7 @@ QGCView { toggle: true }, { - name: "Pattern", + name: _singleComplexItem ? missionController.complexMissionItemNames[0] : "Pattern", iconSource: "/qmlimages/MapDrawShape.svg", dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel }, @@ -721,7 +720,7 @@ QGCView { readOnly: false rootQgcView: _qgcView - onClicked: setCurrentItem(object.sequenceNumber) + onClicked: setCurrentItem(object.sequenceNumber, false) onRemove: { var removeIndex = index @@ -731,7 +730,7 @@ QGCView { removeIndex-- } _currentMissionIndex = -1 - rootQgcView.setCurrentItem(removeIndex) + rootQgcView.setCurrentItem(removeIndex, true) } onInsertWaypoint: insertSimpleMissionItem(editorMap.center, index)