refactor: migrate ztools and Silo to kindred-addon-sdk (#250)
Some checks failed
Build and Test / build (pull_request) Failing after 1m51s
Some checks failed
Build and Test / build (pull_request) Failing after 1m51s
Route platform API calls through kindred_sdk wrappers: ZTools: - Replace hardcoded MOCHA dict with kindred_sdk.get_theme_tokens() - Add sdk dependency to package.xml Silo: - Replace FreeCADGui.registerEditingOverlay() with kindred_sdk.register_overlay() - Replace FreeCADGui.addOrigin()/removeOrigin() with kindred_sdk wrappers - Replace hardcoded _MOCHA palette subset with kindred_sdk.get_theme_tokens() - Add sdk dependency to package.xml Create module: - Replace dock panel boilerplate with kindred_sdk.register_dock_panel() Behavior is identical before and after — this is a refactor only. Closes #250
This commit is contained in:
Submodule mods/silo updated: 7a4ed3550a...d605844cb5
Submodule mods/ztools updated: 29ca89e533...55be41e697
@@ -55,26 +55,17 @@ def _register_silo_origin():
|
||||
def _setup_silo_auth_panel():
|
||||
"""Dock the Silo authentication panel in the right-hand side panel."""
|
||||
try:
|
||||
from PySide import QtCore, QtWidgets
|
||||
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
if mw is None:
|
||||
return
|
||||
|
||||
# Don't create duplicate panels
|
||||
if mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseAuth"):
|
||||
return
|
||||
from kindred_sdk import register_dock_panel
|
||||
|
||||
def _factory():
|
||||
import silo_commands
|
||||
|
||||
auth = silo_commands.SiloAuthDockWidget()
|
||||
# Prevent GC of the auth timer by stashing on the widget
|
||||
auth.widget._auth = auth
|
||||
return auth.widget
|
||||
|
||||
panel = QtWidgets.QDockWidget("Database Auth", mw)
|
||||
panel.setObjectName("SiloDatabaseAuth")
|
||||
panel.setWidget(auth.widget)
|
||||
# Keep the auth object alive so its QTimer isn't destroyed while running
|
||||
panel._auth = auth
|
||||
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, panel)
|
||||
register_dock_panel("SiloDatabaseAuth", "Database Auth", _factory)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo auth panel skipped: {e}\n")
|
||||
|
||||
@@ -82,22 +73,13 @@ def _setup_silo_auth_panel():
|
||||
def _setup_silo_activity_panel():
|
||||
"""Show a dock widget with recent Silo database activity."""
|
||||
try:
|
||||
from PySide import QtCore, QtWidgets
|
||||
from kindred_sdk import register_dock_panel
|
||||
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
if mw is None:
|
||||
return
|
||||
|
||||
# Don't create duplicate panels
|
||||
if mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseActivity"):
|
||||
return
|
||||
|
||||
panel = QtWidgets.QDockWidget("Database Activity", mw)
|
||||
panel.setObjectName("SiloDatabaseActivity")
|
||||
def _factory():
|
||||
from PySide import QtWidgets
|
||||
|
||||
widget = QtWidgets.QWidget()
|
||||
layout = QtWidgets.QVBoxLayout(widget)
|
||||
|
||||
activity_list = QtWidgets.QListWidget()
|
||||
layout.addWidget(activity_list)
|
||||
|
||||
@@ -118,13 +100,9 @@ def _setup_silo_activity_panel():
|
||||
except Exception:
|
||||
activity_list.addItem("(Unable to connect to Silo database)")
|
||||
|
||||
panel.setWidget(widget)
|
||||
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, panel)
|
||||
return widget
|
||||
|
||||
# Give the activity panel most of the vertical space
|
||||
auth_panel = mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseAuth")
|
||||
if auth_panel:
|
||||
mw.resizeDocks([auth_panel, panel], [120, 500], QtCore.Qt.Vertical)
|
||||
register_dock_panel("SiloDatabaseActivity", "Database Activity", _factory)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo activity panel skipped: {e}\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user