package is no longer needed, use the local package if there is one, falling back to the main one when it isn't. overhead is negligable (measured it)

svn path=/trunk/KDE/kdebase/runtime/; revision=1171490
This commit is contained in:
Aaron J. Seigo 2010-09-04 00:06:18 +00:00
parent d07baae46f
commit de6c425f17
2 changed files with 32 additions and 10 deletions

View File

@ -140,7 +140,7 @@ void AppletInterface::setActiveConfig(const QString &name)
Plasma::ConfigLoader *loader = m_configs.value(name, 0);
if (!loader) {
QString path = applet()->package()->filePath("config", name + ".xml");
QString path = file("config", name + ".xml");
if (path.isEmpty()) {
return;
}
@ -195,17 +195,22 @@ QScriptValue AppletInterface::readConfig(const QString &entry) const
QString AppletInterface::file(const QString &fileType)
{
return m_appletScriptEngine->package()->filePath(fileType.toLocal8Bit().constData());
return file(fileType.toLocal8Bit().constData(), QString());
}
QString AppletInterface::file(const QString &fileType, const QString &filePath)
{
return m_appletScriptEngine->package()->filePath(fileType.toLocal8Bit().constData(), filePath);
}
QScriptContext *c = context();
if (c && c->parentContext()) {
QScriptValue v = c->parentContext()->activationObject().property("__plasma_package");
//kDebug() << "variant in parent context?" << v.isVariant() << t.restart();
if (v.isVariant()) {
return v.toVariant().value<Plasma::Package>().filePath(fileType.toLocal8Bit().constData(), filePath);
//kDebug() << "path to package is" << p.path();
}
}
const Plasma::Package *AppletInterface::package() const
{
return m_appletScriptEngine->package();
return m_appletScriptEngine->package()->filePath(fileType.toLocal8Bit().constData(), filePath);
}
QList<QAction*> AppletInterface::contextualActions() const
@ -333,7 +338,24 @@ int AppletInterface::apiVersion() const
bool AppletInterface::include(const QString &script)
{
const QString path = package()->filePath("scripts", script);
QString path;
/*
QScriptContext *c = context();
if (c && c->parentContext()) {
QScriptValue v = c->parentContext()->activationObject().property("__plasma_package");
//kDebug() << "variant in parent context?" << v.isVariant() << t.restart();
if (v.isVariant()) {
Plasma::Package p = v.toVariant().value<Plasma::Package>();
//kDebug() << "path to package is" << p.path();
path = p.filePath("scripts", script);
}
}
*/
if (path.isEmpty()) {
kDebug() << "kicking it old school";
path = file("scripts", script);
}
if (path.isEmpty()) {
return false;
}

View File

@ -25,6 +25,7 @@
#include <QObject>
#include <QSizePolicy>
#include <QScriptValue>
#include <QScriptable>
#include <Plasma/Applet>
#include <Plasma/PopupApplet>
@ -45,7 +46,7 @@ namespace Plasma
class Extender;
} // namespace Plasa
class AppletInterface : public QObject
class AppletInterface : public QObject, QScriptable
{
Q_OBJECT
Q_ENUMS(FormFactor)
@ -277,7 +278,6 @@ enum IntervalAlignment {
Plasma::DataEngine *dataEngine(const QString &name);
const Plasma::Package *package() const;
QList<QAction*> contextualActions() const;
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *);