Merge pull request #4165 from chennes/addImportExportRecentFilesPrefs

[App] Add prefs for import/export in Recent Files
This commit is contained in:
Kurt Kremitzki
2021-01-30 05:14:36 -06:00
committed by GitHub

View File

@@ -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){
@@ -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__");
}