mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Fix tracing still active when snapping is turned off
Otherwise tracing is disabled in the snapping toolbar, yet still active on the canvas.
This commit is contained in:
parent
63ba4feab6
commit
66aaaadd67
@ -43,6 +43,21 @@ Access to action that user may use to toggle tracing on/off. May be null if no a
|
|||||||
%Docstring
|
%Docstring
|
||||||
Assign "enable tracing" checkable action to the tracer.
|
Assign "enable tracing" checkable action to the tracer.
|
||||||
The action is used to determine whether tracing is currently enabled by the user
|
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
|
%End
|
||||||
|
|
||||||
static QgsMapCanvasTracer *tracerForCanvas( QgsMapCanvas *canvas );
|
static QgsMapCanvasTracer *tracerForCanvas( QgsMapCanvas *canvas );
|
||||||
|
@ -2415,6 +2415,7 @@ void QgisApp::createToolBars()
|
|||||||
|
|
||||||
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() );
|
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() );
|
||||||
mTracer->setActionEnableTracing( mSnappingWidget->enableTracingAction() );
|
mTracer->setActionEnableTracing( mSnappingWidget->enableTracingAction() );
|
||||||
|
mTracer->setActionEnableSnapping( mSnappingWidget->enableSnappingAction() );
|
||||||
connect( mSnappingWidget->tracingOffsetSpinBox(), static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ),
|
connect( mSnappingWidget->tracingOffsetSpinBox(), static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ),
|
||||||
this, [ = ]( double v ) { mTracer->setOffset( v ); } );
|
this, [ = ]( double v ) { mTracer->setOffset( v ); } );
|
||||||
|
|
||||||
|
@ -75,6 +75,11 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
|
|||||||
*/
|
*/
|
||||||
QAction *enableTracingAction() { return mEnableTracingAction; }
|
QAction *enableTracingAction() { return mEnableTracingAction; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the enable snapping action widget.
|
||||||
|
*/
|
||||||
|
QAction *enableSnappingAction() { return mEnabledAction; }
|
||||||
|
|
||||||
//! Returns spin box used to set offset for tracing
|
//! Returns spin box used to set offset for tracing
|
||||||
QgsDoubleSpinBox *tracingOffsetSpinBox() { return mTracingOffsetSpinBox; }
|
QgsDoubleSpinBox *tracingOffsetSpinBox() { return mTracingOffsetSpinBox; }
|
||||||
|
|
||||||
|
@ -55,6 +55,19 @@ class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer
|
|||||||
*/
|
*/
|
||||||
void setActionEnableTracing( QAction *action ) { mActionEnableTracing = action; }
|
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).
|
* Retrieve instance of this class associated with given canvas (if any).
|
||||||
* The class keeps a simple registry of tracers associated with map canvas
|
* 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;
|
QgsMessageBarItem *mLastMessage = nullptr;
|
||||||
|
|
||||||
QAction *mActionEnableTracing = nullptr;
|
QAction *mActionEnableTracing = nullptr;
|
||||||
|
QAction *mActionEnableSnapping = nullptr;
|
||||||
|
|
||||||
static QHash<QgsMapCanvas *, QgsMapCanvasTracer *> sTracers;
|
static QHash<QgsMapCanvas *, QgsMapCanvasTracer *> sTracers;
|
||||||
};
|
};
|
||||||
|
@ -129,7 +129,8 @@ void QgsMapToolCapture::currentLayerChanged( QgsMapLayer *layer )
|
|||||||
bool QgsMapToolCapture::tracingEnabled()
|
bool QgsMapToolCapture::tracingEnabled()
|
||||||
{
|
{
|
||||||
QgsMapCanvasTracer *tracer = QgsMapCanvasTracer::tracerForCanvas( mCanvas );
|
QgsMapCanvasTracer *tracer = QgsMapCanvasTracer::tracerForCanvas( mCanvas );
|
||||||
return tracer && tracer->actionEnableTracing() && tracer->actionEnableTracing()->isChecked();
|
return tracer && ( !tracer->actionEnableTracing() || tracer->actionEnableTracing()->isChecked() )
|
||||||
|
&& ( !tracer->actionEnableSnapping() || tracer->actionEnableSnapping()->isChecked() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user