From e4b9dfc1053adf4b7e8fc8014cbea34ecdf87c59 Mon Sep 17 00:00:00 2001 From: Etienne Tourigny Date: Sun, 24 Jun 2012 22:02:42 -0300 Subject: [PATCH] add New Blank Project action that creates a blank project, regardless of template settings --- src/app/qgisapp.cpp | 29 +++++++++++++++++++---------- src/app/qgisapp.h | 6 ++++-- src/ui/qgisapp.ui | 13 +++++++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index a6570ca34569..269c400ae244 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -819,6 +819,7 @@ void QgisApp::createActions() // File Menu Items connect( mActionNewProject, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); + connect( mActionNewBlankProject, SIGNAL( triggered() ), this, SLOT( fileNewBlank() ) ); connect( mActionOpenProject, SIGNAL( triggered() ), this, SLOT( fileOpen() ) ); connect( mActionSaveProject, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); connect( mActionSaveProjectAs, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); @@ -2881,15 +2882,20 @@ void QgisApp::fileExit() } - void QgisApp::fileNew() { fileNew( true ); // prompts whether to save project } // fileNew() +void QgisApp::fileNewBlank() +{ + fileNew( true, true ); +} + + //as file new but accepts flags to indicate whether we should prompt to save -void QgisApp::fileNew( bool thePromptToSaveFlag ) +void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank ) { if ( mMapCanvas && mMapCanvas->isDrawing() ) { @@ -2906,16 +2912,19 @@ void QgisApp::fileNew( bool thePromptToSaveFlag ) // load template instead of loading defaults - or should this be done *after* loading defaults? QSettings settings; - QString projectTemplate = settings.value( "/qgis/newProjectTemplateFile", "" ).toString(); - if ( settings.value( "/qgis/newProjectTemplate", QVariant( false ) ).toBool() && - ! projectTemplate.isEmpty() ) + if ( ! forceBlank ) { - QgsDebugMsg( QString( "tryingload template: %1 - %2" ).arg( settings.value( "/qgis/newProjectTemplate", QVariant( false ) ).toBool() ).arg( projectTemplate ) ); - if ( addProject( projectTemplate ) ) + QString projectTemplate = settings.value( "/qgis/newProjectTemplateFile", "" ).toString(); + if ( settings.value( "/qgis/newProjectTemplate", QVariant( false ) ).toBool() && + ! projectTemplate.isEmpty() ) { - // set null filename so we don't override the template - QgsProject::instance()->setFileName( QString() ); - return; + QgsDebugMsg( QString( "loading template: %1 - %2" ).arg( settings.value( "/qgis/newProjectTemplate", QVariant( false ) ).toBool() ).arg( projectTemplate ) ); + if ( addProject( projectTemplate ) ) + { + // set null filename so we don't override the template + QgsProject::instance()->setFileName( QString() ); + return; + } } } diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 913290d502b5..5b84e2fe6562 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -617,8 +617,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow void fileOpen(); //! Create a new project void fileNew(); - //! As above but allows forcing without prompt - void fileNew( bool thePromptToSaveFlag ); + //! Create a new blank project (no template) + void fileNewBlank(); + //! As above but allows forcing without prompt and forcing blank project + void fileNew( bool thePromptToSaveFlag, bool forceBlank = false ); //! Calculate new rasters from existing ones void showRasterCalculator(); void embedLayers(); diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index ad42be07bd84..77cd3256b70c 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -64,6 +64,7 @@ + @@ -1697,6 +1698,18 @@ Creates a scale bar that is displayed on the map canvas + + + + :/images/themes/default/mActionFileNew.png:/images/themes/default/mActionFileNew.png + + + New Blank Project + + + New Blank Project + +