shift-shell/components/mobileshell/components/applethost.h
Marco Allegretti 8fecdf1d2d Guard against invalid KPackage in AppletHost
loadPackage + setPath can produce an invalid package if the shell
package is missing. Guard with isValid() to avoid passing a bad
package to setKPackage. Add the QML_SINGLETON factory that the
QML engine requires for proper singleton instantiation.
2026-04-18 20:24:11 +02:00

50 lines
944 B
C++

// SPDX-FileCopyrightText: 2026 Marco Allegretti
// SPDX-License-Identifier: EUPL-1.2
#pragma once
#include <QHash>
#include <QObject>
#include <QQmlEngine>
#include <QQuickItem>
namespace Plasma
{
class Applet;
class Containment;
class Corona;
}
namespace PlasmaQuick
{
class AppletQuickItem;
}
class AppletHost : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
public:
explicit AppletHost(QObject *parent = nullptr);
~AppletHost() override;
static QObject *create(QQmlEngine * /*engine*/, QJSEngine * /*scriptEngine*/)
{
return new AppletHost();
}
Q_INVOKABLE QQuickItem *fullRepresentationFor(const QString &pluginId);
Q_SIGNALS:
void appletReady(const QString &pluginId);
private:
void ensureCorona();
class HostCorona;
HostCorona *m_corona = nullptr;
Plasma::Containment *m_containment = nullptr;
QHash<QString, PlasmaQuick::AppletQuickItem *> m_items;
};