Do not auto-close vertex editor on any mouse click (ref #17243)

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.
This commit is contained in:
Martin Dobias 2018-02-23 10:47:31 +00:00
parent 131efbdd1e
commit 917c7b6f19
4 changed files with 12 additions and 4 deletions

View File

@ -387,6 +387,13 @@ void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
} }
} }
void QgsVertexEditor::closeEvent( QCloseEvent *event )
{
QgsDockWidget::closeEvent( event );
emit editorClosed();
}
// //
// CoordinateItemDelegate // CoordinateItemDelegate
// //

View File

@ -83,9 +83,11 @@ class QgsVertexEditor : public QgsDockWidget
signals: signals:
void deleteSelectedRequested(); void deleteSelectedRequested();
void editorClosed();
protected: protected:
void keyPressEvent( QKeyEvent *event ) override; void keyPressEvent( QKeyEvent *event ) override;
void closeEvent( QCloseEvent *event ) override;
private slots: private slots:
void updateTableSelection(); void updateTableSelection();

View File

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

View File

@ -119,6 +119,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
void removeTemporaryRubberBands(); void removeTemporaryRubberBands();
void cleanupVertexEditor();
/** /**
* Temporarily override snapping config and snap to vertices and edges * Temporarily override snapping config and snap to vertices and edges
of any editable vector layer, to allow selection of vertex for editing of any editable vector layer, to allow selection of vertex for editing
@ -202,8 +204,6 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
*/ */
bool matchEdgeCenterTest( const QgsPointLocator::Match &m, const QgsPointXY &mapPoint, QgsPointXY *edgeCenterPtr = nullptr ); bool matchEdgeCenterTest( const QgsPointLocator::Match &m, const QgsPointXY &mapPoint, QgsPointXY *edgeCenterPtr = nullptr );
void cleanupVertexEditor();
//! Run validation on a geometry (in a background thread) //! Run validation on a geometry (in a background thread)
void validateGeometry( QgsVectorLayer *layer, QgsFeatureId featureId ); void validateGeometry( QgsVectorLayer *layer, QgsFeatureId featureId );