"""Silo FreeCAD Workbench - Item database integration.""" import os import FreeCAD import FreeCADGui FreeCAD.Console.PrintMessage("Silo InitGui.py loading...\n") class SiloWorkbench(FreeCADGui.Workbench): """Silo workbench for item database integration.""" MenuText = "Silo" ToolTip = "Item database and part management" Icon = "" def __init__(self): # Find icon path try: locations = [ os.path.join(FreeCAD.getUserAppDataDir(), "Mod", "Silo"), os.path.join(FreeCAD.getResourceDir(), "Mod", "Silo"), os.path.expanduser( "~/.var/app/org.freecad.FreeCAD/data/FreeCAD/Mod/Silo" ), os.path.expanduser("~/.FreeCAD/Mod/Silo"), ] for silo_dir in locations: icon_path = os.path.join(silo_dir, "resources", "icons", "silo.svg") if os.path.exists(icon_path): self.__class__.Icon = icon_path FreeCAD.Console.PrintMessage("Silo icon: " + icon_path + "\n") break except Exception as e: FreeCAD.Console.PrintWarning("Silo icon error: " + str(e) + "\n") def Initialize(self): """Called when workbench is first activated.""" import silo_commands self.toolbar_commands = [ "Silo_Open", "Silo_New", "Silo_Save", "Silo_Commit", "Silo_Pull", "Silo_Push", "Silo_Info", ] self.appendToolbar("Silo", self.toolbar_commands) self.appendMenu("Silo", self.toolbar_commands) def Activated(self): """Called when workbench is activated.""" FreeCAD.Console.PrintMessage("Silo workbench activated\n") FreeCAD.Console.PrintMessage( " API: SILO_API_URL (default: http://localhost:8080/api)\n" ) FreeCAD.Console.PrintMessage( " Projects: SILO_PROJECTS_DIR (default: ~/projects)\n" ) self._show_shortcut_recommendations() def Deactivated(self): pass def GetClassName(self): return "Gui::PythonWorkbench" def _show_shortcut_recommendations(self): """Show keyboard shortcut recommendations dialog on first activation.""" try: param_group = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/Silo" ) if param_group.GetBool("ShortcutsShown", False): return param_group.SetBool("ShortcutsShown", True) from PySide import QtGui msg = """
For the best experience, set up these keyboard shortcuts:
| Ctrl+O | - | Silo_Open (Search & Open) |
| Ctrl+N | - | Silo_New (Register new item) |
| Ctrl+S | - | Silo_Save (Save & upload) |
| Ctrl+Shift+S | - | Silo_Commit (Save with comment) |
To set shortcuts: Tools > Customize > Keyboard
This message appears once.
""" dialog = QtGui.QMessageBox() dialog.setWindowTitle("Silo Keyboard Shortcuts") dialog.setTextFormat(QtGui.Qt.RichText) dialog.setText(msg) dialog.setIcon(QtGui.QMessageBox.Information) dialog.addButton("Set Up Now", QtGui.QMessageBox.AcceptRole) dialog.addButton("Later", QtGui.QMessageBox.RejectRole) if dialog.exec_() == 0: FreeCADGui.runCommand("Std_DlgCustomize", 0) except Exception as e: FreeCAD.Console.PrintWarning("Silo shortcuts dialog: " + str(e) + "\n") FreeCADGui.addWorkbench(SiloWorkbench()) FreeCAD.Console.PrintMessage("Silo workbench registered\n")