mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Fix #6957, move 'not vector/editable layer' dialogs to message bar for map edit and select tools
- Move notifications to base QgsMapToolEdit class - Add QgsMessageBar::INFO icon (also useful for lightweight WARNING)
This commit is contained in:
parent
d8c1593427
commit
2c36e7d79f
@ -197,6 +197,7 @@
|
||||
<file>themes/default/mIconFavourites.png</file>
|
||||
<file>themes/default/mIconFirst.png</file>
|
||||
<file>themes/default/mIconGeometryLayer.png</file>
|
||||
<file>themes/default/mIconInfo.png</file>
|
||||
<file>themes/default/mIconLast.png</file>
|
||||
<file>themes/default/mIconLayer.png</file>
|
||||
<file>themes/default/mIconLineLayer.png</file>
|
||||
|
BIN
images/themes/default/mIconInfo.png
Normal file
BIN
images/themes/default/mIconInfo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 726 B |
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -39,18 +39,13 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e )
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<QgsPoint>& 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 );
|
||||
}
|
||||
|
@ -63,6 +63,13 @@ class QgsMapToolEdit: public QgsMapTool
|
||||
@return 0 in case of success*/
|
||||
int addTopologicalPoints( const QList<QgsPoint>& 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ email : jpalmer at linz dot govt dot nz
|
||||
#include <limits>
|
||||
|
||||
#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<QgsVectorLayer *>( 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;
|
||||
}
|
||||
|
@ -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() );
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user