Skip to content

Commit

Permalink
reenable passing projects and layers on open and 'open project on lau…
Browse files Browse the repository at this point in the history
…nch', but

replace make 'New' (old default) a new option and make 'Welcome Page' the new
default
  • Loading branch information
jef-n committed Aug 19, 2015
1 parent f955cf2 commit 16d7a06
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
48 changes: 26 additions & 22 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
, mpGpsWidget( 0 )
, mSnappingUtils( 0 )
, mProjectLastModified()
, mWelcomePage( 0 )
, mCentralContainer( 0 )
{
if ( smInstance )
{
Expand Down Expand Up @@ -579,16 +581,7 @@ 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 ) );

mWelcomePage = new QgsWelcomePage;

mCentralContainer = new QStackedWidget;
mCentralContainer->insertWidget( 0, mMapCanvas );
mCentralContainer->insertWidget( 1, mWelcomePage );

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

centralLayout->addWidget( mCentralContainer, 0, 0, 2, 1 );
centralLayout->addWidget( mMapCanvas, 0, 0, 2, 1 );

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

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

// Show the welcome page. Needs to be done after creating a new project because it gets hidden on new project
mCentralContainer->setCurrentIndex( 1 );

// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
QgsApplication::setFileOpenEventReceiver( this );
Expand Down Expand Up @@ -965,6 +955,8 @@ QgisApp::QgisApp()
, mActionFilterLegend( 0 )
, mSnappingUtils( 0 )
, mProjectLastModified()
, mWelcomePage( 0 )
, mCentralContainer( 0 )
{
smInstance = this;
setupUi( this );
Expand Down Expand Up @@ -2726,7 +2718,8 @@ void QgisApp::updateRecentProjectPaths()
action->setData( recentProject.path );
}

mWelcomePage->setRecentProjects( mRecentProjects );
if ( mWelcomePage )
mWelcomePage->setRecentProjects( mRecentProjects );
} // QgisApp::updateRecentProjectPaths

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

// get path of project file to open, or was attempted
QString projPath = QString();
if ( projOpen == 0 ) // welcome page
{
mWelcomePage = new QgsWelcomePage;

mCentralContainer = new QStackedWidget;
mCentralContainer->insertWidget( 0, mMapCanvas );
mCentralContainer->insertWidget( 1, mWelcomePage );

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

qobject_cast<QGridLayout *>( centralWidget()->layout() )->addWidget( mCentralContainer, 0, 0, 2, 1 );

mCentralContainer->setCurrentIndex( 1 );

return;
}
if ( projOpen == 1 && mRecentProjects.size() > 0 ) // most recent project
{
projPath = mRecentProjects.at( 0 ).path;
Expand Down Expand Up @@ -4241,15 +4251,8 @@ bool QgisApp::fileSave()
// that the project file name is reset to null in fileNew()
QFileInfo fullPath;

// we need to remember if this is a new project so that we know to later
// update the "last project dir" settings; we know it's a new project if
// the current project file name is empty
bool isNewProject = false;

if ( QgsProject::instance()->fileName().isNull() )
{
isNewProject = true;

// Retrieve last used project dir from persistent settings
QSettings settings;
QString lastUsedDir = settings.value( "/UI/lastProjectDir", "." ).toString();
Expand Down Expand Up @@ -9005,7 +9008,8 @@ void QgisApp::mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool )
void QgisApp::showMapCanvas()
{
// Map layers changed -> switch to map canvas
mCentralContainer->setCurrentIndex( 0 );
if ( mCentralContainer )
mCentralContainer->setCurrentIndex( 0 );
}

void QgisApp::extentsViewToggled( bool theFlag )
Expand Down
7 changes: 6 additions & 1 deletion src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
</property>
<item>
<property name="text">
<string>New</string>
<string>Welcome Page</string>
</property>
</item>
<item>
Expand All @@ -643,6 +643,11 @@
<string>Specific</string>
</property>
</item>
<item>
<property name="text">
<string>New</string>
</property>
</item>
</widget>
</item>
<item row="1" column="5">
Expand Down

0 comments on commit 16d7a06

Please sign in to comment.