Skip to content

Commit

Permalink
add New Blank Project action that creates a blank project, regardless…
Browse files Browse the repository at this point in the history
… of template settings
  • Loading branch information
etiennesky committed Jul 17, 2012
1 parent f3e0cf5 commit e4b9dfc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/app/qgisapp.cpp
Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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() )
{
Expand All @@ -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;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions src/ui/qgisapp.ui
Expand Up @@ -64,6 +64,7 @@
</widget>
<addaction name="mActionNewProject"/>
<addaction name="mActionOpenProject"/>
<addaction name="mActionNewBlankProject"/>
<addaction name="separator"/>
<addaction name="mRecentProjectsMenu"/>
<addaction name="mActionSaveProject"/>
Expand Down Expand Up @@ -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"/>
Expand Down

0 comments on commit e4b9dfc

Please sign in to comment.