2026-11-15 17:06:22 +01:00
|
|
|
"""Application entry point."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import logging
|
2026-11-15 16:08:57 +01:00
|
|
|
import sys
|
2026-11-15 17:06:22 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
from PySide6.QtCore import QUrl
|
|
|
|
|
from PySide6.QtGui import QGuiApplication
|
|
|
|
|
from PySide6.QtQml import QQmlApplicationEngine
|
|
|
|
|
|
|
|
|
|
import mcc.resources_rc # noqa: F401 — registers the compiled Qt resources
|
|
|
|
|
from mcc.core.plugin_registry import PluginRegistry, RegistryEntry
|
|
|
|
|
from mcc.core.static_plugin_provider import StaticRegistryProvider
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_plugins() -> list[dict[str, object]]:
|
|
|
|
|
"""Load explicitly registered plugins and convert them for QML."""
|
|
|
|
|
project_root = Path(__file__).resolve().parent
|
|
|
|
|
example_manifest = project_root / "plugins" / "example-readonly" / "plugin.json"
|
|
|
|
|
|
|
|
|
|
provider = StaticRegistryProvider(
|
|
|
|
|
registered_entries=(
|
|
|
|
|
RegistryEntry(
|
|
|
|
|
plugin_id="org.mageia.mcc.example",
|
|
|
|
|
manifest_path=str(example_manifest),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = PluginRegistry(provider).load()
|
|
|
|
|
|
|
|
|
|
for error in result.errors:
|
|
|
|
|
logging.warning("Could not load plugin %s: %s", error.plugin_id, error.message)
|
|
|
|
|
|
|
|
|
|
logging.info("Loaded %d plugin(s).", len(result.plugins))
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
"pluginId": plugin.plugin_id,
|
|
|
|
|
"name": plugin.name,
|
|
|
|
|
"description": plugin.description,
|
|
|
|
|
"category": plugin.category,
|
|
|
|
|
"subcategory": plugin.subcategory,
|
|
|
|
|
"frontends": list(plugin.frontends),
|
|
|
|
|
"capabilities": list(plugin.capabilities),
|
|
|
|
|
}
|
|
|
|
|
for plugin in result.plugins
|
|
|
|
|
]
|
2026-11-15 16:08:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2026-11-15 17:06:22 +01:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
app = QGuiApplication(sys.argv)
|
|
|
|
|
engine = QQmlApplicationEngine()
|
|
|
|
|
engine.rootContext().setContextProperty("registeredPlugins", load_plugins())
|
|
|
|
|
engine.load(QUrl("qrc:/qml/Main.qml"))
|
|
|
|
|
|
|
|
|
|
if not engine.rootObjects():
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
2026-11-15 16:08:57 +01:00
|
|
|
sys.exit(app.exec())
|