@@ -2795,6 +2795,7 @@ bool QgisApp::fileSave()
2795
2795
saveFileDialog->setFileMode ( QFileDialog::AnyFile );
2796
2796
saveFileDialog->setAcceptMode ( QFileDialog::AcceptSave );
2797
2797
saveFileDialog->setConfirmOverwrite ( true );
2798
+ saveFileDialog->selectFile ( QgsProject::instance ()->title () );
2798
2799
2799
2800
if ( saveFileDialog->exec () == QDialog::Accepted )
2800
2801
{
@@ -2840,8 +2841,6 @@ bool QgisApp::fileSave()
2840
2841
return true ;
2841
2842
} // QgisApp::fileSave
2842
2843
2843
-
2844
-
2845
2844
void QgisApp::fileSaveAs ()
2846
2845
{
2847
2846
if ( mMapCanvas && mMapCanvas ->isDrawing () )
@@ -2852,29 +2851,44 @@ void QgisApp::fileSaveAs()
2852
2851
// Retrieve last used project dir from persistent settings
2853
2852
QSettings settings;
2854
2853
QString lastUsedDir = settings.value ( " /UI/lastProjectDir" , " ." ).toString ();
2855
- QString saveFilePath = QFileDialog::getSaveFileName ( this , tr ( " Choose a file name to save the QGIS project file as" ), lastUsedDir, tr ( " QGis files (*.qgs)" ) );
2856
- if ( saveFilePath.isNull () ) // canceled
2854
+
2855
+ std::auto_ptr<QFileDialog> saveFileDialog ( new QFileDialog ( this ,
2856
+ tr ( " Choose a file name to save the QGIS project file as" ),
2857
+ lastUsedDir, tr ( " QGis files (*.qgs)" ) ) );
2858
+ saveFileDialog->setFileMode ( QFileDialog::AnyFile );
2859
+ saveFileDialog->setAcceptMode ( QFileDialog::AcceptSave );
2860
+ saveFileDialog->setConfirmOverwrite ( true );
2861
+ saveFileDialog->selectFile ( QgsProject::instance ()->title () );
2862
+
2863
+ QFileInfo fullPath;
2864
+ if ( saveFileDialog->exec () == QDialog::Accepted )
2865
+ {
2866
+ // saveFilePath = saveFileDialog->selectedFiles().first();
2867
+ fullPath.setFile ( saveFileDialog->selectedFiles ().first () );
2868
+ }
2869
+ else
2857
2870
{
2858
2871
return ;
2859
2872
}
2860
- QFileInfo myFI ( saveFilePath );
2861
- QString myPath = myFI .path ();
2873
+
2874
+ QString myPath = fullPath .path ();
2862
2875
settings.setValue ( " /UI/lastProjectDir" , myPath );
2863
2876
2864
2877
// make sure the .qgs extension is included in the path name. if not, add it...
2865
- if ( " qgs" != myFI .suffix () )
2878
+ if ( " qgs" != fullPath .suffix () )
2866
2879
{
2867
- saveFilePath = myFI.filePath () + " .qgs" ;
2880
+ myPath = fullPath.filePath () + " .qgs" ;
2881
+ fullPath.setFile ( myPath );
2868
2882
}
2869
2883
2870
- QgsProject::instance ()->setFileName ( saveFilePath );
2884
+ QgsProject::instance ()->setFileName ( fullPath. filePath () );
2871
2885
2872
2886
if ( QgsProject::instance ()->write () )
2873
2887
{
2874
2888
setTitleBarText_ ( *this ); // update title bar
2875
2889
statusBar ()->showMessage ( tr ( " Saved project to: %1" ).arg ( QgsProject::instance ()->fileName () ) );
2876
2890
// add this to the list of recently used project files
2877
- saveRecentProjectPath ( saveFilePath , settings );
2891
+ saveRecentProjectPath ( fullPath. filePath () , settings );
2878
2892
}
2879
2893
else
2880
2894
{
0 commit comments