Commit ffe65c58 authored by Gus Grubba's avatar Gus Grubba

Switch back to single click but with menu instead of direct delete.

parent d28bafba
...@@ -29,7 +29,6 @@ Rectangle { ...@@ -29,7 +29,6 @@ Rectangle {
property var itemCoordinate ///< Coordinate we are updating during drag property var itemCoordinate ///< Coordinate we are updating during drag
signal clicked signal clicked
signal doubleClicked
signal dragStart signal dragStart
signal dragStop signal dragStop
...@@ -77,11 +76,6 @@ Rectangle { ...@@ -77,11 +76,6 @@ Rectangle {
itemDragger.clicked() itemDragger.clicked()
} }
onDoubleClicked: {
focus = true
itemDragger.doubleClicked()
}
property bool dragActive: drag.active property bool dragActive: drag.active
onDragActiveChanged: { onDragActiveChanged: {
if (dragActive) { if (dragActive) {
......
...@@ -186,6 +186,59 @@ Item { ...@@ -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 { Component {
id: polygonComponent id: polygonComponent
...@@ -291,32 +344,36 @@ Item { ...@@ -291,32 +344,36 @@ Item {
} }
} }
onDoubleClicked: mapPolygon.removeVertex(polygonVertex) onClicked: {
menu.popUpWithIndex(polygonVertex)
}
} }
} }
Component { Component {
id: centerDragHandle id: centerDragHandle
MapQuickItem { MapQuickItem {
id: mapQuickItem id: mapQuickItem
anchorPoint.x: dragHandle.width / 2 anchorPoint.x: dragHandle.width * 0.5
anchorPoint.y: dragHandle.height / 2 anchorPoint.y: dragHandle.height * 0.5
z: _zorderDragHandle z: _zorderDragHandle
sourceItem: Rectangle { sourceItem: Rectangle {
id: dragHandle id: dragHandle
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
height: width height: width
radius: width / 2 radius: width * 0.5
color: "white" color: Qt.rgba(1,1,1,0.8)
opacity: .90 border.color: Qt.rgba(0,0,0,0.25)
border.width: 1
QGCLabel { QGCColoredImage {
anchors.horizontalCenter: parent.horizontalCenter width: parent.width
anchors.verticalCenter: parent.verticalCenter height: width
text: "..." color: Qt.rgba(0,0,0,1)
color: "black" mipmap: true
fillMode: Image.PreserveAspectFit
source: "/qmlimages/MapCenter.svg"
sourceSize.height: height
anchors.centerIn: parent
} }
} }
} }
...@@ -327,7 +384,7 @@ Item { ...@@ -327,7 +384,7 @@ Item {
MapQuickItem { MapQuickItem {
id: mapQuickItem id: mapQuickItem
anchorPoint.x: dragHandle.width / 2 anchorPoint.x: dragHandle.width / 2
anchorPoint.y: dragHandle.height / 2 anchorPoint.y: dragHandle.height / 2
z: _zorderDragHandle z: _zorderDragHandle
visible: !_circle visible: !_circle
...@@ -335,12 +392,13 @@ Item { ...@@ -335,12 +392,13 @@ Item {
property int polygonVertex property int polygonVertex
sourceItem: Rectangle { sourceItem: Rectangle {
id: dragHandle id: dragHandle
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
height: width height: width
radius: width / 2 radius: width * 0.5
color: "white" color: Qt.rgba(1,1,1,0.8)
opacity: .90 border.color: Qt.rgba(0,0,0,0.25)
border.width: 1
} }
} }
} }
...@@ -393,44 +451,16 @@ Item { ...@@ -393,44 +451,16 @@ Item {
onItemCoordinateChanged: mapPolygon.center = itemCoordinate onItemCoordinateChanged: mapPolygon.center = itemCoordinate
onDragStart: mapPolygon.centerDrag = true onDragStart: mapPolygon.centerDrag = true
onDragStop: mapPolygon.centerDrag = false onDragStop: mapPolygon.centerDrag = false
onClicked: menu.popup()
onClicked: {
menu.popUpWithIndex(-1) //-- Don't offer a choice to delete vertex (cur index == -1)
}
function setRadiusFromDialog() { function setRadiusFromDialog() {
setCircleRadius(mapPolygon.center, radiusField.text) setCircleRadius(mapPolygon.center, radiusField.text)
radiusDialog.visible = false 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 { Rectangle {
id: radiusDialog id: radiusDialog
anchors.margins: _margin anchors.margins: _margin
......
...@@ -128,22 +128,28 @@ Item { ...@@ -128,22 +128,28 @@ Item {
Menu { Menu {
id: menu id: menu
property int removeVertex property int _removeVertexIndex
function popUpWithIndex(curIndex) {
_removeVertexIndex = curIndex
removeVertexItem.visible = mapPolyline.count > 2
menu.popup()
}
MenuItem { MenuItem {
id: removeVertexItem id: removeVertexItem
text: qsTr("Remove vertex" ) text: qsTr("Remove vertex" )
onTriggered: mapPolyline.removeVertex(parent.removeVertex) onTriggered: mapPolyline.removeVertex(menu._removeVertexIndex)
}
MenuSeparator {
visible: removeVertexItem.visible
} }
MenuItem { MenuItem {
text: qsTr("Load KML...") text: qsTr("Load KML...")
onTriggered: kmlLoadDialog.openForLoad() onTriggered: kmlLoadDialog.openForLoad()
} }
function resetMenu() {
removeVertexItem.visible = mapPolyline.count > 2
}
} }
Component { Component {
...@@ -247,15 +253,7 @@ Item { ...@@ -247,15 +253,7 @@ Item {
} }
onClicked: { onClicked: {
menu.resetMenu() menu.popUpWithIndex(polylineVertex)
menu.removeVertex = polylineVertex
menu.popup()
}
onDoubleClicked: {
if (polylineVertex != 0) {
mapPolyline.removeVertex(polylineVertex)
}
} }
} }
...@@ -273,12 +271,13 @@ Item { ...@@ -273,12 +271,13 @@ Item {
property int polylineVertex property int polylineVertex
sourceItem: Rectangle { sourceItem: Rectangle {
id: dragHandle id: dragHandle
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
height: width height: width
radius: width / 2 radius: width * 0.5
color: "white" color: Qt.rgba(1,1,1,0.8)
opacity: 0.9 border.color: Qt.rgba(0,0,0,0.25)
border.width: 1
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment