Skip to content
Permalink
Browse files

Handle deleting map views

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 864cae4 commit 2c61e4c4c3246f429cc4451ef43896af647c6710
Showing with 21 additions and 0 deletions.
  1. +17 −0 src/app/qgsmapcanvasdockwidget.cpp
  2. +4 −0 src/app/qgsmapcanvasdockwidget.h
@@ -15,11 +15,13 @@
#include "qgsmapcanvasdockwidget.h"
#include "qgsmapcanvas.h"
#include "qgsprojectionselectiondialog.h"
#include <QMessageBox>

QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *parent )
: QgsDockWidget( parent )
{
setupUi( this );
setAttribute( Qt::WA_DeleteOnClose );

mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
mContents->layout()->setMargin( 0 );
@@ -42,9 +44,24 @@ QgsMapCanvas *QgsMapCanvasDockWidget::mapCanvas()
return mMapCanvas;
}

void QgsMapCanvasDockWidget::closeEvent( QCloseEvent *event )
{
if ( mMapCanvas->layerCount() > 0
&& QMessageBox::question( this, tr( "Close map view" ),
tr( "Are you sure you want to close this map view?" ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::No )
{
event->ignore();
}
else
{
event->accept();
}
}

void QgsMapCanvasDockWidget::setMapCrs()
{
QgsProjectionSelectionDialog dlg;
dlg.setShowNoProjection( true );
dlg.setCrs( mMapCanvas->mapSettings().destinationCrs() );

if ( dlg.exec() )
@@ -33,6 +33,10 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QgsDockWidget, private Ui::QgsM
*/
QgsMapCanvas *mapCanvas();

protected:

virtual void closeEvent( QCloseEvent *event ) override;

private slots:

void setMapCrs();

0 comments on commit 2c61e4c

Please sign in to comment.
You can’t perform that action at this time.