Skip to content

Commit

Permalink
[welcomepage] again fix welcome page vs project loading:
Browse files Browse the repository at this point in the history
reason: the welcome page persists anyway even if New option is selected.
  • Loading branch information
slarosa committed Aug 31, 2015
1 parent dff2ed5 commit f3ebe14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/app/qgisapp.cpp
Expand Up @@ -585,6 +585,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
int myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );

// what type of project to auto-open
mProjOpen = settings.value( "/qgis/projOpenAtLaunch", 0 ).toInt();

mWelcomePage = new QgsWelcomePage;

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

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

mCentralContainer->setCurrentIndex( 1 );

mCentralContainer->setCurrentIndex( mProjOpen ? 0 : 1 );

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

Q_FOREACH ( const QString& project, oldRecentProjects )
Q_FOREACH( const QString& project, oldRecentProjects )
{
QgsWelcomePageItemsModel::RecentProjectData data;
data.path = project;
Expand All @@ -1167,7 +1169,7 @@ void QgisApp::readSettings()
settings.beginGroup( "/UI/recentProjects" );
QStringList projectKeys = settings.childGroups();

Q_FOREACH ( const QString& key, projectKeys )
Q_FOREACH( const QString& key, projectKeys )
{
QgsWelcomePageItemsModel::RecentProjectData data;
settings.beginGroup( key );
Expand Down Expand Up @@ -2745,7 +2747,7 @@ void QgisApp::updateRecentProjectPaths()
{
mRecentProjectsMenu->clear();

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

// Persist the list
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
Q_FOREACH( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
{
++idx;
settings.beginGroup( QString( "/UI/recentProjects/%1" ).arg( idx ) );
Expand Down Expand Up @@ -3931,23 +3933,19 @@ void QgisApp::fileOpenAfterLaunch()
QSettings settings;
QString autoOpenMsgTitle = tr( "Auto-open Project" );

// what type of project to auto-open
int projOpen = settings.value( "/qgis/projOpenAtLaunch", 0 ).toInt();
// get path of project file to open, or was attempted
QString projPath;

if ( projOpen == 0 ) // welcome page
if ( mProjOpen == 0 ) // welcome page
{
connect( this, SIGNAL( newProject() ), this, SLOT( showMapCanvas() ) );
return;
}

// get path of project file to open, or was attempted
QString projPath;

if ( projOpen == 1 && mRecentProjects.size() > 0 ) // most recent project
if ( mProjOpen == 1 && mRecentProjects.size() > 0 ) // most recent project
{
projPath = mRecentProjects.at( 0 ).path;
}
if ( projOpen == 2 ) // specific project
if ( mProjOpen == 2 ) // specific project
{
projPath = settings.value( "/qgis/projOpenAtLaunchPath" ).toString();
}
Expand All @@ -3974,7 +3972,7 @@ void QgisApp::fileOpenAfterLaunch()
return;
}

if ( projOpen == 0 ) // new project (default)
if ( mProjOpen == 3 ) // new project
{
// open default template, if defined
if ( settings.value( "/qgis/newProjectDefault", QVariant( false ) ).toBool() )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -1693,6 +1693,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsWelcomePage* mWelcomePage;

QStackedWidget* mCentralContainer;

int mProjOpen;
#ifdef HAVE_TOUCH
bool gestureEvent( QGestureEvent *event );
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
Expand Down

0 comments on commit f3ebe14

Please sign in to comment.