Skip to content

Commit 8bd997d

Browse files
committedJan 23, 2019
[node editor] Improve UX by having right-click bind feature to node editor (i.e., bye bye menu)
1 parent 2defe21 commit 8bd997d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
 

‎src/app/vertextool/qgsvertexeditor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ QgsVertexEditor::QgsVertexEditor(
333333

334334
void QgsVertexEditor::updateEditor( QgsVectorLayer *layer, QgsSelectedFeature *selectedFeature )
335335
{
336-
delete mVertexModel;
336+
if ( mSelectedFeature )
337+
{
338+
delete mVertexModel;
339+
}
337340

338341
mLayer = layer;
339342
mSelectedFeature = selectedFeature;

‎src/app/vertextool/qgsvertextool.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void QgsVertexTool::activate()
286286
{
287287
if ( QgisApp::instance() )
288288
{
289-
showVertexEditor();
289+
showVertexEditor(); //#spellok
290290
}
291291
QgsMapToolAdvancedDigitizing::activate();
292292
}
@@ -445,10 +445,7 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
445445
// show popup menu - if we are on top of a feature
446446
if ( mLastMouseMoveMatch.isValid() && mLastMouseMoveMatch.layer() )
447447
{
448-
QMenu menu;
449-
QAction *actionVertexEditor = menu.addAction( tr( "Vertex Editor" ) );
450-
connect( actionVertexEditor, &QAction::triggered, this, &QgsVertexTool::showVertexEditor ); //#spellok
451-
menu.exec( mCanvas->mapToGlobal( e->pos() ) );
448+
showVertexEditor(); //#spellok
452449
}
453450
}
454451
}
@@ -1058,6 +1055,17 @@ void QgsVertexTool::showVertexEditor() //#spellok
10581055
QgsPointLocator::Match m = mLastMouseMoveMatch;
10591056
if ( m.isValid() || m.layer() )
10601057
{
1058+
if ( mSelectedFeature && mSelectedFeature->featureId() == m.featureId() && mSelectedFeature->layer() == m.layer() )
1059+
{
1060+
// if show feature is called on a feature that's already binded to the vertex editor, toggle it off
1061+
mSelectedFeature.reset();
1062+
if ( mVertexEditor )
1063+
{
1064+
mVertexEditor->updateEditor( nullptr, nullptr );
1065+
}
1066+
return;
1067+
}
1068+
10611069
mSelectedFeature.reset( new QgsSelectedFeature( m.featureId(), m.layer(), mCanvas ) );
10621070
for ( int i = 0; i < mSelectedVertices.length(); ++i )
10631071
{

0 commit comments

Comments
 (0)
Please sign in to comment.