Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix tracing still active when snapping is turned off
Otherwise tracing is disabled in the snapping toolbar, yet still
active on the canvas.
- Loading branch information
|
@@ -43,6 +43,21 @@ Access to action that user may use to toggle tracing on/off. May be null if no a |
|
|
%Docstring |
|
|
Assign "enable tracing" checkable action to the tracer. |
|
|
The action is used to determine whether tracing is currently enabled by the user |
|
|
%End |
|
|
|
|
|
QAction *actionEnableSnapping() const; |
|
|
%Docstring |
|
|
Access to action that user may use to toggle snapping on/off. May be null if no action was associated. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
|
void setActionEnableSnapping( QAction *action ); |
|
|
%Docstring |
|
|
Assign "enable snapping" checkable action to the tracer. |
|
|
The action is used to determine whether snapping is currently enabled by the user. |
|
|
|
|
|
.. versionadded:: 3.0 |
|
|
%End |
|
|
|
|
|
static QgsMapCanvasTracer *tracerForCanvas( QgsMapCanvas *canvas ); |
|
|
|
@@ -2415,6 +2415,7 @@ void QgisApp::createToolBars() |
|
|
|
|
|
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() ); |
|
|
mTracer->setActionEnableTracing( mSnappingWidget->enableTracingAction() ); |
|
|
mTracer->setActionEnableSnapping( mSnappingWidget->enableSnappingAction() ); |
|
|
connect( mSnappingWidget->tracingOffsetSpinBox(), static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ), |
|
|
this, [ = ]( double v ) { mTracer->setOffset( v ); } ); |
|
|
|
|
|
|
@@ -75,6 +75,11 @@ class APP_EXPORT QgsSnappingWidget : public QWidget |
|
|
*/ |
|
|
QAction *enableTracingAction() { return mEnableTracingAction; } |
|
|
|
|
|
/** |
|
|
* Returns the enable snapping action widget. |
|
|
*/ |
|
|
QAction *enableSnappingAction() { return mEnabledAction; } |
|
|
|
|
|
//! Returns spin box used to set offset for tracing |
|
|
QgsDoubleSpinBox *tracingOffsetSpinBox() { return mTracingOffsetSpinBox; } |
|
|
|
|
|
|
@@ -55,6 +55,19 @@ class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer |
|
|
*/ |
|
|
void setActionEnableTracing( QAction *action ) { mActionEnableTracing = action; } |
|
|
|
|
|
/** |
|
|
* Access to action that user may use to toggle snapping on/off. May be null if no action was associated. |
|
|
* \since QGIS 3.0 |
|
|
*/ |
|
|
QAction *actionEnableSnapping() const { return mActionEnableSnapping; } |
|
|
|
|
|
/** |
|
|
* Assign "enable snapping" checkable action to the tracer. |
|
|
* The action is used to determine whether snapping is currently enabled by the user. |
|
|
* \since QGIS 3.0 |
|
|
*/ |
|
|
void setActionEnableSnapping( QAction *action ) { mActionEnableSnapping = action; } |
|
|
|
|
|
/** |
|
|
* Retrieve instance of this class associated with given canvas (if any). |
|
|
* The class keeps a simple registry of tracers associated with map canvas |
|
@@ -78,6 +91,7 @@ class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer |
|
|
QgsMessageBarItem *mLastMessage = nullptr; |
|
|
|
|
|
QAction *mActionEnableTracing = nullptr; |
|
|
QAction *mActionEnableSnapping = nullptr; |
|
|
|
|
|
static QHash<QgsMapCanvas *, QgsMapCanvasTracer *> sTracers; |
|
|
}; |
|
|
|
@@ -129,7 +129,8 @@ void QgsMapToolCapture::currentLayerChanged( QgsMapLayer *layer ) |
|
|
bool QgsMapToolCapture::tracingEnabled() |
|
|
{ |
|
|
QgsMapCanvasTracer *tracer = QgsMapCanvasTracer::tracerForCanvas( mCanvas ); |
|
|
return tracer && tracer->actionEnableTracing() && tracer->actionEnableTracing()->isChecked(); |
|
|
return tracer && ( !tracer->actionEnableTracing() || tracer->actionEnableTracing()->isChecked() ) |
|
|
&& ( !tracer->actionEnableSnapping() || tracer->actionEnableSnapping()->isChecked() ); |
|
|
} |
|
|
|
|
|
|
|
|