feat: register Silo overlay context for EditingContextResolver
Add 'Silo Origin' toolbar (Commit/Pull/Push/Info/BOM) registered with Unavailable visibility. Register a Silo overlay via FreeCADGui.registerEditingOverlay() that appends this toolbar to any active editing context when the current document is Silo-tracked (ownsDocument() returns True). Consolidate PySide.QtCore imports.
This commit is contained in:
@@ -35,9 +35,20 @@ class SiloWorkbench(FreeCADGui.Workbench):
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintWarning(f"Could not register Silo origin: {e}\n")
|
||||
|
||||
# Silo origin toolbar — shown as an overlay on any context when the
|
||||
# active document is Silo-tracked. Registered as Unavailable so
|
||||
# EditingContextResolver controls visibility via the overlay system.
|
||||
self.silo_toolbar_commands = [
|
||||
"Silo_Commit",
|
||||
"Silo_Pull",
|
||||
"Silo_Push",
|
||||
"Separator",
|
||||
"Silo_Info",
|
||||
"Silo_BOM",
|
||||
]
|
||||
self.appendToolbar("Silo Origin", self.silo_toolbar_commands, "Unavailable")
|
||||
|
||||
# Silo menu provides admin/management commands.
|
||||
# File operations (New/Open/Save) are handled by the standard File
|
||||
# toolbar via the origin system -- no separate Silo toolbar needed.
|
||||
self.menu_commands = [
|
||||
"Silo_Info",
|
||||
"Silo_BOM",
|
||||
@@ -68,6 +79,44 @@ class SiloWorkbench(FreeCADGui.Workbench):
|
||||
FreeCADGui.addWorkbench(SiloWorkbench())
|
||||
FreeCAD.Console.PrintMessage("Silo workbench registered\n")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Silo overlay context — adds "Silo Origin" toolbar to any active context
|
||||
# when the current document is Silo-tracked.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _register_silo_overlay():
|
||||
"""Register the Silo overlay after the Silo workbench has initialised."""
|
||||
|
||||
def _silo_overlay_match():
|
||||
"""Return True if the active document is Silo-tracked."""
|
||||
try:
|
||||
doc = FreeCAD.ActiveDocument
|
||||
if not doc:
|
||||
return False
|
||||
from silo_origin import get_silo_origin
|
||||
|
||||
origin = get_silo_origin()
|
||||
return origin.ownsDocument(doc)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
try:
|
||||
FreeCADGui.registerEditingOverlay(
|
||||
"silo", # overlay id
|
||||
["Silo Origin"], # toolbar names to append
|
||||
_silo_overlay_match, # match function
|
||||
)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintWarning(f"Silo overlay registration failed: {e}\n")
|
||||
|
||||
|
||||
from PySide import QtCore as _QtCore
|
||||
|
||||
_QtCore.QTimer.singleShot(2500, _register_silo_overlay)
|
||||
|
||||
|
||||
# Override the Start page with Silo-aware version (must happen before
|
||||
# the C++ StartLauncher fires at ~100ms after GUI init)
|
||||
try:
|
||||
@@ -92,6 +141,4 @@ def _handle_startup_urls():
|
||||
handle_kindred_url(arg)
|
||||
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
QtCore.QTimer.singleShot(500, _handle_startup_urls)
|
||||
_QtCore.QTimer.singleShot(500, _handle_startup_urls)
|
||||
|
||||
Reference in New Issue
Block a user