support fallback to the multi engine
require SingleEngine in X-Plasma-RequiredExtensions to share the engine Change-Id: I72873d2e370f98a069bb3dff0d58290277da1292
This commit is contained in:
parent
509c5da619
commit
bb0d245d5b
@ -46,9 +46,6 @@ Comment[zh_TW]=Plasma 小程式
|
|||||||
[PropertyDef::X-Plasma-API]
|
[PropertyDef::X-Plasma-API]
|
||||||
Type=QString
|
Type=QString
|
||||||
|
|
||||||
[PropertyDef::X-Plasma-MinimumAPIVersion]
|
|
||||||
Type=int
|
|
||||||
|
|
||||||
[PropertyDef::X-Plasma-RootPath]
|
[PropertyDef::X-Plasma-RootPath]
|
||||||
Type=QString
|
Type=QString
|
||||||
|
|
||||||
|
@ -385,8 +385,13 @@ AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent)
|
|||||||
connect(&d->compactRepresentationCheckTimer, SIGNAL(timeout()),
|
connect(&d->compactRepresentationCheckTimer, SIGNAL(timeout()),
|
||||||
this, SLOT(compactRepresentationCheck()));
|
this, SLOT(compactRepresentationCheck()));
|
||||||
|
|
||||||
|
if (applet->pluginInfo().property("X-Plasma-RequiredExtensions").toStringList().contains("SharedEngine")) {
|
||||||
QQmlContext *context = new QQmlContext(AppletQuickItemPrivate::s_engine->rootContext());
|
QQmlContext *context = new QQmlContext(AppletQuickItemPrivate::s_engine->rootContext());
|
||||||
d->qmlObject = new KDeclarative::QmlObject(AppletQuickItemPrivate::s_engine, context, this);
|
d->qmlObject = new KDeclarative::QmlObject(AppletQuickItemPrivate::s_engine, context, this);
|
||||||
|
} else {
|
||||||
|
d->qmlObject = new KDeclarative::QmlObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (applet->pluginInfo().isValid()) {
|
if (applet->pluginInfo().isValid()) {
|
||||||
const QString rootPath = applet->pluginInfo().property("X-Plasma-RootPath").toString();
|
const QString rootPath = applet->pluginInfo().property("X-Plasma-RootPath").toString();
|
||||||
if (!rootPath.isEmpty()) {
|
if (!rootPath.isEmpty()) {
|
||||||
@ -414,7 +419,10 @@ AppletQuickItem::~AppletQuickItem()
|
|||||||
|
|
||||||
AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object)
|
AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object)
|
||||||
{
|
{
|
||||||
QQmlContext *context = QtQml::qmlContext(object);
|
QQmlContext *context;
|
||||||
|
//is it using shared engine mode?
|
||||||
|
if (QtQml::qmlEngine(object) == AppletQuickItemPrivate::s_engine) {
|
||||||
|
context = QtQml::qmlContext(object);
|
||||||
//search the root context of the applet in which the object is in
|
//search the root context of the applet in which the object is in
|
||||||
while (context) {
|
while (context) {
|
||||||
//the rootcontext of an applet is a child of the engine root context
|
//the rootcontext of an applet is a child of the engine root context
|
||||||
@ -424,6 +432,10 @@ AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object)
|
|||||||
|
|
||||||
context = context->parentContext();
|
context = context->parentContext();
|
||||||
}
|
}
|
||||||
|
//otherwise index by root context
|
||||||
|
} else {
|
||||||
|
context = QtQml::qmlEngine(object)->rootContext();
|
||||||
|
}
|
||||||
//at the moment of the attached object creation, the root item is the only one that hasn't a parent
|
//at the moment of the attached object creation, the root item is the only one that hasn't a parent
|
||||||
//only way to avoid creation of this attached for everybody but the root item
|
//only way to avoid creation of this attached for everybody but the root item
|
||||||
if (!object->parent() && AppletQuickItemPrivate::s_rootObjects.contains(context)) {
|
if (!object->parent() && AppletQuickItemPrivate::s_rootObjects.contains(context)) {
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
QStringList allowedPaths;
|
QStringList allowedPaths;
|
||||||
QQmlEngine *engine;
|
QQmlEngine *engine;
|
||||||
|
|
||||||
|
//FIXME: those are going to be stuffed here and stay..
|
||||||
|
// they should probably be removed when the last applet of that type is removed
|
||||||
static QHash<QString, Plasma::Package> s_packages;
|
static QHash<QString, Plasma::Package> s_packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user