chore(silo): add root package.xml and migrate setup to silo addon (#373)
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Update silo submodule to include root-level package.xml, Init.py, and InitGui.py following the standard addon layout used by sdk, gears, datums, and solver. Move five Silo-specific deferred setup functions from src/Mod/Create/InitGui.py into the silo addon's own InitGui.py: - Document observer registration (600ms) - Auth dock panel via kindred_sdk.register_dock_panel() (2000ms) - First-start settings check (3000ms) - Activity dock panel via kindred_sdk.register_dock_panel() (4000ms) - Remove duplicate origin registration (was 1500ms, already done in SiloWorkbench.Initialize()) Update CMake install targets to include root-level silo files. Create core InitGui.py now only handles kc_format (500ms) and update_checker (10000ms).
This commit is contained in:
Submodule mods/silo updated: 65b87ef605...9187622239
@@ -42,6 +42,14 @@ install(
|
||||
)
|
||||
|
||||
# Install Silo addon
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_SOURCE_DIR}/mods/silo/package.xml
|
||||
${CMAKE_SOURCE_DIR}/mods/silo/Init.py
|
||||
${CMAKE_SOURCE_DIR}/mods/silo/InitGui.py
|
||||
DESTINATION
|
||||
mods/silo
|
||||
)
|
||||
install(
|
||||
DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/mods/silo/freecad/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# GUI initialization - loads Kindred addon workbenches via manifest-driven loader
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
try:
|
||||
from addon_loader import load_addons
|
||||
@@ -24,99 +23,6 @@ def _register_kc_format():
|
||||
FreeCAD.Console.PrintLog(f"Create: kc_format registration skipped: {e}\n")
|
||||
|
||||
|
||||
def _register_silo_document_observer():
|
||||
"""Register the Silo document observer for .kc tree building."""
|
||||
try:
|
||||
import silo_document
|
||||
|
||||
silo_document.register()
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: silo_document registration skipped: {e}\n")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Silo integration enhancements
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _check_silo_first_start():
|
||||
"""Show Silo settings dialog on first startup if not yet configured."""
|
||||
try:
|
||||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/KindredSilo")
|
||||
if not param.GetBool("FirstStartChecked", False):
|
||||
param.SetBool("FirstStartChecked", True)
|
||||
if not param.GetString("ApiUrl", ""):
|
||||
FreeCADGui.runCommand("Silo_Settings")
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo first-start check skipped: {e}\n")
|
||||
|
||||
|
||||
def _register_silo_origin():
|
||||
"""Register Silo as a file origin so the origin selector can offer it."""
|
||||
try:
|
||||
import silo_commands # noqa: F401 - registers Silo commands
|
||||
import silo_origin
|
||||
|
||||
silo_origin.register_silo_origin()
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo origin registration skipped: {e}\n")
|
||||
|
||||
|
||||
def _setup_silo_auth_panel():
|
||||
"""Dock the Silo authentication panel in the right-hand side panel."""
|
||||
try:
|
||||
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
|
||||
|
||||
register_dock_panel("SiloDatabaseAuth", "Database Auth", _factory)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo auth panel skipped: {e}\n")
|
||||
|
||||
|
||||
def _setup_silo_activity_panel():
|
||||
"""Show a dock widget with recent Silo database activity."""
|
||||
try:
|
||||
from kindred_sdk import register_dock_panel
|
||||
|
||||
def _factory():
|
||||
from PySide import QtWidgets
|
||||
|
||||
widget = QtWidgets.QWidget()
|
||||
layout = QtWidgets.QVBoxLayout(widget)
|
||||
activity_list = QtWidgets.QListWidget()
|
||||
layout.addWidget(activity_list)
|
||||
|
||||
try:
|
||||
import silo_commands
|
||||
|
||||
items = silo_commands._client.list_items()
|
||||
if isinstance(items, list):
|
||||
for item in items[:20]:
|
||||
pn = item.get("part_number", "")
|
||||
desc = item.get("description", "")
|
||||
updated = item.get("updated_at", "")
|
||||
if updated:
|
||||
updated = updated[:10]
|
||||
activity_list.addItem(f"{pn} - {desc} - {updated}")
|
||||
if activity_list.count() == 0:
|
||||
activity_list.addItem("(No items in database)")
|
||||
except Exception:
|
||||
activity_list.addItem("(Unable to connect to Silo database)")
|
||||
|
||||
return widget
|
||||
|
||||
register_dock_panel("SiloDatabaseActivity", "Database Activity", _factory)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintLog(f"Create: Silo activity panel skipped: {e}\n")
|
||||
|
||||
|
||||
def _check_for_updates():
|
||||
"""Check for application updates in the background."""
|
||||
try:
|
||||
@@ -132,11 +38,6 @@ try:
|
||||
from PySide.QtCore import QTimer
|
||||
|
||||
QTimer.singleShot(500, _register_kc_format)
|
||||
QTimer.singleShot(600, _register_silo_document_observer)
|
||||
QTimer.singleShot(1500, _register_silo_origin)
|
||||
QTimer.singleShot(2000, _setup_silo_auth_panel)
|
||||
QTimer.singleShot(3000, _check_silo_first_start)
|
||||
QTimer.singleShot(4000, _setup_silo_activity_panel)
|
||||
QTimer.singleShot(10000, _check_for_updates)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user