File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
python/gui/auto_generated Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,13 @@ the previously used toolbutton to pop out. *
116116 QAction *action();
117117%Docstring
118118Returns associated action with map tool or NULL if no action is associated
119+ %End
120+
121+ bool isActive() const;
122+ %Docstring
123+ Returns if the current map tool active on the map canvas
124+
125+ .. versionadded:: 3.4
119126%End
120127
121128 void setButton( QAbstractButton *button );
Original file line number Diff line number Diff line change @@ -130,6 +130,11 @@ QAction *QgsMapTool::action()
130130 return mAction ;
131131}
132132
133+ bool QgsMapTool::isActive () const
134+ {
135+ return mCanvas && mCanvas ->mapTool () == this ;
136+ }
137+
133138void QgsMapTool::setButton ( QAbstractButton *button )
134139{
135140 mButton = button;
@@ -143,6 +148,8 @@ QAbstractButton *QgsMapTool::button()
143148void QgsMapTool::setCursor ( const QCursor &cursor )
144149{
145150 mCursor = cursor;
151+ if ( isActive () )
152+ mCanvas ->setCursor ( mCursor );
146153}
147154
148155
Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ class GUI_EXPORT QgsMapTool : public QObject
137137 // ! Returns associated action with map tool or NULL if no action is associated
138138 QAction *action ();
139139
140+ /* *
141+ * Returns if the current map tool active on the map canvas
142+ * \since QGIS 3.4
143+ */
144+ bool isActive () const ;
145+
140146 /* *
141147 * Use this to associate a button to this maptool. It has the same meaning
142148 * as setAction() function except it works with a button instead of an QAction. */
You can’t perform that action at this time.
0 commit comments