issue #0001588: File browser dialogs initial starting directory ignores current working directory
This commit is contained in:
@@ -158,7 +158,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
|
||||
urls << QUrl::fromLocalFile(getWorkingDirectory());
|
||||
urls << QUrl::fromLocalFile(QDir::currentPath());
|
||||
urls << QUrl::fromLocalFile(restoreLocation());
|
||||
|
||||
QString file;
|
||||
FileDialog dlg(parent);
|
||||
@@ -238,7 +238,7 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
|
||||
urls << QUrl::fromLocalFile(getWorkingDirectory());
|
||||
urls << QUrl::fromLocalFile(QDir::currentPath());
|
||||
urls << QUrl::fromLocalFile(restoreLocation());
|
||||
|
||||
QString file;
|
||||
FileDialog dlg(parent);
|
||||
@@ -297,7 +297,7 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
|
||||
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
|
||||
urls << QUrl::fromLocalFile(getWorkingDirectory());
|
||||
urls << QUrl::fromLocalFile(QDir::currentPath());
|
||||
urls << QUrl::fromLocalFile(restoreLocation());
|
||||
|
||||
QStringList files;
|
||||
FileDialog dlg(parent);
|
||||
@@ -330,6 +330,8 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
|
||||
return files;
|
||||
}
|
||||
|
||||
QString FileDialog::workingDirectory;
|
||||
|
||||
/**
|
||||
* Returns the working directory for the file dialog. This path can be used in
|
||||
* combination with getSaveFileName(), getOpenFileName(), getOpenFileNames() or
|
||||
@@ -337,14 +339,7 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
|
||||
*/
|
||||
QString FileDialog::getWorkingDirectory()
|
||||
{
|
||||
std::string path = App::GetApplication().Config()["UserHomePath"];
|
||||
Base::Reference<ParameterGrp> hPath = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")->GetGroup("General");
|
||||
std::string dir = hPath->GetASCII("FileOpenSavePath", path.c_str());
|
||||
QFileInfo fi(QString::fromUtf8(dir.c_str()));
|
||||
if (!fi.exists())
|
||||
dir = path;
|
||||
return QString::fromUtf8(dir.c_str());
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,6 +358,32 @@ void FileDialog::setWorkingDirectory(const QString& dir)
|
||||
dirName = info.absoluteFilePath();
|
||||
}
|
||||
|
||||
workingDirectory = dirName;
|
||||
saveLocation(dirName);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return the last location where a file save or load dialog was used.
|
||||
* \return QString
|
||||
*/
|
||||
QString FileDialog::restoreLocation()
|
||||
{
|
||||
std::string path = App::GetApplication().Config()["UserHomePath"];
|
||||
Base::Reference<ParameterGrp> hPath = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")->GetGroup("General");
|
||||
std::string dir = hPath->GetASCII("FileOpenSavePath", path.c_str());
|
||||
QFileInfo fi(QString::fromUtf8(dir.c_str()));
|
||||
if (!fi.exists())
|
||||
dir = path;
|
||||
return QString::fromUtf8(dir.c_str());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Save the last location where a file save or load dialog was used.
|
||||
* \param dirName
|
||||
*/
|
||||
void FileDialog::saveLocation(const QString& dirName)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hPath = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")->GetGroup("General");
|
||||
hPath->SetASCII("FileOpenSavePath", dirName.toUtf8());
|
||||
|
||||
Reference in New Issue
Block a user