Skip to content

Commit

Permalink
Add mapToolActionGroup to iface object
Browse files Browse the repository at this point in the history
Any actions added by plugins for toggling a map tool should also
be added to this action group so that they behave identically
to the native, in-built map tool actions.
  • Loading branch information
nyalldawson committed Oct 22, 2020
1 parent 460bf8e commit abacccb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions python/gui/auto_generated/qgisinterface.sip.in
Expand Up @@ -446,6 +446,16 @@ Returns the native "Vertex Tool for Active Layer" action.
.. seealso:: :py:func:`actionVertexTool`

.. versionadded:: 3.6
%End

virtual QActionGroup *mapToolActionGroup() = 0;
%Docstring
Returns the action group for map tools.

Any actions added by plugins for toggling a map tool should also be added to this action
group so that they behave identically to the native, in-built map tool actions.

.. versionadded:: 3.16
%End

virtual QAction *actionPan() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -643,7 +643,7 @@ QToolBar *QgisAppInterface::rasterToolBar() { return qgis->rasterToolBar(); }
QToolBar *QgisAppInterface::vectorToolBar() { return qgis->vectorToolBar(); }
QToolBar *QgisAppInterface::databaseToolBar() { return qgis->databaseToolBar(); }
QToolBar *QgisAppInterface::webToolBar() { return qgis->webToolBar(); }

QActionGroup *QgisAppInterface::mapToolActionGroup() { return qgis->mMapToolGroup; }
QAction *QgisAppInterface::actionNewProject() { return qgis->actionNewProject(); }
QAction *QgisAppInterface::actionOpenProject() { return qgis->actionOpenProject(); }
QAction *QgisAppInterface::actionSaveProject() { return qgis->actionSaveProject(); }
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -189,6 +189,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
QToolBar *vectorToolBar() override;
QToolBar *databaseToolBar() override;
QToolBar *webToolBar() override;
QActionGroup *mapToolActionGroup() override;
QAction *actionNewProject() override;
QAction *actionOpenProject() override;
QAction *actionSaveProject() override;
Expand Down
11 changes: 11 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -35,6 +35,7 @@ class QToolBar;
class QDockWidget;
class QMainWindow;
class QWidget;
class QActionGroup;

class QgsAdvancedDigitizingDockWidget;
class QgsAttributeDialog;
Expand Down Expand Up @@ -434,6 +435,16 @@ class GUI_EXPORT QgisInterface : public QObject
*/
virtual QAction *actionVertexToolActiveLayer() = 0;

/**
* Returns the action group for map tools.
*
* Any actions added by plugins for toggling a map tool should also be added to this action
* group so that they behave identically to the native, in-built map tool actions.
*
* \since QGIS 3.16
*/
virtual QActionGroup *mapToolActionGroup() = 0;

// View menu actions
//! Returns the native pan action. Call trigger() on it to set the default pan map tool.
virtual QAction *actionPan() = 0;
Expand Down

0 comments on commit abacccb

Please sign in to comment.