Skip to content
Permalink
Browse files
Merge pull request #46089 from agiudiceandrea/fix-46083-save-as-defau…
…lt-format

Fix the "Save As..." project saving dialog in order to respect the default project file format setting
  • Loading branch information
rouault committed Nov 17, 2021
2 parents dddc9c5 + 4a61b7c commit 6644404b4928b7cedd274a44a1dc2244b51a8719
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/app/qgisapp.cpp
@@ -7285,6 +7285,7 @@ bool QgisApp::fileSave()
void QgisApp::fileSaveAs()
{
QString defaultPath;
QgsSettings settings;
// First priority is to default to same path as existing file
const QString currentPath = QgsProject::instance()->absoluteFilePath();
if ( !currentPath.isEmpty() )
@@ -7294,18 +7295,28 @@ void QgisApp::fileSaveAs()
else
{
// Retrieve last used project dir from persistent settings
QgsSettings settings;
defaultPath = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString();
defaultPath += QString( '/' + QgsProject::instance()->title() );
}

const QString qgsExt = tr( "QGIS files" ) + " (*.qgs *.QGS)";
const QString zipExt = tr( "QGZ files" ) + " (*.qgz)";

QString exts;
QgsProject::FileFormat defaultProjectFileFormat = settings.enumValue( QStringLiteral( "/qgis/defaultProjectFileFormat" ), QgsProject::FileFormat::Qgz );
if ( defaultProjectFileFormat == QgsProject::FileFormat::Qgs )
{
exts = qgsExt + QStringLiteral( ";;" ) + zipExt;
}
else
{
exts = zipExt + QStringLiteral( ";;" ) + qgsExt;
}
QString filter;
QString path = QFileDialog::getSaveFileName( this,
tr( "Save Project As" ),
defaultPath,
zipExt + ";;" + qgsExt, &filter );
exts, &filter );
if ( path.isEmpty() )
return;

0 comments on commit 6644404

Please sign in to comment.