| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | import FreeCAD
|
| |
|
| |
|
| | def _remove_from_list(prefs, pref_name):
|
| |
|
| |
|
| |
|
| | is_empty_string = "<IS_EMPTY>"
|
| | mods = prefs.GetString(pref_name, is_empty_string).split(",")
|
| |
|
| | if is_empty_string in mods:
|
| | return
|
| |
|
| | if "StartWorkbench" in mods:
|
| | mods.remove("StartWorkbench")
|
| | if "WebWorkbench" in mods:
|
| | mods.remove("WebWorkbench")
|
| |
|
| | prefs.SetString(pref_name, ",".join(mods))
|
| |
|
| |
|
| | class StartMigrator2024:
|
| | """In April 2024 the old Start workbench was retired, and replaced with the current Start command. This function
|
| | cleans up references to the old workbench, migrating the settings where appropriate, and deleting them where they
|
| | are no longer relevant. Web was also removed, without replacement.
|
| | TODO: Remove the 2024 migration code when enough time has passed that it is no longer useful"""
|
| |
|
| | def __init__(self):
|
| | self.completion_indicator = "Migration2024Complete"
|
| | self.start_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
|
| | self.general_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General")
|
| | self.migration_2024_complete = self.start_prefs.GetBool(self.completion_indicator, False)
|
| |
|
| | def run_migration(self):
|
| | if self.migration_2024_complete:
|
| |
|
| | return
|
| | FreeCAD.Console.PrintMessage("Migrating Start Workbench to Start command... ")
|
| | self._update_startup_flags()
|
| | self._remove_wb_references()
|
| | self._remove_commands()
|
| | self._remove_toolbars()
|
| | self._remove_deprecated_parameters()
|
| | self._mark_complete()
|
| | FreeCAD.Console.PrintMessage("done.\n")
|
| |
|
| |
|
| |
|
| | def _update_startup_flags(self):
|
| | autoload_module = self.general_prefs.GetString("AutoloadModule", "StartWorkbench")
|
| | if autoload_module == "StartWorkbench":
|
| | self.start_prefs.SetBool("ShowOnStartup", True)
|
| | self.general_prefs.SetString("AutoloadModule", "PartDesignWorkbench")
|
| | else:
|
| | self.start_prefs.SetBool("ShowOnStartup", False)
|
| |
|
| |
|
| | def _remove_wb_references(self):
|
| | general_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General")
|
| | last_module = general_prefs.GetString("LastModule", "")
|
| | if last_module in ["StartWorkbench", "WebWorkbench"]:
|
| | general_prefs.RemString("LastModule")
|
| | _remove_from_list(general_prefs, "BackgroundAutoloadModules")
|
| | treeview_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Workbenches")
|
| | _remove_from_list(treeview_prefs, "Ordered")
|
| | _remove_from_list(treeview_prefs, "Disabled")
|
| |
|
| |
|
| | def _remove_commands(self):
|
| | command_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Commands")
|
| | commands = command_prefs.GetStrings()
|
| | for command in commands:
|
| | if command.startswith("Web_") or (
|
| | command.startswith("Start_") and command != "Start_Start"
|
| | ):
|
| | command_prefs.RemString(command)
|
| |
|
| |
|
| | def _remove_toolbars(self):
|
| | tux_prefs = FreeCAD.ParamGet("User parameter:Tux/PersistentToolbars/User")
|
| | groups = tux_prefs.GetGroups()
|
| | if "StartWorkbench" in groups:
|
| | tux_prefs.RemGroup("StartWorkbench")
|
| | if "WebWorkbench" in groups:
|
| | tux_prefs.RemGroup("WebWorkbench")
|
| |
|
| |
|
| | def _remove_deprecated_parameters(self):
|
| | show_on_startup = self.start_prefs.GetBool("ShowOnStartup", True)
|
| | show_examples = self.start_prefs.GetBool("ShowExamples", True)
|
| | close_start = self.start_prefs.GetBool("closeStart", False)
|
| | custom_folder = self.start_prefs.GetString("ShowCustomFolder", "")
|
| | self.start_prefs.Clear()
|
| | self.start_prefs.SetBool("ShowOnStartup", show_on_startup)
|
| | self.start_prefs.SetBool("ShowExamples", show_examples)
|
| | self.start_prefs.SetBool("CloseStart", close_start)
|
| |
|
| | self.start_prefs.SetString("CustomFolder", custom_folder)
|
| |
|
| |
|
| | def _mark_complete(self):
|
| | self.start_prefs.SetBool(self.completion_indicator, True)
|
| |
|