Skip to content
Permalink
Browse files
Make "Save As" for project respect the default format
as "Save" do. See #33872
  • Loading branch information
agiudiceandrea committed Nov 17, 2021
1 parent 5cd7625 commit 4a61b7c5e50ec1c12983214ab3a63ab5738165f5
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 4a61b7c

Please sign in to comment.