Skip to content
Permalink
Browse files

add New Blank Project action that creates a blank project, regardless…

… of template settings
  • Loading branch information
etiennesky committed Jul 17, 2012
1 parent f3e0cf5 commit e4b9dfc1053adf4b7e8fc8014cbea34ecdf87c59
Showing with 36 additions and 12 deletions.
  1. +19 −10 src/app/qgisapp.cpp
  2. +4 −2 src/app/qgisapp.h
  3. +13 −0 src/ui/qgisapp.ui
@@ -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;
}
}
}

@@ -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();
@@ -64,6 +64,7 @@
</widget>
<addaction name="mActionNewProject"/>
<addaction name="mActionOpenProject"/>
<addaction name="mActionNewBlankProject"/>
<addaction name="separator"/>
<addaction name="mRecentProjectsMenu"/>
<addaction name="mActionSaveProject"/>
@@ -1697,6 +1698,18 @@
<string>Creates a scale bar that is displayed on the map canvas</string>
</property>
</action>
<action name="mActionNewBlankProject">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileNew.png</normaloff>:/images/themes/default/mActionFileNew.png</iconset>
</property>
<property name="text">
<string>New Blank Project</string>
</property>
<property name="toolTip">
<string>New Blank Project</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>

0 comments on commit e4b9dfc

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