Skip to content

Commit 16d7a06

Browse files
committedAug 19, 2015
reenable passing projects and layers on open and 'open project on launch', but
replace make 'New' (old default) a new option and make 'Welcome Page' the new default
1 parent f955cf2 commit 16d7a06

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
521521
, mpGpsWidget( 0 )
522522
, mSnappingUtils( 0 )
523523
, mProjectLastModified()
524+
, mWelcomePage( 0 )
525+
, mCentralContainer( 0 )
524526
{
525527
if ( smInstance )
526528
{
@@ -579,16 +581,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
579581
int myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
580582
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
581583

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 );
592585

593586
// a bar to warn the user with non-blocking messages
594587
mInfoBar = new QgsMessageBar( centralWidget );
@@ -874,9 +867,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
874867

875868
fileNewBlank(); // prepare empty project, also skips any default templates from loading
876869

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-
880870
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
881871
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
882872
QgsApplication::setFileOpenEventReceiver( this );
@@ -965,6 +955,8 @@ QgisApp::QgisApp()
965955
, mActionFilterLegend( 0 )
966956
, mSnappingUtils( 0 )
967957
, mProjectLastModified()
958+
, mWelcomePage( 0 )
959+
, mCentralContainer( 0 )
968960
{
969961
smInstance = this;
970962
setupUi( this );
@@ -2726,7 +2718,8 @@ void QgisApp::updateRecentProjectPaths()
27262718
action->setData( recentProject.path );
27272719
}
27282720

2729-
mWelcomePage->setRecentProjects( mRecentProjects );
2721+
if ( mWelcomePage )
2722+
mWelcomePage->setRecentProjects( mRecentProjects );
27302723
} // QgisApp::updateRecentProjectPaths
27312724

27322725
// add this file to the recently opened/saved projects list
@@ -3909,6 +3902,23 @@ void QgisApp::fileOpenAfterLaunch()
39093902

39103903
// get path of project file to open, or was attempted
39113904
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+
}
39123922
if ( projOpen == 1 && mRecentProjects.size() > 0 ) // most recent project
39133923
{
39143924
projPath = mRecentProjects.at( 0 ).path;
@@ -4241,15 +4251,8 @@ bool QgisApp::fileSave()
42414251
// that the project file name is reset to null in fileNew()
42424252
QFileInfo fullPath;
42434253

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-
42494254
if ( QgsProject::instance()->fileName().isNull() )
42504255
{
4251-
isNewProject = true;
4252-
42534256
// Retrieve last used project dir from persistent settings
42544257
QSettings settings;
42554258
QString lastUsedDir = settings.value( "/UI/lastProjectDir", "." ).toString();
@@ -9005,7 +9008,8 @@ void QgisApp::mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool )
90059008
void QgisApp::showMapCanvas()
90069009
{
90079010
// Map layers changed -> switch to map canvas
9008-
mCentralContainer->setCurrentIndex( 0 );
9011+
if ( mCentralContainer )
9012+
mCentralContainer->setCurrentIndex( 0 );
90099013
}
90109014

90119015
void QgisApp::extentsViewToggled( bool theFlag )

‎src/ui/qgsoptionsbase.ui

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
</property>
631631
<item>
632632
<property name="text">
633-
<string>New</string>
633+
<string>Welcome Page</string>
634634
</property>
635635
</item>
636636
<item>
@@ -643,6 +643,11 @@
643643
<string>Specific</string>
644644
</property>
645645
</item>
646+
<item>
647+
<property name="text">
648+
<string>New</string>
649+
</property>
650+
</item>
646651
</widget>
647652
</item>
648653
<item row="1" column="5">

0 commit comments

Comments
 (0)
Please sign in to comment.