27
def _remove_from_list(prefs, pref_name):
29
mods = prefs.GetString(pref_name, "").split(",")
30
if "StartWorkbench" in mods:
31
mods.remove("StartWorkbench")
32
if "WebWorkbench" in mods:
33
mods.remove("WebWorkbench")
34
prefs.SetString(pref_name, ",".join(mods))
37
class StartMigrator2024:
38
"""In April 2024 the old Start workbench was retired, and replaced with the current Start command. This function
39
cleans up references to the old workbench, migrating the settings where appropriate, and deleting them where they
40
are no longer relevant. Web was also removed, without replacement.
41
TODO: Remove the 2024 migration code when enough time has passed that it is no longer useful"""
44
self.completion_indicator = "Migration2024Complete"
45
self.start_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
46
self.general_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General")
47
self.migration_2024_complete = self.start_prefs.GetBool(self.completion_indicator, False)
49
def run_migration(self):
50
if self.migration_2024_complete:
53
FreeCAD.Console.PrintMessage("Migrating Start Workbench to Start command... ")
54
self._update_startup_flags()
55
self._remove_wb_references()
56
self._remove_commands()
57
self._remove_toolbars()
58
self._remove_deprecated_parameters()
60
FreeCAD.Console.PrintMessage("done.\n")
64
def _update_startup_flags(self):
65
autoload_module = self.general_prefs.GetString("AutoloadModule", "StartWorkbench")
66
if autoload_module == "StartWorkbench":
67
self.start_prefs.SetBool("ShowOnStartup", True)
68
self.general_prefs.SetString("AutoloadModule", "PartDesignWorkbench")
70
self.start_prefs.SetBool("ShowOnStartup", False)
73
def _remove_wb_references(self):
74
general_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General")
75
last_module = general_prefs.GetString("LastModule", "")
76
if last_module in ["StartWorkbench", "WebWorkbench"]:
77
general_prefs.RemString("LastModule")
78
_remove_from_list(general_prefs, "BackgroundAutoloadModules")
79
treeview_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Workbenches")
80
_remove_from_list(treeview_prefs, "Ordered")
81
_remove_from_list(treeview_prefs, "Disabled")
84
def _remove_commands(self):
85
command_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Commands")
86
commands = command_prefs.GetStrings()
87
for command in commands:
88
if command.startswith("Web_") or (
89
command.startswith("Start_") and command != "Start_Start"
91
command_prefs.RemString(command)
94
def _remove_toolbars(self):
95
tux_prefs = FreeCAD.ParamGet("User parameter:Tux/PersistentToolbars/User")
96
groups = tux_prefs.GetGroups()
97
if "StartWorkbench" in groups:
98
tux_prefs.RemGroup("StartWorkbench")
99
if "WebWorkbench" in groups:
100
tux_prefs.RemGroup("WebWorkbench")
103
def _remove_deprecated_parameters(self):
104
show_on_startup = self.start_prefs.GetBool("ShowOnStartup", True)
105
show_examples = self.start_prefs.GetBool("ShowExamples", True)
106
close_start = self.start_prefs.GetBool("closeStart", False)
107
custom_folder = self.start_prefs.GetString(
108
"ShowCustomFolder", ""
110
self.start_prefs.Clear()
111
self.start_prefs.SetBool("ShowOnStartup", show_on_startup)
112
self.start_prefs.SetBool("ShowExamples", show_examples)
113
self.start_prefs.SetBool("CloseStart", close_start)
114
self.start_prefs.SetString("ShowCustomFolder", custom_folder)
117
def _mark_complete(self):
118
self.start_prefs.SetBool(self.completion_indicator, True)