From c9e7da359a871d8b864a68ab8f501df9c01c24f2 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Mon, 15 Sep 2025 13:03:20 -0500 Subject: [PATCH] Fixes #23015 The standard in FreeCAD is that workbench preference pages get loaded when the module gets loaded. That behavior was altered by PR 21981 which attempted to load CAM preference pages at startup even if CAM was not loaded. The result was that pages were only partially loaded and the result was a confusing mess. There is some discussion about future enhancements to allow workbench preferences to be loaded early. When that is implemented, CAM will adjust to be compliant with FreeCAD standard. This effectively revertts PR #21981 --- src/Mod/CAM/InitGui.py | 60 +++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/src/Mod/CAM/InitGui.py b/src/Mod/CAM/InitGui.py index ce933763a4..23e6e003f1 100644 --- a/src/Mod/CAM/InitGui.py +++ b/src/Mod/CAM/InitGui.py @@ -22,39 +22,11 @@ # * * # *************************************************************************** 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 @@ -94,10 +66,13 @@ 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") @@ -108,16 +83,25 @@ class CAMWorkbench(Workbench): from Path.Tool.toolbit.ui import cmd as PathToolBitCmd from Path.Tool.library.ui import cmd as PathToolBitLibraryCmd - from Path.Tool.camassets import cam_assets - - cam_assets.setup() - from PySide.QtCore import QT_TRANSLATE_NOOP import PathCommands 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 @@ -194,6 +178,7 @@ class CAMWorkbench(Workbench): prepcmdlist.append("CAM_PathShapeTC") extracmdlist.extend(["CAM_Area", "CAM_Area_Workplane"]) specialcmdlist.append("CAM_ThreadMilling") + twodopcmdlist.append("CAM_Slot") if Path.Preferences.advancedOCLFeaturesEnabled(): try: @@ -307,6 +292,14 @@ 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): @@ -322,6 +315,8 @@ class CAMWorkbench(Workbench): pass def ContextMenu(self, recipient): + import PathScripts + menuAppended = False if len(FreeCADGui.Selection.getSelection()) == 1: obj = FreeCADGui.Selection.getSelection()[0] @@ -344,7 +339,6 @@ class CAMWorkbench(Workbench): "Profile" in selectedName or "Contour" in selectedName or "Dressup" in selectedName - or "Pocket" in selectedName ): self.appendContextMenu("", "Separator") # self.appendContextMenu("", ["Set_StartPoint"])