@ -189,20 +189,25 @@ Item {
@@ -189,20 +189,25 @@ Item {
Menu {
id: menu
property int _removeVertexIndex
property int _editingVertexIndex : - 1
function popUpWithIndex ( curIndex ) {
_removeVertexIndex = curIndex
removeVertexItem . visible = ( mapPolygon . count > 3 && _removeVertexIndex >= 0 )
function popupVertex ( curIndex ) {
menu . _editingVertexIndex = curIndex
removeVertexItem . visible = ( mapPolygon . count > 3 && menu . _editingVertexIndex >= 0 )
menu . popup ( )
}
function popupCenter ( ) {
menu . popup ( )
}
MenuItem {
id: removeVertexItem
visible: ! _circle
text: qsTr ( "Remove vertex" )
onTriggered: {
if ( menu . _remove VertexIndex >= 0 ) {
mapPolygon . removeVertex ( menu . _remove VertexIndex )
if ( menu . _editing VertexIndex >= 0 ) {
mapPolygon . removeVertex ( menu . _editing VertexIndex )
}
}
}
@ -229,8 +234,14 @@ Item {
@@ -229,8 +234,14 @@ Item {
MenuItem {
text: qsTr ( "Edit position..." )
enabled: _circle
onTriggered: qgcView . showDialog ( editPositionDialog , qsTr ( "Edit Position" ) , qgcView . showDialogDefaultWidth , StandardButton . Close )
visible: _circle
onTriggered: qgcView . showDialog ( editCenterPositionDialog , qsTr ( "Edit Center Position" ) , qgcView . showDialogDefaultWidth , StandardButton . Close )
}
MenuItem {
text: qsTr ( "Edit position..." )
visible: ! _circle && menu . _editingVertexIndex >= 0
onTriggered: qgcView . showDialog ( editVertexPositionDialog , qsTr ( "Edit Vertex Position" ) , qgcView . showDialogDefaultWidth , StandardButton . Close )
}
MenuItem {
@ -345,9 +356,7 @@ Item {
@@ -345,9 +356,7 @@ Item {
}
}
onClicked: {
menu . popUpWithIndex ( polygonVertex )
}
onClicked: menu . popupVertex ( polygonVertex )
}
}
@ -436,11 +445,26 @@ Item {
@@ -436,11 +445,26 @@ Item {
}
Component {
id: editPositionDialog
id: editCenter PositionDialog
EditPositionDialog {
coordinate: mapPolygon . center
onCoordinateChanged: mapPolygon . center = coordinate
onCoordinateChanged: {
/ / P r e v e n t s p a m m i n g s i g n a l s o n v e r t e x c h a n g e s b y s e t t i n g c e n t e r D r a g = t r u e w h e n c h a n g i n g c e n t e r p o s i t i o n .
/ / T h i s a l s o f i x e s a b u g w h e r e Q t g e t s c o n f u s e d b y a l l t h e s i g n a l l i n g a n d d r a w s a b a d v i s u a l .
mapPolygon . centerDrag = true
mapPolygon . center = coordinate
mapPolygon . centerDrag = false
}
}
}
Component {
id: editVertexPositionDialog
EditPositionDialog {
coordinate: mapPolygon . vertexCoordinate ( menu . _editingVertexIndex )
onCoordinateChanged: mapPolygon . adjustVertex ( menu . _editingVertexIndex , coordinate )
}
}
@ -454,9 +478,7 @@ Item {
@@ -454,9 +478,7 @@ Item {
onDragStart: mapPolygon . centerDrag = true
onDragStop: mapPolygon . centerDrag = false
onClicked: {
menu . popUpWithIndex ( - 1 ) / / - - D o n ' t o f f e r a c h o i c e t o d e l e t e v e r t e x ( c u r i n d e x = = - 1 )
}
onClicked: menu . popupCenter ( )
function setRadiusFromDialog ( ) {
var radius = QGroundControl . appSettingsDistanceUnitsToMeters ( radiusField . text )