From 8639b6fd8ab3fed0400bb1cf47ec1007ce3559b5 Mon Sep 17 00:00:00 2001 From: forbes Date: Sat, 31 Jan 2026 11:47:28 -0600 Subject: [PATCH] fix(gui): resolve unknown command and style token errors at startup Move ZTools command imports before workbench initialization in InitGui.py so commands are registered before PartDesign/Sketcher init triggers toolbar state restoration. Import silo_commands eagerly in _setup_silo_menu() so Silo commands exist before the WorkbenchManipulator references them. Create KindredCreate.yaml and Classic.yaml theme parameter files defining all style tokens (PrimaryColor, TextForegroundColor, etc.) used by FreeCAD.qss and the overlay stylesheet. Register them in CMakeLists.txt and set the Theme preference in KindredCreate.cfg. Add migration in migrateOldTheme() to set Theme=KindredCreate for existing users who have the stylesheet but not the Theme parameter. --- mods/ztools | 2 +- .../KindredCreate/KindredCreate.cfg | 164 ++++++++++-------- src/Gui/StartupProcess.cpp | 11 ++ src/Gui/Stylesheets/CMakeLists.txt | 2 + src/Gui/Stylesheets/parameters/Classic.yaml | 85 +++++++++ .../Stylesheets/parameters/KindredCreate.yaml | 85 +++++++++ src/Mod/Create/InitGui.py | 3 + 7 files changed, 274 insertions(+), 78 deletions(-) create mode 100644 src/Gui/Stylesheets/parameters/Classic.yaml create mode 100644 src/Gui/Stylesheets/parameters/KindredCreate.yaml diff --git a/mods/ztools b/mods/ztools index 8d1f195e56..e6f1de4ef8 160000 --- a/mods/ztools +++ b/mods/ztools @@ -1 +1 @@ -Subproject commit 8d1f195e5689876a252cba1358db20238a06aa4c +Subproject commit e6f1de4ef8421f483ea69838908e2d9b772d6438 diff --git a/src/Gui/PreferencePacks/KindredCreate/KindredCreate.cfg b/src/Gui/PreferencePacks/KindredCreate/KindredCreate.cfg index 5714f860f7..5c466f3adc 100644 --- a/src/Gui/PreferencePacks/KindredCreate/KindredCreate.cfg +++ b/src/Gui/PreferencePacks/KindredCreate/KindredCreate.cfg @@ -4,103 +4,113 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + KindredCreate.qss + KindredCreate - - - - - - - + + + + + + + - - + + - + - + - + diff --git a/src/Gui/StartupProcess.cpp b/src/Gui/StartupProcess.cpp index fd1f497535..ce9181d743 100644 --- a/src/Gui/StartupProcess.cpp +++ b/src/Gui/StartupProcess.cpp @@ -341,6 +341,17 @@ void StartupPostProcess::migrateOldTheme(const std::string& style) if (style == "FreeCAD Light.qss" || style == "FreeCAD Dark.qss") { prefPackManager->apply("KindredCreate"); } + + // Ensure the Theme parameter is set for KindredCreate so the style + // parameter YAML file (parameters/KindredCreate.yaml) is found. + if (style == "KindredCreate.qss") { + auto hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/MainWindow" + ); + if (hGrp->GetASCII("Theme", "Classic") == "Classic") { + hGrp->SetASCII("Theme", "KindredCreate"); + } + } } void StartupPostProcess::checkOpenGL() diff --git a/src/Gui/Stylesheets/CMakeLists.txt b/src/Gui/Stylesheets/CMakeLists.txt index c025a75b72..7874437f5a 100644 --- a/src/Gui/Stylesheets/CMakeLists.txt +++ b/src/Gui/Stylesheets/CMakeLists.txt @@ -6,6 +6,8 @@ SET(Stylesheets_Files ) SET(Parameters_Files + "parameters/Classic.yaml" + "parameters/KindredCreate.yaml" ) SET(Overlay_Stylesheets_Files diff --git a/src/Gui/Stylesheets/parameters/Classic.yaml b/src/Gui/Stylesheets/parameters/Classic.yaml new file mode 100644 index 0000000000..5820b33d4c --- /dev/null +++ b/src/Gui/Stylesheets/parameters/Classic.yaml @@ -0,0 +1,85 @@ +# KindredCreate theme parameters - Catppuccin Mocha palette +# Used by FreeCAD.qss and overlay stylesheets for token substitution + +# Primary surfaces +PrimaryColor: "#1e1e2e" +PrimaryColorDarken2: "#181825" +DialogBackgroundColor: "#1e1e2e" +GeneralBackgroundColor: "#1e1e2e" +GeneralAlternateBackgroundColor: "#181825" + +# Text +TextForegroundColor: "#cdd6f4" +TextDisabledColor: "#6c7086" +TextUrlColor: "#89b4fa" +TextSelectBackgroundColor: "#585b70" + +# Input fields +TextEditFieldBackgroundColor: "#313244" +InputFieldBorderRadius: "2px" + +# Borders +GeneralBorderColor: "#45475a" +GeneralBorderHoverColor: "#585b70" + +# Buttons +ButtonTopBackgroundColor: "#313244" +ButtonBottomBackgroundColor: "#313244" +ButtonBorderColor: "#45475a" +DefaultButtonTopBackgroundColor: "#cba6f7" +DefaultButtonBottomBackgroundColor: "#cba6f7" +DefaultButtonBorderColor: "#cba6f7" +CheckedButtonTopBackgroundColor: "#45475a" +CheckedButtonBottomBackgroundColor: "#45475a" + +# Accent +AccentColor: "#cba6f7" +AccentBackgroundColor: "#45475a" +AccentHoverColor: "#b4befe" + +# Interactive states +GeneralBackgroundHoverColor: "#313244" +GeneralDisabledBackgroundColor: "#181825" +GeneralHeaderBackgroundColor: "#313244" + +# Grid +GeneralGridLinesColor: "#313244" +3DViewBackgroundRefColor: "#181825" + +# Groupbox +GroupboxBackgroundColor: "#1e1e2e" +GroupboxBorderColor: "#45475a" + +# Menu +MenuBackgroundColor: "#181825" + +# Scrollbar +ScrollbarBackgroundColor: "#181825" + +# Tabs +TabbarBackgroundColor: "#181825" +ActiveTabBackgroundColor: "#1e1e2e" +InActiveTabBackgroundColor: "#313244" + +# Checkbox and radio +CheckBoxBackgroundColor: "#313244" +CheckBoxBorderColor: "#585b70" +RadioButtonBackgroundColor: "#313244" +RadioButtonBorderColor: "#585b70" + +# Toolbar +ToolbarButtonsPadding: "4px" + +# Icons +IconsLocationFolderName: "images_classic" +StylesheetIconsColor: "white" + +# Sketcher constraint colors +SketcherFullyConstrainedColor: "#a6e3a1" +SketcherUnderConstrainedColor: "#f9e2af" +SketcherConflictingConstraintsColor: "#f38ba8" +SketcherRedundantConstraintsColor: "#fab387" +SketcherMalformedConstraintsColor: "#f38ba8" +SketcherPartiallyRedundantConstraintsColor: "#fab387" +SketcherSolverFailedColor: "#f38ba8" +SketcherEmptySketchColor: "#6c7086" diff --git a/src/Gui/Stylesheets/parameters/KindredCreate.yaml b/src/Gui/Stylesheets/parameters/KindredCreate.yaml new file mode 100644 index 0000000000..5820b33d4c --- /dev/null +++ b/src/Gui/Stylesheets/parameters/KindredCreate.yaml @@ -0,0 +1,85 @@ +# KindredCreate theme parameters - Catppuccin Mocha palette +# Used by FreeCAD.qss and overlay stylesheets for token substitution + +# Primary surfaces +PrimaryColor: "#1e1e2e" +PrimaryColorDarken2: "#181825" +DialogBackgroundColor: "#1e1e2e" +GeneralBackgroundColor: "#1e1e2e" +GeneralAlternateBackgroundColor: "#181825" + +# Text +TextForegroundColor: "#cdd6f4" +TextDisabledColor: "#6c7086" +TextUrlColor: "#89b4fa" +TextSelectBackgroundColor: "#585b70" + +# Input fields +TextEditFieldBackgroundColor: "#313244" +InputFieldBorderRadius: "2px" + +# Borders +GeneralBorderColor: "#45475a" +GeneralBorderHoverColor: "#585b70" + +# Buttons +ButtonTopBackgroundColor: "#313244" +ButtonBottomBackgroundColor: "#313244" +ButtonBorderColor: "#45475a" +DefaultButtonTopBackgroundColor: "#cba6f7" +DefaultButtonBottomBackgroundColor: "#cba6f7" +DefaultButtonBorderColor: "#cba6f7" +CheckedButtonTopBackgroundColor: "#45475a" +CheckedButtonBottomBackgroundColor: "#45475a" + +# Accent +AccentColor: "#cba6f7" +AccentBackgroundColor: "#45475a" +AccentHoverColor: "#b4befe" + +# Interactive states +GeneralBackgroundHoverColor: "#313244" +GeneralDisabledBackgroundColor: "#181825" +GeneralHeaderBackgroundColor: "#313244" + +# Grid +GeneralGridLinesColor: "#313244" +3DViewBackgroundRefColor: "#181825" + +# Groupbox +GroupboxBackgroundColor: "#1e1e2e" +GroupboxBorderColor: "#45475a" + +# Menu +MenuBackgroundColor: "#181825" + +# Scrollbar +ScrollbarBackgroundColor: "#181825" + +# Tabs +TabbarBackgroundColor: "#181825" +ActiveTabBackgroundColor: "#1e1e2e" +InActiveTabBackgroundColor: "#313244" + +# Checkbox and radio +CheckBoxBackgroundColor: "#313244" +CheckBoxBorderColor: "#585b70" +RadioButtonBackgroundColor: "#313244" +RadioButtonBorderColor: "#585b70" + +# Toolbar +ToolbarButtonsPadding: "4px" + +# Icons +IconsLocationFolderName: "images_classic" +StylesheetIconsColor: "white" + +# Sketcher constraint colors +SketcherFullyConstrainedColor: "#a6e3a1" +SketcherUnderConstrainedColor: "#f9e2af" +SketcherConflictingConstraintsColor: "#f38ba8" +SketcherRedundantConstraintsColor: "#fab387" +SketcherMalformedConstraintsColor: "#f38ba8" +SketcherPartiallyRedundantConstraintsColor: "#fab387" +SketcherSolverFailedColor: "#f38ba8" +SketcherEmptySketchColor: "#6c7086" diff --git a/src/Mod/Create/InitGui.py b/src/Mod/Create/InitGui.py index 07863b9ac3..3ebaaa0cd6 100644 --- a/src/Mod/Create/InitGui.py +++ b/src/Mod/Create/InitGui.py @@ -68,6 +68,9 @@ def _check_silo_first_start(): def _setup_silo_menu(): """Inject Silo commands into the File menu and toolbar across all workbenches.""" try: + # Import silo_commands eagerly so commands are registered before the + # manipulator tries to add them to toolbars/menus. + import silo_commands # noqa: F401 class SiloMenuManipulator: def modifyMenuBar(self):