From 636add044bcda19b805adea5e43341f58faa2711 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 10 Jan 2021 15:40:10 -0600 Subject: [PATCH] Add parameters to user.cfg file when used The two parameters are now added to the user.cfg file once they are accessed in the code. So the first time you export a file, the parameeter RecentIncludesExported is created and defaulted to false, and the first time you import a file the parameter RecentIncludesImported is created and defaults to true. Once that is done the parameters can be edited from the Parameter Editor, even though they do not have entries in the Preferences dialog. --- src/Gui/Application.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 90c122228a..299c61906c 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -716,9 +716,10 @@ 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()); - bool addToRecent = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> - GetBool("RecentIncludesImported", true); + QString filename = QString::fromUtf8(File.filePath().c_str()); + 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); } @@ -775,8 +776,10 @@ 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()); - bool addToRecent = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> - GetBool("RecentIncludesExported", false); + + 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)