From aec977765e7a584539716eb90f912276603ee7d9 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 18 Dec 2020 13:43:23 -0600 Subject: [PATCH] Add prefs for import/export in Recent Files Add two (currently hidden) preferences controlling whether imported and exported files are included in the recent files list. RecentIncludesImported defaults to true, and RecentIncludesExported defaults to false. --- src/Gui/Application.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index ea4c6a76d9..34a9e3a0f7 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -716,8 +716,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); + QString filename = QString::fromUtf8(File.filePath().c_str()); + bool addToRecent = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> + GetBool("RecentIncludesImported", true); + if (addToRecent) { + getMainWindow()->appendRecentFile(filename); + } FileDialog::setWorkingDirectory(filename); } catch (const Base::PyException& e){ @@ -771,9 +775,15 @@ 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 importMap = App::GetApplication().getImportFilters(te.c_str()); - if (!importMap.empty()) - getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str())); - + bool addToRecent = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> + GetBool("RecentIncludesExported", false); + 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 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__"); }