fix(toolbar): add workbench-level fallback contexts (#230)
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Some checks failed
Build and Test / build (pull_request) Has been cancelled
PartDesign, Sketcher, and Assembly toolbars use DefaultVisibility::Unavailable and rely on EditingContextResolver to show them. When switching to these workbenches without a specific editing state (e.g. PartDesign with no Body activated), no context matches and all workbench toolbars stay hidden. Add workbench-level fallback contexts at priority 20 that match when the workbench is active regardless of editing state: - partdesign.workbench: shows Helper Features + Sketcher toolbars - sketcher.workbench: shows Sketcher + Sketcher Tools - assembly.workbench: shows Assembly toolbar These fill the gap between object-specific contexts (priority 30+) and the empty_document fallback (priority 10).
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "ToolBarManager.h"
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProviderDocumentObject.h"
|
||||
#include "WorkbenchManager.h"
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
@@ -330,6 +331,49 @@ void EditingContextResolver::registerBuiltinContexts()
|
||||
},
|
||||
});
|
||||
|
||||
// --- Workbench-level fallbacks (priority 20) ---
|
||||
// Show basic workbench toolbars when the workbench is active but no
|
||||
// specific editing context matches (e.g. no Body selected in PartDesign).
|
||||
|
||||
registerContext({
|
||||
/*.id =*/QStringLiteral("partdesign.workbench"),
|
||||
/*.labelTemplate =*/QStringLiteral("Part Design"),
|
||||
/*.color =*/QLatin1String(CatppuccinMocha::Mauve),
|
||||
/*.toolbars =*/
|
||||
{QStringLiteral("Part Design Helper Features"), QStringLiteral("Sketcher")},
|
||||
/*.priority =*/20,
|
||||
/*.match =*/
|
||||
[]() {
|
||||
return WorkbenchManager::instance()->activeName() == "PartDesignWorkbench";
|
||||
},
|
||||
});
|
||||
|
||||
registerContext({
|
||||
/*.id =*/QStringLiteral("sketcher.workbench"),
|
||||
/*.labelTemplate =*/QStringLiteral("Sketcher"),
|
||||
/*.color =*/QLatin1String(CatppuccinMocha::Green),
|
||||
/*.toolbars =*/
|
||||
{QStringLiteral("Sketcher"), QStringLiteral("Sketcher Tools")},
|
||||
/*.priority =*/20,
|
||||
/*.match =*/
|
||||
[]() {
|
||||
return WorkbenchManager::instance()->activeName() == "SketcherWorkbench";
|
||||
},
|
||||
});
|
||||
|
||||
registerContext({
|
||||
/*.id =*/QStringLiteral("assembly.workbench"),
|
||||
/*.labelTemplate =*/QStringLiteral("Assembly"),
|
||||
/*.color =*/QLatin1String(CatppuccinMocha::Blue),
|
||||
/*.toolbars =*/
|
||||
{QStringLiteral("Assembly")},
|
||||
/*.priority =*/20,
|
||||
/*.match =*/
|
||||
[]() {
|
||||
return WorkbenchManager::instance()->activeName() == "AssemblyWorkbench";
|
||||
},
|
||||
});
|
||||
|
||||
// --- Empty document ---
|
||||
registerContext({
|
||||
/*.id =*/QStringLiteral("empty_document"),
|
||||
|
||||
Reference in New Issue
Block a user