18 #include "ListenerRegistry.h"
20 #include "PluginRegistry.h"
22 Q_LOGGING_CATEGORY(PLUGIN_LISTENER,
"dekko.plugman.listener")
28 QQmlListProperty<QQuickItem> ListenerRegistry::defaultListeners()
30 return QQmlListProperty<QQuickItem>(
this, m_defaults);
33 QQuickItem *ListenerRegistry::createListenerFromURl(
const QString &url)
36 qCWarning(PLUGIN_LISTENER) <<
"Invalid component url";
39 auto engine = qmlEngine(
this);
40 QQmlComponent itemComponent(engine, QUrl::fromLocalFile(url));
41 if (itemComponent.isError()) {
42 for (
auto error : itemComponent.errors()) {
43 qCDebug(PLUGIN_LISTENER) <<
"Failed loading plugin with error:";
44 qCDebug(PLUGIN_LISTENER) << error.toString();
48 return qobject_cast<QQuickItem *>(itemComponent.create(engine->contextForObject(
this)));
51 void ListenerRegistry::componentComplete()
53 auto plugins = PluginRegistry::instance()->getByLocation(QStringLiteral(
"Dekko::Listener"));
54 for (
auto plugin : plugins) {
55 if (
auto dp = qobject_cast<DekkoPlugin *>(plugin)) {
56 qCDebug(PLUGIN_LISTENER) <<
"Loading plugin: " << dp->pluginId();
57 QQuickItem *item = createListenerFromURl(dp->component());