rough experiment on giving all applets the same engine
it has a couple of big problems Plasmoid attached property (should be easily fixable) url interceptor (more tricky) Change-Id: Ie75dfa97e097f43e8e5778f9b47fdff29224e5fc
This commit is contained in:
parent
662adbb41b
commit
dc288044ef
@ -42,6 +42,8 @@ namespace PlasmaQuick
|
|||||||
|
|
||||||
QHash<QObject *, AppletQuickItem *> AppletQuickItemPrivate::s_rootObjects = QHash<QObject *, AppletQuickItem *>();
|
QHash<QObject *, AppletQuickItem *> AppletQuickItemPrivate::s_rootObjects = QHash<QObject *, AppletQuickItem *>();
|
||||||
|
|
||||||
|
QQmlEngine *AppletQuickItemPrivate::s_engine = 0;
|
||||||
|
|
||||||
AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickItem *item)
|
AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickItem *item)
|
||||||
: q(item),
|
: q(item),
|
||||||
switchWidth(-1),
|
switchWidth(-1),
|
||||||
@ -49,6 +51,9 @@ AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickIte
|
|||||||
applet(a),
|
applet(a),
|
||||||
expanded(false)
|
expanded(false)
|
||||||
{
|
{
|
||||||
|
if (!s_engine) {
|
||||||
|
s_engine = new QQmlEngine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletQuickItemPrivate::connectLayoutAttached(QObject *item)
|
void AppletQuickItemPrivate::connectLayoutAttached(QObject *item)
|
||||||
@ -378,7 +383,8 @@ AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent)
|
|||||||
connect(&d->compactRepresentationCheckTimer, SIGNAL(timeout()),
|
connect(&d->compactRepresentationCheckTimer, SIGNAL(timeout()),
|
||||||
this, SLOT(compactRepresentationCheck()));
|
this, SLOT(compactRepresentationCheck()));
|
||||||
|
|
||||||
d->qmlObject = new KDeclarative::QmlObject(this);
|
QQmlContext *context = new QQmlContext(AppletQuickItemPrivate::s_engine->rootContext());
|
||||||
|
d->qmlObject = new KDeclarative::QmlObject(AppletQuickItemPrivate::s_engine, context, 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()) {
|
||||||
@ -402,7 +408,6 @@ AppletQuickItem::~AppletQuickItem()
|
|||||||
delete d->compactRepresentationExpanderItem;
|
delete d->compactRepresentationExpanderItem;
|
||||||
|
|
||||||
AppletQuickItemPrivate::s_rootObjects.remove(d->qmlObject->engine());
|
AppletQuickItemPrivate::s_rootObjects.remove(d->qmlObject->engine());
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object)
|
AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object)
|
||||||
@ -423,7 +428,8 @@ Plasma::Applet *AppletQuickItem::applet() const
|
|||||||
|
|
||||||
void AppletQuickItem::init()
|
void AppletQuickItem::init()
|
||||||
{
|
{
|
||||||
if (AppletQuickItemPrivate::s_rootObjects.contains(d->qmlObject->engine())) {
|
//FIXME: Plasmoid attached property should be fixed since can't be indexed by engine anymore
|
||||||
|
if (0&&AppletQuickItemPrivate::s_rootObjects.contains(d->qmlObject->engine())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +487,7 @@ void AppletQuickItem::init()
|
|||||||
d->applet->setLaunchErrorMessage(reason);
|
d->applet->setLaunchErrorMessage(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->rootContext()->setContextProperty("plasmoid", this);
|
d->qmlObject->rootContext()->setContextProperty("plasmoid", this);
|
||||||
|
|
||||||
//initialize size, so an useless resize less
|
//initialize size, so an useless resize less
|
||||||
QVariantHash initialProperties;
|
QVariantHash initialProperties;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <kdeclarative/kdeclarative.h>
|
#include <kdeclarative/kdeclarative.h>
|
||||||
|
|
||||||
@ -144,6 +145,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
qWarning() << "WARNING: Access denied for URL" << path << m_package.path();
|
qWarning() << "WARNING: Access denied for URL" << path << m_package.path();
|
||||||
|
return path;
|
||||||
return QUrl::fromLocalFile( allowedPaths.first() + "/org/kde/plasma/accessdenied/qmldir");
|
return QUrl::fromLocalFile( allowedPaths.first() + "/org/kde/plasma/accessdenied/qmldir");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
#include <qquickitem.h>
|
#include <qquickitem.h>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
@ -103,6 +104,7 @@ public:
|
|||||||
bool expanded : 1;
|
bool expanded : 1;
|
||||||
|
|
||||||
static QHash<QObject *, AppletQuickItem *> s_rootObjects;
|
static QHash<QObject *, AppletQuickItem *> s_rootObjects;
|
||||||
|
static QQmlEngine *s_engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user