@@ -2795,6 +2795,7 @@ bool QgisApp::fileSave()
27952795 saveFileDialog->setFileMode ( QFileDialog::AnyFile );
27962796 saveFileDialog->setAcceptMode ( QFileDialog::AcceptSave );
27972797 saveFileDialog->setConfirmOverwrite ( true );
2798+ saveFileDialog->selectFile ( QgsProject::instance ()->title () );
27982799
27992800 if ( saveFileDialog->exec () == QDialog::Accepted )
28002801 {
@@ -2840,8 +2841,6 @@ bool QgisApp::fileSave()
28402841 return true ;
28412842} // QgisApp::fileSave
28422843
2843-
2844-
28452844void QgisApp::fileSaveAs ()
28462845{
28472846 if ( mMapCanvas && mMapCanvas ->isDrawing () )
@@ -2852,29 +2851,44 @@ void QgisApp::fileSaveAs()
28522851 // Retrieve last used project dir from persistent settings
28532852 QSettings settings;
28542853 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
28572870 {
28582871 return ;
28592872 }
2860- QFileInfo myFI ( saveFilePath );
2861- QString myPath = myFI .path ();
2873+
2874+ QString myPath = fullPath .path ();
28622875 settings.setValue ( " /UI/lastProjectDir" , myPath );
28632876
28642877 // 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 () )
28662879 {
2867- saveFilePath = myFI.filePath () + " .qgs" ;
2880+ myPath = fullPath.filePath () + " .qgs" ;
2881+ fullPath.setFile ( myPath );
28682882 }
28692883
2870- QgsProject::instance ()->setFileName ( saveFilePath );
2884+ QgsProject::instance ()->setFileName ( fullPath. filePath () );
28712885
28722886 if ( QgsProject::instance ()->write () )
28732887 {
28742888 setTitleBarText_ ( *this ); // update title bar
28752889 statusBar ()->showMessage ( tr ( " Saved project to: %1" ).arg ( QgsProject::instance ()->fileName () ) );
28762890 // add this to the list of recently used project files
2877- saveRecentProjectPath ( saveFilePath , settings );
2891+ saveRecentProjectPath ( fullPath. filePath () , settings );
28782892 }
28792893 else
28802894 {
0 commit comments