- Silo_ToggleMode: checkable toolbar button that swaps Ctrl+O/S/N between standard FreeCAD file commands and Silo equivalents - _swap_shortcuts() helper stores/restores original QAction shortcuts - SSL settings: add CA certificate file browser (SslCertPath preference) with QFileDialog for .pem/.crt/.cer, loaded in _get_ssl_context() - Integrate Silo_BOM into workbench toolbar (after upstream BOM merge) - Add Silo_ToggleMode to toolbar as first item with separator
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
"""Kindred Silo Workbench - Item database integration for Kindred Create."""
|
|
|
|
import os
|
|
|
|
import FreeCAD
|
|
import FreeCADGui
|
|
|
|
FreeCAD.Console.PrintMessage("Kindred Silo InitGui.py loading...\n")
|
|
|
|
|
|
class SiloWorkbench(FreeCADGui.Workbench):
|
|
"""Kindred Silo workbench for item database integration."""
|
|
|
|
MenuText = "Kindred Silo"
|
|
ToolTip = "Item database and part management for Kindred Create"
|
|
Icon = ""
|
|
|
|
def __init__(self):
|
|
# Resolve icon relative to this file so it works regardless of install location
|
|
icon_path = os.path.join(
|
|
os.path.dirname(os.path.abspath(__file__)), "resources", "icons", "silo.svg"
|
|
)
|
|
if os.path.exists(icon_path):
|
|
self.__class__.Icon = icon_path
|
|
|
|
def Initialize(self):
|
|
"""Called when workbench is first activated."""
|
|
import silo_commands
|
|
|
|
self.toolbar_commands = [
|
|
"Silo_ToggleMode",
|
|
"Separator",
|
|
"Silo_Open",
|
|
"Silo_New",
|
|
"Silo_Save",
|
|
"Silo_Commit",
|
|
"Silo_Pull",
|
|
"Silo_Push",
|
|
"Silo_Info",
|
|
"Silo_BOM",
|
|
"Silo_Settings",
|
|
]
|
|
|
|
self.appendToolbar("Silo", self.toolbar_commands)
|
|
self.appendMenu("Silo", self.toolbar_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
|
|
|
|
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 = """<h3>Welcome to Kindred Silo!</h3>
|
|
<p>For the best experience, set up these keyboard shortcuts:</p>
|
|
<table style="margin: 10px 0;">
|
|
<tr><td><b>Ctrl+O</b></td><td> - </td><td>Silo_Open (Search & Open)</td></tr>
|
|
<tr><td><b>Ctrl+N</b></td><td> - </td><td>Silo_New (Register new item)</td></tr>
|
|
<tr><td><b>Ctrl+S</b></td><td> - </td><td>Silo_Save (Save & upload)</td></tr>
|
|
<tr><td><b>Ctrl+Shift+S</b></td><td> - </td><td>Silo_Commit (Save with comment)</td></tr>
|
|
</table>
|
|
<p><b>To set shortcuts:</b> Tools > Customize > Keyboard</p>
|
|
<p style="color: #888;">This message appears once.</p>"""
|
|
|
|
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")
|