QRC and GUI Test #4
This commit is contained in:
1 parent
828534c1f5
commit
15a716d107
11 files changed
+628
-6
No files matched your search
@@ -1,9 +1,64 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
"""Application entry point."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from PySide6.QtWidgets import QApplication
|
||||
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
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
# ...
|
||||
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)
|
||||
|
||||
sys.exit(app.exec())
|
||||
Reference in new issue
Block a user