diff --git a/images/images.qrc b/images/images.qrc index 4d065a3f68a..ed5a42ca92c 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -197,6 +197,7 @@ themes/default/mIconFavourites.png themes/default/mIconFirst.png themes/default/mIconGeometryLayer.png + themes/default/mIconInfo.png themes/default/mIconLast.png themes/default/mIconLayer.png themes/default/mIconLineLayer.png diff --git a/images/themes/default/mIconInfo.png b/images/themes/default/mIconInfo.png new file mode 100644 index 00000000000..30766666889 Binary files /dev/null and b/images/themes/default/mIconInfo.png differ diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index caf1005bcfa..ec3f00dadf4 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -4040,11 +4040,11 @@ void QgisApp::labeling() if ( layer == NULL || layer->type() != QgsMapLayer::VectorLayer ) { QWidget* msg = QgsMessageBar::createMessage( - tr( "Labeling: " ), + tr( "Labeling Options: " ), tr( "Please select a vector layer first." ) , - QgsApplication::getThemeIcon( "/mIconWarn.png" ), + QgsApplication::getThemeIcon( "/mIconInfo.png" ), mInfoBar ); - mInfoBar->pushWidget( msg, QgsMessageBar::WARNING, 4 ); + mInfoBar->pushWidget( msg, QgsMessageBar::WARNING, 5 ); return; } diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index f6904649424..f8d05137997 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -54,8 +54,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) if ( !vlayer ) { - QMessageBox::information( 0, tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); + notifyNotVectorLayer(); return; } @@ -72,9 +71,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; } diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp index 3bbc22095a6..8943a4293b0 100644 --- a/src/app/qgsmaptooladdpart.cpp +++ b/src/app/qgsmaptooladdpart.cpp @@ -39,18 +39,13 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e ) QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); if ( !vlayer ) { - QMessageBox::information( 0, - tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); + notifyNotVectorLayer(); return; } if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, - tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; } diff --git a/src/app/qgsmaptooladdring.cpp b/src/app/qgsmaptooladdring.cpp index acc48ef77c7..18777a7b7f8 100644 --- a/src/app/qgsmaptooladdring.cpp +++ b/src/app/qgsmaptooladdring.cpp @@ -39,16 +39,13 @@ void QgsMapToolAddRing::canvasReleaseEvent( QMouseEvent * e ) if ( !vlayer ) { - QMessageBox::information( 0, tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); + notifyNotVectorLayer(); return; } if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; } diff --git a/src/app/qgsmaptooledit.cpp b/src/app/qgsmaptooledit.cpp index dbde6b6bc5d..c90d24eba35 100644 --- a/src/app/qgsmaptooledit.cpp +++ b/src/app/qgsmaptooledit.cpp @@ -14,6 +14,9 @@ ***************************************************************************/ #include "qgsmaptooledit.h" +#include "qgisapp.h" +#include "qgsapplication.h" +#include "qgsmessagebar.h" #include "qgsproject.h" #include "qgsmapcanvas.h" #include "qgsrubberband.h" @@ -119,4 +122,22 @@ int QgsMapToolEdit::addTopologicalPoints( const QList& geom ) return 0; } +void QgsMapToolEdit::notifyNotVectorLayer() +{ + QWidget* msg = QgsMessageBar::createMessage( + QObject::tr( "No active vector layer: " ), + QObject::tr( "Choose a vector layer in the legend" ) , + QgsApplication::getThemeIcon( "/mIconInfo.png" ), + QgisApp::instance()->messageBar() ); + QgisApp::instance()->messageBar()->pushWidget( msg, QgsMessageBar::WARNING, 5 ); +} +void QgsMapToolEdit::notifyNotEditableLayer() +{ + QWidget* msg = QgsMessageBar::createMessage( + QObject::tr( "Layer not editable: " ), + QObject::tr( "Use 'Toggle Editing' to make it editable" ) , + QgsApplication::getThemeIcon( "/mIconInfo.png" ), + QgisApp::instance()->messageBar() ); + QgisApp::instance()->messageBar()->pushWidget( msg, QgsMessageBar::WARNING, 5 ); +} diff --git a/src/app/qgsmaptooledit.h b/src/app/qgsmaptooledit.h index ebc28d7e566..2173c373878 100644 --- a/src/app/qgsmaptooledit.h +++ b/src/app/qgsmaptooledit.h @@ -63,6 +63,13 @@ class QgsMapToolEdit: public QgsMapTool @return 0 in case of success*/ int addTopologicalPoints( const QList& geom ); + /**Display a timed message bar noting the active layer is not vector. + @note added in QGIS 1.9*/ + void notifyNotVectorLayer(); + /**Display a timed message bar noting the active vector layer is not editable. + @note added in QGIS 1.9*/ + void notifyNotEditableLayer(); + }; #endif diff --git a/src/app/qgsmaptoolmovefeature.cpp b/src/app/qgsmaptoolmovefeature.cpp index a44d4fc0bd9..b3b0435dccf 100644 --- a/src/app/qgsmaptoolmovefeature.cpp +++ b/src/app/qgsmaptoolmovefeature.cpp @@ -56,14 +56,13 @@ void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e ) QgsVectorLayer* vlayer = currentVectorLayer(); if ( !vlayer ) { + notifyNotVectorLayer(); return; } if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; } diff --git a/src/app/qgsmaptooloffsetcurve.cpp b/src/app/qgsmaptooloffsetcurve.cpp index 09f7f463897..67b3fcb9a06 100644 --- a/src/app/qgsmaptooloffsetcurve.cpp +++ b/src/app/qgsmaptooloffsetcurve.cpp @@ -43,10 +43,16 @@ void QgsMapToolOffsetCurve::canvasPressEvent( QMouseEvent* e ) mGeometryModified = false; mForceCopy = false; + if ( !mCanvas ) + { + return; + } + //get selected features or snap to nearest feature if no selection QgsVectorLayer* layer = currentVectorLayer(); - if ( !mCanvas || !layer ) + if ( !layer ) { + notifyNotVectorLayer(); return; } diff --git a/src/app/qgsmaptoolreshape.cpp b/src/app/qgsmaptoolreshape.cpp index af81ab1a1f4..4bd05963e80 100644 --- a/src/app/qgsmaptoolreshape.cpp +++ b/src/app/qgsmaptoolreshape.cpp @@ -38,16 +38,13 @@ void QgsMapToolReshape::canvasReleaseEvent( QMouseEvent * e ) if ( !vlayer ) { - QMessageBox::information( 0, tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); + notifyNotVectorLayer(); return; } if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; } diff --git a/src/app/qgsmaptoolrotatepointsymbols.cpp b/src/app/qgsmaptoolrotatepointsymbols.cpp index 8a1537f2008..47db803dc65 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.cpp +++ b/src/app/qgsmaptoolrotatepointsymbols.cpp @@ -78,10 +78,17 @@ void QgsMapToolRotatePointSymbols::canvasPressEvent( QMouseEvent *e ) mActiveLayer = currentVectorLayer(); if ( !mActiveLayer ) { + notifyNotVectorLayer(); return; } - if ( mActiveLayer->geometryType() != QGis::Point || !mActiveLayer->isEditable() ) + if ( !mActiveLayer->isEditable() ) + { + notifyNotEditableLayer(); + return; + } + + if ( mActiveLayer->geometryType() != QGis::Point ) { return; } diff --git a/src/app/qgsmaptoolselectutils.cpp b/src/app/qgsmaptoolselectutils.cpp index ff67114f25b..0e501daf19a 100644 --- a/src/app/qgsmaptoolselectutils.cpp +++ b/src/app/qgsmaptoolselectutils.cpp @@ -16,6 +16,9 @@ email : jpalmer at linz dot govt dot nz #include #include "qgsmaptoolselectutils.h" +#include "qgisapp.h" +#include "qgsapplication.h" +#include "qgsmessagebar.h" #include "qgsmapcanvas.h" #include "qgsvectorlayer.h" #include "qgsfeature.h" @@ -35,10 +38,12 @@ QgsVectorLayer* QgsMapToolSelectUtils::getCurrentVectorLayer( QgsMapCanvas* canv if ( !canvas->currentLayer() || ( vlayer = qobject_cast( canvas->currentLayer() ) ) == NULL ) { - QMessageBox::warning( canvas, QObject::tr( "No active vector layer" ), - QObject::tr( "To select features, you must choose a " - "vector layer by clicking on its name in the legend" - ) ); + QWidget* msg = QgsMessageBar::createMessage( + QObject::tr( "No active vector layer: " ), + QObject::tr( "To select features, choose a vector layer in the legend" ) , + QgsApplication::getThemeIcon( "/mIconInfo.png" ), + QgisApp::instance()->messageBar() ); + QgisApp::instance()->messageBar()->pushWidget( msg, QgsMessageBar::WARNING, 5 ); } return vlayer; } diff --git a/src/app/qgsmaptoolsimplify.cpp b/src/app/qgsmaptoolsimplify.cpp index 008ea35c647..d16c342bbf4 100644 --- a/src/app/qgsmaptoolsimplify.cpp +++ b/src/app/qgsmaptoolsimplify.cpp @@ -251,6 +251,13 @@ bool QgsMapToolSimplify::calculateSliderBoudaries() void QgsMapToolSimplify::canvasPressEvent( QMouseEvent * e ) { QgsVectorLayer * vlayer = currentVectorLayer(); + + if ( !vlayer ) + { + notifyNotVectorLayer(); + return; + } + QgsPoint layerCoords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() ); double r = QgsTolerance::vertexSearchRadius( vlayer, mCanvas->mapRenderer() ); diff --git a/src/app/qgsmaptoolsplitfeatures.cpp b/src/app/qgsmaptoolsplitfeatures.cpp index 36836aa6764..48c8b107efa 100644 --- a/src/app/qgsmaptoolsplitfeatures.cpp +++ b/src/app/qgsmaptoolsplitfeatures.cpp @@ -38,16 +38,13 @@ void QgsMapToolSplitFeatures::canvasReleaseEvent( QMouseEvent * e ) if ( !vlayer ) { - QMessageBox::information( 0, tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); + notifyNotVectorLayer(); return; } if ( !vlayer->isEditable() ) { - QMessageBox::information( 0, tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); + notifyNotEditableLayer(); return; }