mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix bug where file dialogs lose the last directory node each time they are used.
Move settings stuff inside accepted check of dialog so last dir etc arnt saved if user presses cancel git-svn-id: http://svn.osgeo.org/qgis/trunk@4143 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
bde5da2dd6
commit
7596d4d2b4
@ -1048,17 +1048,16 @@ static void openFilesRememberingFilter_(QString const &filterName,
|
||||
QString::null,
|
||||
&haveLastUsedFilter);
|
||||
|
||||
QString lastUsedDir = settings.readEntry("/qgis/UI/" + filterName + "Dir",
|
||||
".");
|
||||
QString lastUsedDir = settings.readEntry("/qgis/UI/" + filterName + "Dir",".");
|
||||
|
||||
QString lastUsedEncoding = settings.readEntry("/qgis/UI/encoding");
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
|
||||
std::cerr << "Opening vector file dialog with filters: " << filters.local8Bit() << std::endl;
|
||||
std::cerr << "Opening file dialog with filters: " << filters.local8Bit() << std::endl;
|
||||
#endif
|
||||
|
||||
QgsEncodingFileDialog* openFileDialog = new QgsEncodingFileDialog(lastUsedDir, filters, 0, QFileDialog::tr("open files dialog"), lastUsedEncoding);
|
||||
QgsEncodingFileDialog* openFileDialog =
|
||||
new QgsEncodingFileDialog(lastUsedDir, filters, 0, QFileDialog::tr("open files dialog"), lastUsedEncoding);
|
||||
|
||||
// allow for selection of more than one file
|
||||
openFileDialog->setMode(QFileDialog::ExistingFiles);
|
||||
@ -1071,20 +1070,25 @@ static void openFilesRememberingFilter_(QString const &filterName,
|
||||
|
||||
if (openFileDialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
selectedFiles = openFileDialog->selectedFiles();
|
||||
enc = openFileDialog->encoding();
|
||||
selectedFiles = openFileDialog->selectedFiles();
|
||||
enc = openFileDialog->encoding();
|
||||
// Fix by Tim - getting the dirPath from the dialog
|
||||
// directly truncates the last node in the dir path.
|
||||
// This is a workaround for that
|
||||
QString myFirstFileName = selectedFiles.first();
|
||||
QFileInfo myFI(myFirstFileName);
|
||||
QString myPath = myFI.dirPath();
|
||||
#ifdef QGISDEBUG
|
||||
qDebug("Writing last used dir: " + myPath);
|
||||
#endif
|
||||
|
||||
settings.writeEntry("/qgis/UI/" + filterName, openFileDialog->selectedFilter());
|
||||
settings.writeEntry("/qgis/UI/" + filterName + "Dir", myPath);
|
||||
settings.writeEntry("/qgis/UI/encoding", openFileDialog->encoding());
|
||||
}
|
||||
|
||||
settings.writeEntry("/qgis/UI/" + filterName, openFileDialog->selectedFilter());
|
||||
|
||||
|
||||
settings.writeEntry("/qgis/UI/" + filterName + "Dir", openFileDialog->dirPath());
|
||||
settings.writeEntry("/qgis/UI/encoding", openFileDialog->encoding());
|
||||
|
||||
delete openFileDialog;
|
||||
} // openFilesRememberingFilter_
|
||||
|
||||
|
||||
} // openFilesRememberingFilter_
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user