@@ -579,6 +579,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
579579 mpGpsDock->setWidget ( mpGpsWidget );
580580 mpGpsDock->hide ();
581581
582+ mLastMapToolMessage = 0 ;
583+
582584 mLogViewer = new QgsMessageLogViewer ( statusBar (), this );
583585
584586 mLogDock = new QDockWidget ( tr ( " Log Messages" ), this );
@@ -1890,8 +1892,8 @@ void QgisApp::setupConnections()
18901892 this , SLOT ( showScale ( double ) ) );
18911893 connect ( mMapCanvas , SIGNAL ( scaleChanged ( double ) ),
18921894 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 * ) ) );
18951897 connect ( mMapCanvas , SIGNAL ( selectionChanged ( QgsMapLayer * ) ),
18961898 this , SLOT ( selectionChanged ( QgsMapLayer * ) ) );
18971899 connect ( mMapCanvas , SIGNAL ( extentsChanged () ),
@@ -2006,9 +2008,9 @@ void QgisApp::createCanvasTools()
20062008 mMapTools .mMoveFeature ->setAction ( mActionMoveFeature );
20072009 mMapTools .mRotateFeature = new QgsMapToolRotateFeature ( mMapCanvas );
20082010 mMapTools .mRotateFeature ->setAction ( mActionRotateFeature );
2009- // need at least geos 3.3 for OffsetCurve tool
2011+ // need at least geos 3.3 for OffsetCurve tool
20102012#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 )))
20122014 mMapTools .mOffsetCurve = new QgsMapToolOffsetCurve ( mMapCanvas );
20132015 mMapTools .mOffsetCurve ->setAction ( mActionOffsetCurve );
20142016#else
@@ -2059,7 +2061,7 @@ void QgisApp::createCanvasTools()
20592061 mMapTools .mRotateLabel ->setAction ( mActionRotateLabel );
20602062 mMapTools .mChangeLabelProperties = new QgsMapToolChangeLabelProperties ( mMapCanvas );
20612063 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
20632065 mNonEditMapTool = mMapTools .mPan ;
20642066}
20652067
@@ -8020,11 +8022,25 @@ void QgisApp::showProgress( int theProgress, int theTotalSteps )
80208022 }
80218023}
80228024
8023- void QgisApp::mapToolChanged ( QgsMapTool *tool )
8025+ void QgisApp::mapToolChanged ( QgsMapTool *newTool, QgsMapTool *oldTool )
80248026{
8025- if ( tool && !tool-> isEditTool () )
8027+ if ( oldTool )
80268028 {
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 () ) );
80288044 }
80298045}
80308046
@@ -8151,6 +8167,27 @@ void QgisApp::showStatusMessage( QString theMessage )
81518167 statusBar ()->showMessage ( theMessage );
81528168}
81538169
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+ messageBar ()->pushItem ( mLastMapToolMessage );
8181+ }
8182+ }
8183+
8184+ void QgisApp::removeMapToolMessage ()
8185+ {
8186+ // remove previous message
8187+ messageBar ()->popWidget ( mLastMapToolMessage );
8188+ }
8189+
8190+
81548191// Show the maptip using tooltip
81558192void QgisApp::showMapTip ()
81568193{
0 commit comments