@@ -579,6 +579,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
579
579
mpGpsDock->setWidget ( mpGpsWidget );
580
580
mpGpsDock->hide ();
581
581
582
+ mLastMapToolMessage = 0 ;
583
+
582
584
mLogViewer = new QgsMessageLogViewer ( statusBar (), this );
583
585
584
586
mLogDock = new QDockWidget ( tr ( " Log Messages" ), this );
@@ -1890,8 +1892,8 @@ void QgisApp::setupConnections()
1890
1892
this , SLOT ( showScale ( double ) ) );
1891
1893
connect ( mMapCanvas , SIGNAL ( scaleChanged ( double ) ),
1892
1894
this , SLOT ( updateMouseCoordinatePrecision () ) );
1893
- connect ( mMapCanvas , SIGNAL ( mapToolSet ( QgsMapTool * ) ),
1894
- this , SLOT ( mapToolChanged ( QgsMapTool * ) ) );
1895
+ connect ( mMapCanvas , SIGNAL ( mapToolSet ( QgsMapTool *, QgsMapTool * ) ),
1896
+ this , SLOT ( mapToolChanged ( QgsMapTool *, QgsMapTool * ) ) );
1895
1897
connect ( mMapCanvas , SIGNAL ( selectionChanged ( QgsMapLayer * ) ),
1896
1898
this , SLOT ( selectionChanged ( QgsMapLayer * ) ) );
1897
1899
connect ( mMapCanvas , SIGNAL ( extentsChanged () ),
@@ -2006,9 +2008,9 @@ void QgisApp::createCanvasTools()
2006
2008
mMapTools .mMoveFeature ->setAction ( mActionMoveFeature );
2007
2009
mMapTools .mRotateFeature = new QgsMapToolRotateFeature ( mMapCanvas );
2008
2010
mMapTools .mRotateFeature ->setAction ( mActionRotateFeature );
2009
- // need at least geos 3.3 for OffsetCurve tool
2011
+ // need at least geos 3.3 for OffsetCurve tool
2010
2012
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
2011
- ((GEOS_VERSION_MAJOR>3 ) || ((GEOS_VERSION_MAJOR==3 ) && (GEOS_VERSION_MINOR>=3 )))
2013
+ ((GEOS_VERSION_MAJOR>3 ) || ((GEOS_VERSION_MAJOR==3 ) && (GEOS_VERSION_MINOR>=3 )))
2012
2014
mMapTools .mOffsetCurve = new QgsMapToolOffsetCurve ( mMapCanvas );
2013
2015
mMapTools .mOffsetCurve ->setAction ( mActionOffsetCurve );
2014
2016
#else
@@ -2059,7 +2061,7 @@ void QgisApp::createCanvasTools()
2059
2061
mMapTools .mRotateLabel ->setAction ( mActionRotateLabel );
2060
2062
mMapTools .mChangeLabelProperties = new QgsMapToolChangeLabelProperties ( mMapCanvas );
2061
2063
mMapTools .mChangeLabelProperties ->setAction ( mActionChangeLabelProperties );
2062
- // ensure that non edit tool is initialised or we will get crashes in some situations
2064
+ // ensure that non edit tool is initialised or we will get crashes in some situations
2063
2065
mNonEditMapTool = mMapTools .mPan ;
2064
2066
}
2065
2067
@@ -8020,11 +8022,25 @@ void QgisApp::showProgress( int theProgress, int theTotalSteps )
8020
8022
}
8021
8023
}
8022
8024
8023
- void QgisApp::mapToolChanged ( QgsMapTool *tool )
8025
+ void QgisApp::mapToolChanged ( QgsMapTool *newTool, QgsMapTool *oldTool )
8024
8026
{
8025
- if ( tool && !tool-> isEditTool () )
8027
+ if ( oldTool )
8026
8028
{
8027
- mNonEditMapTool = tool;
8029
+ disconnect ( oldTool, SIGNAL ( displayMessage ( QString ) ), this , SLOT ( displayMapToolMessage ( QString ) ) );
8030
+ disconnect ( oldTool, SIGNAL ( displayMessage ( QString, QgsMessageBar::MessageLevel ) ), this , SLOT ( displayMapToolMessage ( QString, QgsMessageBar::MessageLevel ) ) );
8031
+ disconnect ( oldTool, SIGNAL ( removeMessage () ), this , SLOT ( removeMapToolMessage () ) );
8032
+ }
8033
+
8034
+ if ( newTool )
8035
+ {
8036
+ if ( !newTool->isEditTool () )
8037
+ {
8038
+ mNonEditMapTool = newTool;
8039
+ }
8040
+
8041
+ connect ( newTool, SIGNAL ( displayMessage ( QString ) ), this , SLOT ( displayMapToolMessage ( QString ) ) );
8042
+ connect ( newTool, SIGNAL ( displayMessage ( QString, QgsMessageBar::MessageLevel ) ), this , SLOT ( displayMapToolMessage ( QString, QgsMessageBar::MessageLevel ) ) );
8043
+ connect ( newTool, SIGNAL ( removeMessage () ), this , SLOT ( removeMapToolMessage () ) );
8028
8044
}
8029
8045
}
8030
8046
@@ -8151,6 +8167,27 @@ void QgisApp::showStatusMessage( QString theMessage )
8151
8167
statusBar ()->showMessage ( theMessage );
8152
8168
}
8153
8169
8170
+ void QgisApp::displayMapToolMessage ( QString message, QgsMessageBar::MessageLevel level )
8171
+ {
8172
+ // remove previous message
8173
+ messageBar ()->popWidget ( mLastMapToolMessage );
8174
+
8175
+ QgsMapTool* tool = mapCanvas ()->mapTool ();
8176
+
8177
+ if ( tool )
8178
+ {
8179
+ mLastMapToolMessage = new QgsMessageBarItem ( tool->toolName (), message, level, messageTimeout () );
8180
+ QgisApp::instance ()->messageBar ()->pushItem ( mLastMapToolMessage );
8181
+ }
8182
+ }
8183
+
8184
+ void QgisApp::removeMapToolMessage ()
8185
+ {
8186
+ // remove previous message
8187
+ messageBar ()->popWidget ( mLastMapToolMessage );
8188
+ }
8189
+
8190
+
8154
8191
// Show the maptip using tooltip
8155
8192
void QgisApp::showMapTip ()
8156
8193
{
0 commit comments