@@ -585,6 +585,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
585
585
int myBlue = settings.value ( " /qgis/default_canvas_color_blue" , 255 ).toInt ();
586
586
mMapCanvas ->setCanvasColor ( QColor ( myRed, myGreen, myBlue ) );
587
587
588
+ // what type of project to auto-open
589
+ mProjOpen = settings.value ( " /qgis/projOpenAtLaunch" , 0 ).toInt ();
590
+
588
591
mWelcomePage = new QgsWelcomePage;
589
592
590
593
mCentralContainer = new QStackedWidget;
@@ -595,8 +598,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
595
598
596
599
connect ( mMapCanvas , SIGNAL ( layersChanged () ), this , SLOT ( showMapCanvas () ) );
597
600
598
- mCentralContainer ->setCurrentIndex ( 1 );
599
-
601
+ mCentralContainer ->setCurrentIndex ( mProjOpen ? 0 : 1 );
600
602
601
603
// a bar to warn the user with non-blocking messages
602
604
mInfoBar = new QgsMessageBar ( centralWidget );
@@ -1155,7 +1157,7 @@ void QgisApp::readSettings()
1155
1157
QStringList oldRecentProjects = settings.value ( " /UI/recentProjectsList" ).toStringList ();
1156
1158
settings.remove ( " /UI/recentProjectsList" );
1157
1159
1158
- Q_FOREACH ( const QString& project, oldRecentProjects )
1160
+ Q_FOREACH ( const QString& project, oldRecentProjects )
1159
1161
{
1160
1162
QgsWelcomePageItemsModel::RecentProjectData data;
1161
1163
data.path = project;
@@ -1167,7 +1169,7 @@ void QgisApp::readSettings()
1167
1169
settings.beginGroup ( " /UI/recentProjects" );
1168
1170
QStringList projectKeys = settings.childGroups ();
1169
1171
1170
- Q_FOREACH ( const QString& key, projectKeys )
1172
+ Q_FOREACH ( const QString& key, projectKeys )
1171
1173
{
1172
1174
QgsWelcomePageItemsModel::RecentProjectData data;
1173
1175
settings.beginGroup ( key );
@@ -2745,7 +2747,7 @@ void QgisApp::updateRecentProjectPaths()
2745
2747
{
2746
2748
mRecentProjectsMenu ->clear ();
2747
2749
2748
- Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2750
+ Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2749
2751
{
2750
2752
QAction* action = mRecentProjectsMenu ->addAction ( QString ( " %1 (%2)" ).arg ( recentProject.title ).arg ( recentProject.path ) );
2751
2753
action->setEnabled ( QFile::exists (( recentProject.path ) ) );
@@ -2814,7 +2816,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
2814
2816
int idx = 0 ;
2815
2817
2816
2818
// Persist the list
2817
- Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2819
+ Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2818
2820
{
2819
2821
++idx;
2820
2822
settings.beginGroup ( QString ( " /UI/recentProjects/%1" ).arg ( idx ) );
@@ -3931,23 +3933,19 @@ void QgisApp::fileOpenAfterLaunch()
3931
3933
QSettings settings;
3932
3934
QString autoOpenMsgTitle = tr ( " Auto-open Project" );
3933
3935
3934
- // what type of project to auto- open
3935
- int projOpen = settings. value ( " /qgis/projOpenAtLaunch " , 0 ). toInt () ;
3936
+ // get path of project file to open, or was attempted
3937
+ QString projPath ;
3936
3938
3937
- if ( projOpen == 0 ) // welcome page
3939
+ if ( mProjOpen == 0 ) // welcome page
3938
3940
{
3939
3941
connect ( this , SIGNAL ( newProject () ), this , SLOT ( showMapCanvas () ) );
3940
3942
return ;
3941
3943
}
3942
-
3943
- // get path of project file to open, or was attempted
3944
- QString projPath;
3945
-
3946
- if ( projOpen == 1 && mRecentProjects .size () > 0 ) // most recent project
3944
+ if ( mProjOpen == 1 && mRecentProjects .size () > 0 ) // most recent project
3947
3945
{
3948
3946
projPath = mRecentProjects .at ( 0 ).path ;
3949
3947
}
3950
- if ( projOpen == 2 ) // specific project
3948
+ if ( mProjOpen == 2 ) // specific project
3951
3949
{
3952
3950
projPath = settings.value ( " /qgis/projOpenAtLaunchPath" ).toString ();
3953
3951
}
@@ -3974,7 +3972,7 @@ void QgisApp::fileOpenAfterLaunch()
3974
3972
return ;
3975
3973
}
3976
3974
3977
- if ( projOpen == 0 ) // new project (default)
3975
+ if ( mProjOpen == 3 ) // new project
3978
3976
{
3979
3977
// open default template, if defined
3980
3978
if ( settings.value ( " /qgis/newProjectDefault" , QVariant ( false ) ).toBool () )
0 commit comments