|
77 | 77 | #include <qgscomposition.h> |
78 | 78 | #include <qgslayerstylingwidget.h> |
79 | 79 | #include "qgstaskmanager.h" |
| 80 | +#include "qgsziputils.h" |
80 | 81 |
|
81 | 82 | #include <QNetworkReply> |
82 | 83 | #include <QNetworkProxy> |
@@ -5230,7 +5231,7 @@ void QgisApp::fileOpen() |
5230 | 5231 | QString fullPath = QFileDialog::getOpenFileName( this, |
5231 | 5232 | tr( "Choose a QGIS project file to open" ), |
5232 | 5233 | lastUsedDir, |
5233 | | - tr( "QGIS files" ) + " (*.qgs *.QGS)" ); |
| 5234 | + tr( "QGIS files" ) + " (*.qgs *.qgz *.QGS)" ); |
5234 | 5235 | if ( fullPath.isNull() ) |
5235 | 5236 | { |
5236 | 5237 | return; |
@@ -5275,7 +5276,7 @@ bool QgisApp::addProject( const QString &projectFile ) |
5275 | 5276 | bool autoSetupOnFirstLayer = mLayerTreeCanvasBridge->autoSetupOnFirstLayer(); |
5276 | 5277 | mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( false ); |
5277 | 5278 |
|
5278 | | - if ( !QgsProject::instance()->read( projectFile ) ) |
| 5279 | + if ( !QgsProject::instance()->read( projectFile ) && !QgsZipUtils::isZipFile( projectFile ) ) |
5279 | 5280 | { |
5280 | 5281 | QString backupFile = projectFile + "~"; |
5281 | 5282 | QString loadBackupPrompt; |
@@ -5415,22 +5416,30 @@ bool QgisApp::fileSave() |
5415 | 5416 | QgsSettings settings; |
5416 | 5417 | QString lastUsedDir = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString(); |
5417 | 5418 |
|
| 5419 | + const QString qgsExt = tr( "QGIS files" ) + " (*.qgs)"; |
| 5420 | + const QString zipExt = tr( "QGZ files" ) + " (*.qgz)"; |
| 5421 | + QString filter; |
5418 | 5422 | QString path = QFileDialog::getSaveFileName( |
5419 | 5423 | this, |
5420 | 5424 | tr( "Choose a QGIS project file" ), |
5421 | 5425 | lastUsedDir + '/' + QgsProject::instance()->title(), |
5422 | | - tr( "QGIS files" ) + " (*.qgs *.QGS)" ); |
| 5426 | + qgsExt + ";;" + zipExt, &filter ); |
5423 | 5427 | if ( path.isEmpty() ) |
5424 | 5428 | return false; |
5425 | 5429 |
|
5426 | 5430 | fullPath.setFile( path ); |
5427 | 5431 |
|
5428 | 5432 | // make sure we have the .qgs extension in the file name |
5429 | | - if ( "qgs" != fullPath.suffix().toLower() ) |
| 5433 | + if ( filter == zipExt ) |
5430 | 5434 | { |
5431 | | - fullPath.setFile( fullPath.filePath() + ".qgs" ); |
| 5435 | + if ( fullPath.suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) != 0 ) |
| 5436 | + fullPath.setFile( fullPath.filePath() + ".qgz" ); |
| 5437 | + } |
| 5438 | + else |
| 5439 | + { |
| 5440 | + if ( fullPath.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) != 0 ) |
| 5441 | + fullPath.setFile( fullPath.filePath() + ".qgs" ); |
5432 | 5442 | } |
5433 | | - |
5434 | 5443 |
|
5435 | 5444 | QgsProject::instance()->setFileName( fullPath.filePath() ); |
5436 | 5445 | } |
@@ -5493,21 +5502,29 @@ void QgisApp::fileSaveAs() |
5493 | 5502 | QgsSettings settings; |
5494 | 5503 | QString lastUsedDir = settings.value( QStringLiteral( "UI/lastProjectDir" ), QDir::homePath() ).toString(); |
5495 | 5504 |
|
| 5505 | + const QString qgsExt = tr( "QGIS files" ) + " (*.qgs *.QGS)"; |
| 5506 | + const QString zipExt = tr( "QGZ files" ) + " (*.qgz)"; |
| 5507 | + QString filter; |
5496 | 5508 | QString path = QFileDialog::getSaveFileName( this, |
5497 | 5509 | tr( "Choose a file name to save the QGIS project file as" ), |
5498 | 5510 | lastUsedDir + '/' + QgsProject::instance()->title(), |
5499 | | - tr( "QGIS files" ) + " (*.qgs *.QGS)" ); |
| 5511 | + qgsExt + ";;" + zipExt, &filter ); |
5500 | 5512 | if ( path.isEmpty() ) |
5501 | 5513 | return; |
5502 | 5514 |
|
5503 | 5515 | QFileInfo fullPath( path ); |
5504 | 5516 |
|
5505 | 5517 | settings.setValue( QStringLiteral( "UI/lastProjectDir" ), fullPath.path() ); |
5506 | 5518 |
|
5507 | | - // make sure the .qgs extension is included in the path name. if not, add it... |
5508 | | - if ( "qgs" != fullPath.suffix().toLower() ) |
| 5519 | + if ( filter == zipExt ) |
| 5520 | + { |
| 5521 | + if ( fullPath.suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) != 0 ) |
| 5522 | + fullPath.setFile( fullPath.filePath() + ".qgz" ); |
| 5523 | + } |
| 5524 | + else // .qgs |
5509 | 5525 | { |
5510 | | - fullPath.setFile( fullPath.filePath() + ".qgs" ); |
| 5526 | + if ( fullPath.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) != 0 ) |
| 5527 | + fullPath.setFile( fullPath.filePath() + ".qgs" ); |
5511 | 5528 | } |
5512 | 5529 |
|
5513 | 5530 | QgsProject::instance()->setFileName( fullPath.filePath() ); |
|
0 commit comments