Skip to content

Commit

Permalink
Do not auto-close vertex editor on any mouse click (ref #17243)
Browse files Browse the repository at this point in the history
This is a partial fix for #17243 to improve usability of vertex editor panel.
Until now the vertex editor would get closed on any mouse click in mouse canvas,
making it quite annoying to work with it.

With this change, the vertex editor stays open until is is explicitly closed.
  • Loading branch information
wonder-sk committed Feb 23, 2018
1 parent 131efbd commit 917c7b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/app/vertextool/qgsvertexeditor.cpp
Expand Up @@ -387,6 +387,13 @@ void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
}
}

void QgsVertexEditor::closeEvent( QCloseEvent *event )
{
QgsDockWidget::closeEvent( event );

emit editorClosed();
}

//
// CoordinateItemDelegate
//
Expand Down
2 changes: 2 additions & 0 deletions src/app/vertextool/qgsvertexeditor.h
Expand Up @@ -83,9 +83,11 @@ class QgsVertexEditor : public QgsDockWidget

signals:
void deleteSelectedRequested();
void editorClosed();

protected:
void keyPressEvent( QKeyEvent *event ) override;
void closeEvent( QCloseEvent *event ) override;

private slots:
void updateTableSelection();
Expand Down
3 changes: 1 addition & 2 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -374,8 +374,6 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
return;
}

cleanupVertexEditor();

if ( !mDraggingVertex && !mSelectedVertices.isEmpty() && !( e->modifiers() & Qt::ShiftModifier ) && !( e->modifiers() & Qt::ControlModifier ) )
{
// only remove highlight if not clicked on one of highlighted vertices
Expand Down Expand Up @@ -1041,6 +1039,7 @@ void QgsVertexTool::showVertexEditor() //#spellok
mVertexEditor.reset( new QgsVertexEditor( m.layer(), mSelectedFeature.get(), mCanvas ) );
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mVertexEditor.get() );
connect( mVertexEditor.get(), &QgsVertexEditor::deleteSelectedRequested, this, &QgsVertexTool::deleteVertexEditorSelection );
connect( mVertexEditor.get(), &QgsVertexEditor::editorClosed, this, &QgsVertexTool::cleanupVertexEditor );
connect( mSelectedFeature.get()->vlayer(), &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::cleanEditor );
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/vertextool/qgsvertextool.h
Expand Up @@ -119,6 +119,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void removeTemporaryRubberBands();

void cleanupVertexEditor();

/**
* Temporarily override snapping config and snap to vertices and edges
of any editable vector layer, to allow selection of vertex for editing
Expand Down Expand Up @@ -202,8 +204,6 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
*/
bool matchEdgeCenterTest( const QgsPointLocator::Match &m, const QgsPointXY &mapPoint, QgsPointXY *edgeCenterPtr = nullptr );

void cleanupVertexEditor();

//! Run validation on a geometry (in a background thread)
void validateGeometry( QgsVectorLayer *layer, QgsFeatureId featureId );

Expand Down

0 comments on commit 917c7b6

Please sign in to comment.