From d28bafba58d332db58d20dc9fa16cc8af83fbc58 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Wed, 30 May 2018 17:59:55 -0400 Subject: [PATCH 1/2] Double click to delete a vertex --- .../MapItems/MissionItemIndicatorDrag.qml | 6 +++++ src/MissionManager/QGCMapPolygonVisuals.qml | 2 +- src/MissionManager/QGCMapPolylineVisuals.qml | 29 +++++++++++----------- src/PlanView/CorridorScanEditor.qml | 13 +++++----- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml b/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml index 720e5fd..3d49c21 100644 --- a/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml +++ b/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml @@ -29,6 +29,7 @@ Rectangle { property var itemCoordinate ///< Coordinate we are updating during drag signal clicked + signal doubleClicked signal dragStart signal dragStop @@ -76,6 +77,11 @@ Rectangle { itemDragger.clicked() } + onDoubleClicked: { + focus = true + itemDragger.doubleClicked() + } + property bool dragActive: drag.active onDragActiveChanged: { if (dragActive) { diff --git a/src/MissionManager/QGCMapPolygonVisuals.qml b/src/MissionManager/QGCMapPolygonVisuals.qml index f72a4ab..01e57ba 100644 --- a/src/MissionManager/QGCMapPolygonVisuals.qml +++ b/src/MissionManager/QGCMapPolygonVisuals.qml @@ -291,7 +291,7 @@ Item { } } - onClicked: mapPolygon.removeVertex(polygonVertex) + onDoubleClicked: mapPolygon.removeVertex(polygonVertex) } } diff --git a/src/MissionManager/QGCMapPolylineVisuals.qml b/src/MissionManager/QGCMapPolylineVisuals.qml index 07a25ae..848f1ec 100644 --- a/src/MissionManager/QGCMapPolylineVisuals.qml +++ b/src/MissionManager/QGCMapPolylineVisuals.qml @@ -128,10 +128,10 @@ Item { Menu { id: menu - property int removeVertex MenuItem { + id: removeVertexItem text: qsTr("Remove vertex" ) onTriggered: mapPolyline.removeVertex(parent.removeVertex) } @@ -140,6 +140,10 @@ Item { text: qsTr("Load KML...") onTriggered: kmlLoadDialog.openForLoad() } + + function resetMenu() { + removeVertexItem.visible = mapPolyline.count > 2 + } } Component { @@ -167,7 +171,7 @@ Item { width: ScreenTools.defaultFontPixelHeight * 1.5 height: width radius: width / 2 - border.color: "white" + border.color: "white" color: "transparent" opacity: .50 z: _zorderSplitHandle @@ -243,10 +247,13 @@ Item { } onClicked: { - if (polylineVertex == 0) { - menu.removeVertex = polylineVertex - menu.popup() - } else { + menu.resetMenu() + menu.removeVertex = polylineVertex + menu.popup() + } + + onDoubleClicked: { + if (polylineVertex != 0) { mapPolyline.removeVertex(polylineVertex) } } @@ -271,15 +278,7 @@ Item { height: width radius: width / 2 color: "white" - opacity: .90 - - QGCLabel { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - text: "..." - color: "black" - visible: polylineVertex == 0 - } + opacity: 0.9 } } } diff --git a/src/PlanView/CorridorScanEditor.qml b/src/PlanView/CorridorScanEditor.qml index 9bd97bb..54235e2 100644 --- a/src/PlanView/CorridorScanEditor.qml +++ b/src/PlanView/CorridorScanEditor.qml @@ -106,11 +106,11 @@ Rectangle { QGCCheckBox { id: relAlt - anchors.left: parent.left text: qsTr("Relative altitude") checked: missionItem.cameraCalc.distanceToSurfaceRelative enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain visible: QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || (!missionItem.cameraCalc.distanceToSurfaceRelative && !missionItem.followTerrain) + Layout.alignment: Qt.AlignLeft Layout.columnSpan: 2 onClicked: missionItem.cameraCalc.distanceToSurfaceRelative = checked @@ -146,12 +146,11 @@ Rectangle { } GridLayout { - anchors.left: parent.left - anchors.right: parent.right - columnSpacing: _margin - rowSpacing: _margin - columns: 2 - visible: followsTerrainCheckBox.checked + Layout.fillWidth: true + columnSpacing: _margin + rowSpacing: _margin + columns: 2 + visible: followsTerrainCheckBox.checked QGCLabel { text: qsTr("Tolerance") } FactTextField { From ffe65c58e712682f668989b354d0efe34a6cd07a Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Wed, 30 May 2018 22:40:55 -0400 Subject: [PATCH 2/2] Switch back to single click but with menu instead of direct delete. --- .../MapItems/MissionItemIndicatorDrag.qml | 6 - src/MissionManager/QGCMapPolygonVisuals.qml | 142 +++++++++++++-------- src/MissionManager/QGCMapPolylineVisuals.qml | 41 +++--- 3 files changed, 106 insertions(+), 83 deletions(-) diff --git a/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml b/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml index 3d49c21..720e5fd 100644 --- a/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml +++ b/src/FlightMap/MapItems/MissionItemIndicatorDrag.qml @@ -29,7 +29,6 @@ Rectangle { property var itemCoordinate ///< Coordinate we are updating during drag signal clicked - signal doubleClicked signal dragStart signal dragStop @@ -77,11 +76,6 @@ Rectangle { itemDragger.clicked() } - onDoubleClicked: { - focus = true - itemDragger.doubleClicked() - } - property bool dragActive: drag.active onDragActiveChanged: { if (dragActive) { diff --git a/src/MissionManager/QGCMapPolygonVisuals.qml b/src/MissionManager/QGCMapPolygonVisuals.qml index 01e57ba..d651239 100644 --- a/src/MissionManager/QGCMapPolygonVisuals.qml +++ b/src/MissionManager/QGCMapPolygonVisuals.qml @@ -186,6 +186,59 @@ Item { } } + Menu { + id: menu + + property int _removeVertexIndex + + function popUpWithIndex(curIndex) { + _removeVertexIndex = curIndex + removeVertexItem.visible = (mapPolygon.count > 3 && _removeVertexIndex >= 0) + menu.popup() + } + + MenuItem { + id: removeVertexItem + text: qsTr("Remove vertex") + onTriggered: { + if(menu._removeVertexIndex >= 0) { + mapPolygon.removeVertex(menu._removeVertexIndex) + } + } + } + + MenuSeparator { + visible: removeVertexItem.visible + } + + MenuItem { + text: qsTr("Circle" ) + onTriggered: resetCircle() + } + + MenuItem { + text: qsTr("Polygon") + onTriggered: resetPolygon() + } + + MenuItem { + text: qsTr("Set radius..." ) + visible: _circle + onTriggered: radiusDialog.visible = true + } + + MenuItem { + text: qsTr("Edit position..." ) + enabled: _circle + onTriggered: qgcView.showDialog(editPositionDialog, qsTr("Edit Position"), qgcView.showDialogDefaultWidth, StandardButton.Cancel) + } + + MenuItem { + text: qsTr("Load KML...") + onTriggered: kmlLoadDialog.openForLoad() + } + } + Component { id: polygonComponent @@ -291,32 +344,36 @@ Item { } } - onDoubleClicked: mapPolygon.removeVertex(polygonVertex) + onClicked: { + menu.popUpWithIndex(polygonVertex) + } } } Component { id: centerDragHandle - MapQuickItem { id: mapQuickItem - anchorPoint.x: dragHandle.width / 2 - anchorPoint.y: dragHandle.height / 2 + anchorPoint.x: dragHandle.width * 0.5 + anchorPoint.y: dragHandle.height * 0.5 z: _zorderDragHandle - sourceItem: Rectangle { - id: dragHandle - width: ScreenTools.defaultFontPixelHeight * 1.5 - height: width - radius: width / 2 - color: "white" - opacity: .90 - - QGCLabel { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - text: "..." - color: "black" + id: dragHandle + width: ScreenTools.defaultFontPixelHeight * 1.5 + height: width + radius: width * 0.5 + color: Qt.rgba(1,1,1,0.8) + border.color: Qt.rgba(0,0,0,0.25) + border.width: 1 + QGCColoredImage { + width: parent.width + height: width + color: Qt.rgba(0,0,0,1) + mipmap: true + fillMode: Image.PreserveAspectFit + source: "/qmlimages/MapCenter.svg" + sourceSize.height: height + anchors.centerIn: parent } } } @@ -327,7 +384,7 @@ Item { MapQuickItem { id: mapQuickItem - anchorPoint.x: dragHandle.width / 2 + anchorPoint.x: dragHandle.width / 2 anchorPoint.y: dragHandle.height / 2 z: _zorderDragHandle visible: !_circle @@ -335,12 +392,13 @@ Item { property int polygonVertex sourceItem: Rectangle { - id: dragHandle - width: ScreenTools.defaultFontPixelHeight * 1.5 - height: width - radius: width / 2 - color: "white" - opacity: .90 + id: dragHandle + width: ScreenTools.defaultFontPixelHeight * 1.5 + height: width + radius: width * 0.5 + color: Qt.rgba(1,1,1,0.8) + border.color: Qt.rgba(0,0,0,0.25) + border.width: 1 } } } @@ -393,44 +451,16 @@ Item { onItemCoordinateChanged: mapPolygon.center = itemCoordinate onDragStart: mapPolygon.centerDrag = true onDragStop: mapPolygon.centerDrag = false - onClicked: menu.popup() + + onClicked: { + menu.popUpWithIndex(-1) //-- Don't offer a choice to delete vertex (cur index == -1) + } function setRadiusFromDialog() { setCircleRadius(mapPolygon.center, radiusField.text) radiusDialog.visible = false } - Menu { - id: menu - - MenuItem { - text: qsTr("Circle" ) - onTriggered: resetCircle() - } - - MenuItem { - text: qsTr("Polygon") - onTriggered: resetPolygon() - } - - MenuItem { - text: qsTr("Set radius..." ) - visible: _circle - onTriggered: radiusDialog.visible = true - } - - MenuItem { - text: qsTr("Edit position..." ) - enabled: _circle - onTriggered: qgcView.showDialog(editPositionDialog, qsTr("Edit Position"), qgcView.showDialogDefaultWidth, StandardButton.Cancel) - } - - MenuItem { - text: qsTr("Load KML...") - onTriggered: kmlLoadDialog.openForLoad() - } - } - Rectangle { id: radiusDialog anchors.margins: _margin diff --git a/src/MissionManager/QGCMapPolylineVisuals.qml b/src/MissionManager/QGCMapPolylineVisuals.qml index 848f1ec..1d86a24 100644 --- a/src/MissionManager/QGCMapPolylineVisuals.qml +++ b/src/MissionManager/QGCMapPolylineVisuals.qml @@ -128,22 +128,28 @@ Item { Menu { id: menu - property int removeVertex + property int _removeVertexIndex + + function popUpWithIndex(curIndex) { + _removeVertexIndex = curIndex + removeVertexItem.visible = mapPolyline.count > 2 + menu.popup() + } MenuItem { id: removeVertexItem text: qsTr("Remove vertex" ) - onTriggered: mapPolyline.removeVertex(parent.removeVertex) + onTriggered: mapPolyline.removeVertex(menu._removeVertexIndex) + } + + MenuSeparator { + visible: removeVertexItem.visible } MenuItem { text: qsTr("Load KML...") onTriggered: kmlLoadDialog.openForLoad() } - - function resetMenu() { - removeVertexItem.visible = mapPolyline.count > 2 - } } Component { @@ -247,15 +253,7 @@ Item { } onClicked: { - menu.resetMenu() - menu.removeVertex = polylineVertex - menu.popup() - } - - onDoubleClicked: { - if (polylineVertex != 0) { - mapPolyline.removeVertex(polylineVertex) - } + menu.popUpWithIndex(polylineVertex) } } @@ -273,12 +271,13 @@ Item { property int polylineVertex sourceItem: Rectangle { - id: dragHandle - width: ScreenTools.defaultFontPixelHeight * 1.5 - height: width - radius: width / 2 - color: "white" - opacity: 0.9 + id: dragHandle + width: ScreenTools.defaultFontPixelHeight * 1.5 + height: width + radius: width * 0.5 + color: Qt.rgba(1,1,1,0.8) + border.color: Qt.rgba(0,0,0,0.25) + border.width: 1 } } }