unbreak update() method

svn path=/trunk/KDE/kdebase/runtime/; revision=1217812
This commit is contained in:
Aaron J. Seigo 2011-01-28 19:44:35 +00:00
parent e22d1c5b2a
commit 906b55c050
3 changed files with 31 additions and 21 deletions

View File

@ -124,25 +124,21 @@ void AppletInterface::setConfigurationRequired(bool needsConfiguring, const QStr
m_appletScriptEngine->setConfigurationRequired(needsConfiguring, reason);
}
#ifdef USE_JS_SCRIPTENGINE
void AppletInterface::update(const QRectF &rect)
void JsAppletInterface::update(const QRectF &rect)
{
applet()->update(rect);
}
QGraphicsLayout *AppletInterface::layout() const
QGraphicsLayout *JsAppletInterface::layout() const
{
return applet()->layout();
}
void AppletInterface::setLayout(QGraphicsLayout *layout)
void JsAppletInterface::setLayout(QGraphicsLayout *layout)
{
applet()->setLayout(layout);
}
#endif
QString AppletInterface::activeConfig() const
{
return m_currentConfig.isEmpty() ? "main" : m_currentConfig;
@ -379,7 +375,7 @@ void AppletInterface::gc()
PopupAppletInterface::PopupAppletInterface(AbstractJsAppletScript *parent)
: AppletInterface(parent)
: POPUPAPPLETSUPERCLASS(parent)
{
}

View File

@ -76,10 +76,6 @@ class AppletInterface : public QObject
Q_PROPERTY(int apiVersion READ apiVersion CONSTANT)
Q_PROPERTY(QRectF rect READ rect)
Q_PROPERTY(QSizeF size READ size)
#ifdef USE_JS_SCRIPTENGINE
Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout)
Q_PROPERTY(QObject *sender READ sender)
#endif
public:
AppletInterface(AbstractJsAppletScript *parent);
@ -276,12 +272,6 @@ enum IntervalAlignment {
Q_INVOKABLE Plasma::Extender *extender() const;
#ifdef USE_JS_SCRIPTENGINE
Q_INVOKABLE void update(const QRectF &rect = QRectF());
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *);
#endif
Plasma::DataEngine *dataEngine(const QString &name);
QList<QAction*> contextualActions() const;
@ -311,7 +301,29 @@ private:
QMap<QString, Plasma::ConfigLoader*> m_configs;
};
class PopupAppletInterface : public AppletInterface
class JsAppletInterface : public AppletInterface
{
Q_OBJECT
Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout)
Q_PROPERTY(QObject *sender READ sender)
public:
JsAppletInterface(AbstractJsAppletScript *parent)
: AppletInterface(parent)
{
}
Q_INVOKABLE void update(const QRectF &rect = QRectF());
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *);
};
#ifdef USE_JS_SCRIPTENGINE
#define POPUPAPPLETSUPERCLASS JsAppletInterface
#else
#define POPUPAPPLETSUPERCLASS AppletInterface
#endif
class PopupAppletInterface : public POPUPAPPLETSUPERCLASS
{
Q_OBJECT
Q_PROPERTY(QIcon popupIcon READ popupIcon WRITE setPopupIcon)

View File

@ -55,6 +55,8 @@
#include <Plasma/Svg>
#include <Plasma/VideoWidget>
#define USE_JS_SCRIPTENGINE
#include "appletauthorization.h"
#include "appletinterface.h"
#include "scriptenv.h"
@ -511,8 +513,8 @@ void SimpleJavaScriptApplet::setupObjects()
// Expose applet interface
const bool isPopupApplet = qobject_cast<Plasma::PopupApplet *>(applet());
m_interface = isPopupApplet ? new PopupAppletInterface(this) : new AppletInterface(this);
m_self = m_engine->newQObject(m_interface);
m_interface = isPopupApplet ? new PopupAppletInterface(this) : new JsAppletInterface(this);
m_self = m_engine->newQObject(m_interface, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
m_env->addMainObjectProperties(m_self);
m_self.setScope(global);
global.setProperty("plasmoid", m_self);