Skip to content

Commit f3ebe14

Browse files
committed
[welcomepage] again fix welcome page vs project loading:
reason: the welcome page persists anyway even if New option is selected.
1 parent dff2ed5 commit f3ebe14

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/app/qgisapp.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
585585
int myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
586586
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
587587

588+
// what type of project to auto-open
589+
mProjOpen = settings.value( "/qgis/projOpenAtLaunch", 0 ).toInt();
590+
588591
mWelcomePage = new QgsWelcomePage;
589592

590593
mCentralContainer = new QStackedWidget;
@@ -595,8 +598,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
595598

596599
connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( showMapCanvas() ) );
597600

598-
mCentralContainer->setCurrentIndex( 1 );
599-
601+
mCentralContainer->setCurrentIndex( mProjOpen ? 0 : 1 );
600602

601603
// a bar to warn the user with non-blocking messages
602604
mInfoBar = new QgsMessageBar( centralWidget );
@@ -1155,7 +1157,7 @@ void QgisApp::readSettings()
11551157
QStringList oldRecentProjects = settings.value( "/UI/recentProjectsList" ).toStringList();
11561158
settings.remove( "/UI/recentProjectsList" );
11571159

1158-
Q_FOREACH ( const QString& project, oldRecentProjects )
1160+
Q_FOREACH( const QString& project, oldRecentProjects )
11591161
{
11601162
QgsWelcomePageItemsModel::RecentProjectData data;
11611163
data.path = project;
@@ -1167,7 +1169,7 @@ void QgisApp::readSettings()
11671169
settings.beginGroup( "/UI/recentProjects" );
11681170
QStringList projectKeys = settings.childGroups();
11691171

1170-
Q_FOREACH ( const QString& key, projectKeys )
1172+
Q_FOREACH( const QString& key, projectKeys )
11711173
{
11721174
QgsWelcomePageItemsModel::RecentProjectData data;
11731175
settings.beginGroup( key );
@@ -2745,7 +2747,7 @@ void QgisApp::updateRecentProjectPaths()
27452747
{
27462748
mRecentProjectsMenu->clear();
27472749

2748-
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2750+
Q_FOREACH( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
27492751
{
27502752
QAction* action = mRecentProjectsMenu->addAction( QString( "%1 (%2)" ).arg( recentProject.title ).arg( recentProject.path ) );
27512753
action->setEnabled( QFile::exists(( recentProject.path ) ) );
@@ -2814,7 +2816,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
28142816
int idx = 0;
28152817

28162818
// Persist the list
2817-
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2819+
Q_FOREACH( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
28182820
{
28192821
++idx;
28202822
settings.beginGroup( QString( "/UI/recentProjects/%1" ).arg( idx ) );
@@ -3931,23 +3933,19 @@ void QgisApp::fileOpenAfterLaunch()
39313933
QSettings settings;
39323934
QString autoOpenMsgTitle = tr( "Auto-open Project" );
39333935

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;
39363938

3937-
if ( projOpen == 0 ) // welcome page
3939+
if ( mProjOpen == 0 ) // welcome page
39383940
{
39393941
connect( this, SIGNAL( newProject() ), this, SLOT( showMapCanvas() ) );
39403942
return;
39413943
}
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
39473945
{
39483946
projPath = mRecentProjects.at( 0 ).path;
39493947
}
3950-
if ( projOpen == 2 ) // specific project
3948+
if ( mProjOpen == 2 ) // specific project
39513949
{
39523950
projPath = settings.value( "/qgis/projOpenAtLaunchPath" ).toString();
39533951
}
@@ -3974,7 +3972,7 @@ void QgisApp::fileOpenAfterLaunch()
39743972
return;
39753973
}
39763974

3977-
if ( projOpen == 0 ) // new project (default)
3975+
if ( mProjOpen == 3 ) // new project
39783976
{
39793977
// open default template, if defined
39803978
if ( settings.value( "/qgis/newProjectDefault", QVariant( false ) ).toBool() )

src/app/qgisapp.h

+2
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
16931693
QgsWelcomePage* mWelcomePage;
16941694

16951695
QStackedWidget* mCentralContainer;
1696+
1697+
int mProjOpen;
16961698
#ifdef HAVE_TOUCH
16971699
bool gestureEvent( QGestureEvent *event );
16981700
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );

0 commit comments

Comments
 (0)