Skip to content

Commit

Permalink
Merge pull request #4165 from chennes/addImportExportRecentFilesPrefs
Browse files Browse the repository at this point in the history
[App] Add prefs for import/export in Recent Files
  • Loading branch information
kkremitzki committed Jan 30, 2021
2 parents 1f77dc2 + ce8b96b commit ca346b9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Gui/Application.cpp
Expand Up @@ -717,7 +717,12 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch

// the original file name is required
QString filename = QString::fromUtf8(File.filePath().c_str());
getMainWindow()->appendRecentFile(filename);
auto parameterGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General");
bool addToRecent = parameterGroup->GetBool("RecentIncludesImported", true);
parameterGroup->SetBool("RecentIncludesImported", addToRecent); // Make sure it gets added to the parameter list
if (addToRecent) {
getMainWindow()->appendRecentFile(filename);
}
FileDialog::setWorkingDirectory(filename);
}
catch (const Base::PyException& e){
Expand Down Expand Up @@ -771,9 +776,17 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
// search for a module that is able to open the exported file because otherwise
// it doesn't need to be added to the recent files list (#0002047)
std::map<std::string, std::string> importMap = App::GetApplication().getImportFilters(te.c_str());
if (!importMap.empty())
getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str()));

auto parameterGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General");
bool addToRecent = parameterGroup->GetBool("RecentIncludesExported", false);
parameterGroup->SetBool("RecentIncludesExported", addToRecent); // Make sure it gets added to the parameter list
if (addToRecent) {
// search for a module that is able to open the exported file because otherwise
// it doesn't need to be added to the recent files list (#0002047)
std::map<std::string, std::string> importMap = App::GetApplication().getImportFilters(te.c_str());
if (!importMap.empty())
getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str()));
}
// allow exporters to pass _objs__ to submodules before deleting it
Gui::Command::runCommand(Gui::Command::App, "del __objs__");
}
Expand Down

0 comments on commit ca346b9

Please sign in to comment.