Skip to content
Permalink
Browse files

add isActive to QgsMapTool and update cursor when it is active

  • Loading branch information
3nids committed Oct 19, 2018
1 parent b3e5263 commit 773167411c1079d57483ca512f2919002be23123
Showing with 20 additions and 0 deletions.
  1. +7 −0 python/gui/auto_generated/qgsmaptool.sip.in
  2. +7 −0 src/gui/qgsmaptool.cpp
  3. +6 −0 src/gui/qgsmaptool.h
@@ -116,6 +116,13 @@ the previously used toolbutton to pop out. *
QAction *action();
%Docstring
Returns associated action with map tool or NULL if no action is associated
%End

bool isActive() const;
%Docstring
Returns if the current map tool active on the map canvas

.. versionadded:: 3.4
%End

void setButton( QAbstractButton *button );
@@ -130,6 +130,11 @@ QAction *QgsMapTool::action()
return mAction;
}

bool QgsMapTool::isActive() const
{
return mCanvas && mCanvas->mapTool() == this;
}

void QgsMapTool::setButton( QAbstractButton *button )
{
mButton = button;
@@ -143,6 +148,8 @@ QAbstractButton *QgsMapTool::button()
void QgsMapTool::setCursor( const QCursor &cursor )
{
mCursor = cursor;
if ( isActive() )
mCanvas->setCursor( mCursor );
}


@@ -137,6 +137,12 @@ class GUI_EXPORT QgsMapTool : public QObject
//! Returns associated action with map tool or NULL if no action is associated
QAction *action();

/**
* Returns if the current map tool active on the map canvas
* \since QGIS 3.4
*/
bool isActive() const;

/**
* Use this to associate a button to this maptool. It has the same meaning
* as setAction() function except it works with a button instead of an QAction. */

0 comments on commit 7731674

Please sign in to comment.
You can’t perform that action at this time.