diff --git a/freecad/InitGui.py b/freecad/InitGui.py index 662e559..f07896d 100644 --- a/freecad/InitGui.py +++ b/freecad/InitGui.py @@ -35,19 +35,9 @@ class SiloWorkbench(FreeCADGui.Workbench): except Exception as e: FreeCAD.Console.PrintWarning(f"Could not register Silo origin: {e}\n") - self.toolbar_commands = [ - "Silo_ToggleMode", - "Separator", - "Silo_Open", - "Silo_New", - "Silo_Save", - "Silo_Commit", - "Silo_Pull", - "Silo_Push", - ] - - # Menu has management/admin commands (file commands are in File menu - # via the Create module's SiloMenuManipulator) + # 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", @@ -59,13 +49,11 @@ class SiloWorkbench(FreeCADGui.Workbench): "Silo_Auth", ] - self.appendToolbar("Silo", self.toolbar_commands) self.appendMenu("Silo", self.menu_commands) def Activated(self): """Called when workbench is activated.""" FreeCAD.Console.PrintMessage("Kindred Silo workbench activated\n") - self._show_shortcut_recommendations() def Deactivated(self): pass @@ -73,41 +61,6 @@ class SiloWorkbench(FreeCADGui.Workbench): 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/KindredSilo" - ) - if param_group.GetBool("ShortcutsShown", False): - return - param_group.SetBool("ShortcutsShown", True) - - from PySide import QtGui - - msg = """

Welcome to Kindred Silo!

-

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") diff --git a/freecad/silo_commands.py b/freecad/silo_commands.py index b162c87..42c02ea 100644 --- a/freecad/silo_commands.py +++ b/freecad/silo_commands.py @@ -2316,85 +2316,6 @@ class Silo_BOM: return FreeCAD.ActiveDocument is not None -# --------------------------------------------------------------------------- -# Silo Mode toggle - swap Ctrl+O/S/N between standard and Silo commands -# --------------------------------------------------------------------------- - -# Stored original shortcuts so they can be restored on toggle-off -_original_shortcuts: Dict[str, Any] = {} - - -def _swap_shortcuts(mapping, enable_silo): - """Swap keyboard shortcuts between standard and Silo commands. - - mapping: list of (std_cmd, silo_cmd, shortcut) tuples - enable_silo: True to assign shortcuts to Silo commands, False to restore. - """ - from PySide import QtGui - - mw = FreeCADGui.getMainWindow() - if mw is None: - return - - for std_cmd, silo_cmd, shortcut in mapping: - if enable_silo: - # Save and clear the standard command's shortcut - std_action = mw.findChild(QtGui.QAction, std_cmd) - if std_action: - _original_shortcuts[std_cmd] = std_action.shortcut().toString() - std_action.setShortcut("") - # Assign the shortcut to the Silo command - silo_action = mw.findChild(QtGui.QAction, silo_cmd) - if silo_action: - silo_action.setShortcut(shortcut) - else: - # Clear the Silo command's shortcut - silo_action = mw.findChild(QtGui.QAction, silo_cmd) - if silo_action: - silo_action.setShortcut("") - # Restore the standard command's original shortcut - std_action = mw.findChild(QtGui.QAction, std_cmd) - if std_action and std_cmd in _original_shortcuts: - std_action.setShortcut(_original_shortcuts.pop(std_cmd)) - - -_SHORTCUT_MAP = [ - ("Std_Open", "Silo_Open", "Ctrl+O"), - ("Std_Save", "Silo_Save", "Ctrl+S"), - ("Std_New", "Silo_New", "Ctrl+N"), -] - - -class Silo_ToggleMode: - """Toggle between standard file operations and Silo equivalents.""" - - def GetResources(self): - return { - "MenuText": "Silo Mode", - "ToolTip": ( - "Toggle between standard file operations and Silo equivalents.\n" - "When ON: Ctrl+O/S/N use Silo Open/Save/New.\n" - "When OFF: Standard FreeCAD file operations." - ), - "Pixmap": _icon("silo"), - "Checkable": True, - } - - def Activated(self, checked): - param = FreeCAD.ParamGet(_PREF_GROUP) - if checked: - _swap_shortcuts(_SHORTCUT_MAP, enable_silo=True) - param.SetBool("SiloMode", True) - FreeCAD.Console.PrintMessage("Silo mode enabled\n") - else: - _swap_shortcuts(_SHORTCUT_MAP, enable_silo=False) - param.SetBool("SiloMode", False) - FreeCAD.Console.PrintMessage("Silo mode disabled\n") - - def IsActive(self): - return True - - # --------------------------------------------------------------------------- # SSE live-update listener # --------------------------------------------------------------------------- @@ -2947,5 +2868,5 @@ FreeCADGui.addCommand("Silo_TagProjects", Silo_TagProjects()) FreeCADGui.addCommand("Silo_Rollback", Silo_Rollback()) FreeCADGui.addCommand("Silo_SetStatus", Silo_SetStatus()) FreeCADGui.addCommand("Silo_Settings", Silo_Settings()) -FreeCADGui.addCommand("Silo_ToggleMode", Silo_ToggleMode()) + FreeCADGui.addCommand("Silo_Auth", Silo_Auth())