Skip to content
Permalink
Browse files

Make save as initial path default to current project path instead

of last used path

This is more logical (as you're more likely to want to save
a copy of the project somewhere near the original as opposed
to wherever the last project was saved (which is effectively
random!))
  • Loading branch information
nyalldawson committed Aug 8, 2018
1 parent d90348d commit 91c6556faa57f6815a4d87c5419e2c27ad65538b
Showing with 16 additions and 5 deletions.
  1. +16 −5 src/app/qgisapp.cpp
@@ -5939,23 +5939,34 @@ bool QgisApp::fileSave()

void QgisApp::fileSaveAs()
{
// Retrieve last used project dir from persistent settings
QgsSettings settings;
QString lastUsedDir = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString();
QString defaultPath;
// First priority is to default to same path as existing file
const QString currentPath = QgsProject::instance()->absoluteFilePath();
if ( !currentPath.isEmpty() )
{
defaultPath = currentPath;
}
else
{
// Retrieve last used project dir from persistent settings
QgsSettings settings;
defaultPath = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString();
defaultPath += + '/' + QgsProject::instance()->title();
}

const QString qgsExt = tr( "QGIS files" ) + " (*.qgs *.QGS)";
const QString zipExt = tr( "QGZ files" ) + " (*.qgz)";
QString filter;
QString path = QFileDialog::getSaveFileName( this,
tr( "Save Project As" ),
lastUsedDir + '/' + QgsProject::instance()->title(),
defaultPath,
zipExt + ";;" + qgsExt, &filter );
if ( path.isEmpty() )
return;

QFileInfo fullPath( path );

settings.setValue( QStringLiteral( "UI/lastProjectDir" ), fullPath.path() );
QgsSettings().setValue( QStringLiteral( "UI/lastProjectDir" ), fullPath.path() );

if ( filter == zipExt )
{

0 comments on commit 91c6556

Please sign in to comment.
You can’t perform that action at this time.