@@ -521,6 +521,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
521
521
, mpGpsWidget( 0 )
522
522
, mSnappingUtils ( 0 )
523
523
, mProjectLastModified ()
524
+ , mWelcomePage ( 0 )
525
+ , mCentralContainer ( 0 )
524
526
{
525
527
if ( smInstance )
526
528
{
@@ -579,16 +581,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
579
581
int myBlue = settings.value ( " /qgis/default_canvas_color_blue" , 255 ).toInt ();
580
582
mMapCanvas ->setCanvasColor ( QColor ( myRed, myGreen, myBlue ) );
581
583
582
- mWelcomePage = new QgsWelcomePage;
583
-
584
- mCentralContainer = new QStackedWidget;
585
- mCentralContainer ->insertWidget ( 0 , mMapCanvas );
586
- mCentralContainer ->insertWidget ( 1 , mWelcomePage );
587
-
588
- connect ( mMapCanvas , SIGNAL ( layersChanged () ), this , SLOT ( showMapCanvas () ) );
589
- connect ( this , SIGNAL ( newProject () ), this , SLOT ( showMapCanvas () ) );
590
-
591
- centralLayout->addWidget ( mCentralContainer , 0 , 0 , 2 , 1 );
584
+ centralLayout->addWidget ( mMapCanvas , 0 , 0 , 2 , 1 );
592
585
593
586
// a bar to warn the user with non-blocking messages
594
587
mInfoBar = new QgsMessageBar ( centralWidget );
@@ -874,9 +867,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
874
867
875
868
fileNewBlank (); // prepare empty project, also skips any default templates from loading
876
869
877
- // Show the welcome page. Needs to be done after creating a new project because it gets hidden on new project
878
- mCentralContainer ->setCurrentIndex ( 1 );
879
-
880
870
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
881
871
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
882
872
QgsApplication::setFileOpenEventReceiver ( this );
@@ -965,6 +955,8 @@ QgisApp::QgisApp()
965
955
, mActionFilterLegend ( 0 )
966
956
, mSnappingUtils ( 0 )
967
957
, mProjectLastModified ()
958
+ , mWelcomePage ( 0 )
959
+ , mCentralContainer ( 0 )
968
960
{
969
961
smInstance = this ;
970
962
setupUi ( this );
@@ -2726,7 +2718,8 @@ void QgisApp::updateRecentProjectPaths()
2726
2718
action->setData ( recentProject.path );
2727
2719
}
2728
2720
2729
- mWelcomePage ->setRecentProjects ( mRecentProjects );
2721
+ if ( mWelcomePage )
2722
+ mWelcomePage ->setRecentProjects ( mRecentProjects );
2730
2723
} // QgisApp::updateRecentProjectPaths
2731
2724
2732
2725
// add this file to the recently opened/saved projects list
@@ -3909,6 +3902,23 @@ void QgisApp::fileOpenAfterLaunch()
3909
3902
3910
3903
// get path of project file to open, or was attempted
3911
3904
QString projPath = QString ();
3905
+ if ( projOpen == 0 ) // welcome page
3906
+ {
3907
+ mWelcomePage = new QgsWelcomePage;
3908
+
3909
+ mCentralContainer = new QStackedWidget;
3910
+ mCentralContainer ->insertWidget ( 0 , mMapCanvas );
3911
+ mCentralContainer ->insertWidget ( 1 , mWelcomePage );
3912
+
3913
+ connect ( mMapCanvas , SIGNAL ( layersChanged () ), this , SLOT ( showMapCanvas () ) );
3914
+ connect ( this , SIGNAL ( newProject () ), this , SLOT ( showMapCanvas () ) );
3915
+
3916
+ qobject_cast<QGridLayout *>( centralWidget ()->layout () )->addWidget ( mCentralContainer , 0 , 0 , 2 , 1 );
3917
+
3918
+ mCentralContainer ->setCurrentIndex ( 1 );
3919
+
3920
+ return ;
3921
+ }
3912
3922
if ( projOpen == 1 && mRecentProjects .size () > 0 ) // most recent project
3913
3923
{
3914
3924
projPath = mRecentProjects .at ( 0 ).path ;
@@ -4241,15 +4251,8 @@ bool QgisApp::fileSave()
4241
4251
// that the project file name is reset to null in fileNew()
4242
4252
QFileInfo fullPath;
4243
4253
4244
- // we need to remember if this is a new project so that we know to later
4245
- // update the "last project dir" settings; we know it's a new project if
4246
- // the current project file name is empty
4247
- bool isNewProject = false ;
4248
-
4249
4254
if ( QgsProject::instance ()->fileName ().isNull () )
4250
4255
{
4251
- isNewProject = true ;
4252
-
4253
4256
// Retrieve last used project dir from persistent settings
4254
4257
QSettings settings;
4255
4258
QString lastUsedDir = settings.value ( " /UI/lastProjectDir" , " ." ).toString ();
@@ -9005,7 +9008,8 @@ void QgisApp::mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool )
9005
9008
void QgisApp::showMapCanvas ()
9006
9009
{
9007
9010
// Map layers changed -> switch to map canvas
9008
- mCentralContainer ->setCurrentIndex ( 0 );
9011
+ if ( mCentralContainer )
9012
+ mCentralContainer ->setCurrentIndex ( 0 );
9009
9013
}
9010
9014
9011
9015
void QgisApp::extentsViewToggled ( bool theFlag )
0 commit comments