mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-19 00:02:48 -04:00
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!))
This commit is contained in:
parent
d90348df40
commit
91c6556faa
@ -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 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user