mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
Move tracing action creation to qgis app
This commit is contained in:
parent
f4bdaad59f
commit
7a5df7ada6
@ -2,6 +2,7 @@
|
|||||||
* Extension of QgsTracer that provides extra functionality:
|
* Extension of QgsTracer that provides extra functionality:
|
||||||
* - automatic updates of own configuration based on canvas settings
|
* - automatic updates of own configuration based on canvas settings
|
||||||
* - reporting of issues to the user via message bar
|
* - reporting of issues to the user via message bar
|
||||||
|
* - determines whether tracing is currently enabled by the user
|
||||||
*
|
*
|
||||||
* A simple registry of tracer instances associated to map canvas instances
|
* A simple registry of tracer instances associated to map canvas instances
|
||||||
* is kept for convenience. (Map tools do not need to create their local
|
* is kept for convenience. (Map tools do not need to create their local
|
||||||
@ -21,8 +22,12 @@ class QgsMapCanvasTracer : QgsTracer
|
|||||||
explicit QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* messageBar = 0 );
|
explicit QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* messageBar = 0 );
|
||||||
~QgsMapCanvasTracer();
|
~QgsMapCanvasTracer();
|
||||||
|
|
||||||
//! Access to action that user may use to toggle tracing on/off
|
//! Access to action that user may use to toggle tracing on/off. May be null if no action was associated
|
||||||
QAction* actionEnableTracing();
|
QAction* actionEnableTracing() const;
|
||||||
|
|
||||||
|
//! Assign "enable tracing" checkable action to the tracer.
|
||||||
|
//! The action is used to determine whether tracing is currently enabled by the user
|
||||||
|
void setActionEnableTracing( QAction* 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
|
||||||
|
@ -1981,10 +1981,10 @@ void QgisApp::createToolBars()
|
|||||||
mDigitizeToolBar->insertWidget( mActionMoveFeature, tbAddCircularString );
|
mDigitizeToolBar->insertWidget( mActionMoveFeature, tbAddCircularString );
|
||||||
|
|
||||||
// Cad toolbar
|
// Cad toolbar
|
||||||
mAdvancedDigitizeToolBar->insertAction( mActionUndo, mAdvancedDigitizingDockWidget->enableAction() );
|
mAdvancedDigitizeToolBar->insertAction( mActionEnableTracing, mAdvancedDigitizingDockWidget->enableAction() );
|
||||||
|
|
||||||
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() );
|
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() );
|
||||||
mAdvancedDigitizeToolBar->insertAction( mActionUndo, mTracer->actionEnableTracing() );
|
mTracer->setActionEnableTracing( mActionEnableTracing );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::createStatusBar()
|
void QgisApp::createStatusBar()
|
||||||
@ -9739,7 +9739,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
|||||||
mActionMergeFeatures->setEnabled( false );
|
mActionMergeFeatures->setEnabled( false );
|
||||||
mActionMergeFeatureAttributes->setEnabled( false );
|
mActionMergeFeatureAttributes->setEnabled( false );
|
||||||
mActionRotatePointSymbols->setEnabled( false );
|
mActionRotatePointSymbols->setEnabled( false );
|
||||||
mTracer->actionEnableTracing()->setEnabled( false );
|
mActionEnableTracing->setEnabled( false );
|
||||||
|
|
||||||
mActionPinLabels->setEnabled( false );
|
mActionPinLabels->setEnabled( false );
|
||||||
mActionShowHideLabels->setEnabled( false );
|
mActionShowHideLabels->setEnabled( false );
|
||||||
@ -9860,7 +9860,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
|||||||
mActionRotateFeature->setEnabled( isEditable && canChangeGeometry );
|
mActionRotateFeature->setEnabled( isEditable && canChangeGeometry );
|
||||||
mActionNodeTool->setEnabled( isEditable && canChangeGeometry );
|
mActionNodeTool->setEnabled( isEditable && canChangeGeometry );
|
||||||
|
|
||||||
mTracer->actionEnableTracing()->setEnabled( isEditable && canAddFeatures &&
|
mActionEnableTracing->setEnabled( isEditable && canAddFeatures &&
|
||||||
( vlayer->geometryType() == QGis::Line || vlayer->geometryType() == QGis::Polygon ) );
|
( vlayer->geometryType() == QGis::Line || vlayer->geometryType() == QGis::Polygon ) );
|
||||||
|
|
||||||
if ( vlayer->geometryType() == QGis::Point )
|
if ( vlayer->geometryType() == QGis::Point )
|
||||||
|
@ -17,6 +17,7 @@ QgsMapCanvasTracer::QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* mes
|
|||||||
: mCanvas( canvas )
|
: mCanvas( canvas )
|
||||||
, mMessageBar( messageBar )
|
, mMessageBar( messageBar )
|
||||||
, mLastMessage( nullptr )
|
, mLastMessage( nullptr )
|
||||||
|
, mActionEnableTracing( nullptr )
|
||||||
{
|
{
|
||||||
sTracers.insert( canvas, this );
|
sTracers.insert( canvas, this );
|
||||||
|
|
||||||
@ -27,10 +28,6 @@ QgsMapCanvasTracer::QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* mes
|
|||||||
connect( canvas, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( onCurrentLayerChanged() ) );
|
connect( canvas, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( onCurrentLayerChanged() ) );
|
||||||
connect( canvas->snappingUtils(), SIGNAL( configChanged() ), this, SLOT( invalidateGraph() ) );
|
connect( canvas->snappingUtils(), SIGNAL( configChanged() ), this, SLOT( invalidateGraph() ) );
|
||||||
|
|
||||||
mActionEnableTracing = new QAction( QIcon( QgsApplication::getThemeIcon( "/mActionTracing.png" ) ), tr( "Enable Tracing" ), this );
|
|
||||||
mActionEnableTracing->setShortcut( Qt::Key_T );
|
|
||||||
mActionEnableTracing->setCheckable( true );
|
|
||||||
|
|
||||||
// arbitrarily chosen limit that should allow for fairly fast initialization
|
// arbitrarily chosen limit that should allow for fairly fast initialization
|
||||||
// of the underlying graph structure
|
// of the underlying graph structure
|
||||||
setMaxFeatureCount( QSettings().value( "/qgis/digitizing/tracing_max_feature_count", 10000 ).toInt() );
|
setMaxFeatureCount( QSettings().value( "/qgis/digitizing/tracing_max_feature_count", 10000 ).toInt() );
|
||||||
|
@ -12,6 +12,7 @@ class QgsMessageBarItem;
|
|||||||
* Extension of QgsTracer that provides extra functionality:
|
* Extension of QgsTracer that provides extra functionality:
|
||||||
* - automatic updates of own configuration based on canvas settings
|
* - automatic updates of own configuration based on canvas settings
|
||||||
* - reporting of issues to the user via message bar
|
* - reporting of issues to the user via message bar
|
||||||
|
* - determines whether tracing is currently enabled by the user
|
||||||
*
|
*
|
||||||
* A simple registry of tracer instances associated to map canvas instances
|
* A simple registry of tracer instances associated to map canvas instances
|
||||||
* is kept for convenience. (Map tools do not need to create their local
|
* is kept for convenience. (Map tools do not need to create their local
|
||||||
@ -29,8 +30,12 @@ class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer
|
|||||||
explicit QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* messageBar = 0 );
|
explicit QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* messageBar = 0 );
|
||||||
~QgsMapCanvasTracer();
|
~QgsMapCanvasTracer();
|
||||||
|
|
||||||
//! Access to action that user may use to toggle tracing on/off
|
//! Access to action that user may use to toggle tracing on/off. May be null if no action was associated
|
||||||
QAction* actionEnableTracing() { return mActionEnableTracing; }
|
QAction* actionEnableTracing() const { return mActionEnableTracing; }
|
||||||
|
|
||||||
|
//! Assign "enable tracing" checkable action to the tracer.
|
||||||
|
//! The action is used to determine whether tracing is currently enabled by the user
|
||||||
|
void setActionEnableTracing( QAction* action ) { mActionEnableTracing = 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
|
||||||
|
@ -139,7 +139,7 @@ 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()->isChecked();
|
return tracer && tracer->actionEnableTracing() && tracer->actionEnableTracing()->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,6 +381,7 @@
|
|||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<addaction name="mActionEnableTracing"/>
|
||||||
<addaction name="mActionUndo"/>
|
<addaction name="mActionUndo"/>
|
||||||
<addaction name="mActionRedo"/>
|
<addaction name="mActionRedo"/>
|
||||||
<addaction name="mActionRotateFeature"/>
|
<addaction name="mActionRotateFeature"/>
|
||||||
@ -2398,6 +2399,21 @@ Acts on currently active editable layer</string>
|
|||||||
<string>Report an issue</string>
|
<string>Report an issue</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="mActionEnableTracing">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../images/images.qrc">
|
||||||
|
<normaloff>:/images/themes/default/mActionTracing.png</normaloff>:/images/themes/default/mActionTracing.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Tracing</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>T</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../images/images.qrc"/>
|
<include location="../../images/images.qrc"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user