From 2069e799bb028eabacfd62cb0540fc570457e15a Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 23 Jun 2025 21:11:23 +0200 Subject: [PATCH] CAM: Load preferences before activating the workbench (#21981) --- src/Mod/CAM/InitGui.py | 54 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Mod/CAM/InitGui.py b/src/Mod/CAM/InitGui.py index d9f92c86b7..259bf310d5 100644 --- a/src/Mod/CAM/InitGui.py +++ b/src/Mod/CAM/InitGui.py @@ -22,11 +22,39 @@ # * * # *************************************************************************** import FreeCAD +from PySide.QtCore import QT_TRANSLATE_NOOP +import Path.Dressup.Gui.Preferences as PathPreferencesPathDressup +import Path.Tool.assets.ui.preferences as AssetPreferences +import Path.Main.Gui.PreferencesJob as PathPreferencesPathJob +import Path.Base.Gui.PreferencesAdvanced as PathPreferencesAdvanced +import Path.Op.Base +import Path.Tool FreeCAD.__unit_test__ += ["TestCAMGui"] +if FreeCAD.GuiUp: + import FreeCADGui + + FreeCADGui.addPreferencePage( + PathPreferencesPathJob.JobPreferencesPage, + QT_TRANSLATE_NOOP("QObject", "CAM"), + ) + FreeCADGui.addPreferencePage( + AssetPreferences.AssetPreferencesPage, + QT_TRANSLATE_NOOP("QObject", "CAM"), + ) + FreeCADGui.addPreferencePage( + PathPreferencesPathDressup.DressupPreferencesPage, + QT_TRANSLATE_NOOP("QObject", "CAM"), + ) + FreeCADGui.addPreferencePage( + PathPreferencesAdvanced.AdvancedPreferencesPage, + QT_TRANSLATE_NOOP("QObject", "CAM"), + ) + + class PathCommandGroup: def __init__(self, cmdlist, menu, tooltip=None): self.cmdlist = cmdlist @@ -66,13 +94,10 @@ class CAMWorkbench(Workbench): import Path.Tool.assets.ui.preferences as AssetPreferences import Path.Main.Gui.PreferencesJob as PathPreferencesPathJob - translate = FreeCAD.Qt.translate - # load the builtin modules import Path import PathScripts import PathGui - from PySide import QtCore, QtGui FreeCADGui.addLanguagePath(":/translations") FreeCADGui.addIconPath(":/icons") @@ -89,19 +114,6 @@ class CAMWorkbench(Workbench): import subprocess from packaging.version import Version, parse - FreeCADGui.addPreferencePage( - PathPreferencesPathJob.JobPreferencesPage, - QT_TRANSLATE_NOOP("QObject", "CAM"), - ) - FreeCADGui.addPreferencePage( - AssetPreferences.AssetPreferencesPage, - QT_TRANSLATE_NOOP("QObject", "CAM"), - ) - FreeCADGui.addPreferencePage( - PathPreferencesPathDressup.DressupPreferencesPage, - QT_TRANSLATE_NOOP("QObject", "CAM"), - ) - Path.GuiInit.Startup() # build commands list @@ -291,14 +303,6 @@ class CAMWorkbench(Workbench): if curveAccuracy: Path.Area.setDefaultParams(Accuracy=curveAccuracy) - # keep this one the last entry in the preferences - import Path.Base.Gui.PreferencesAdvanced as PathPreferencesAdvanced - from Path.Preferences import preferences - - FreeCADGui.addPreferencePage( - PathPreferencesAdvanced.AdvancedPreferencesPage, - QT_TRANSLATE_NOOP("QObject", "CAM"), - ) Log("Loading CAM workbench... done\n") def GetClassName(self): @@ -314,8 +318,6 @@ class CAMWorkbench(Workbench): pass def ContextMenu(self, recipient): - import PathScripts - menuAppended = False if len(FreeCADGui.Selection.getSelection()) == 1: obj = FreeCADGui.Selection.getSelection()[0]