From ae6880bc155522c978235d47cd81b0063c5f68ab Mon Sep 17 00:00:00 2001 From: Sebastian Sauer Date: Sun, 2 Mar 2008 21:36:59 +0000 Subject: [PATCH] redirect also the constraintsUpdated(), contextActions() and showConfigurationInterface() methods to the scriptengine. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=781447 --- applet.cpp | 8 +++++++- scripting/appletscript.cpp | 14 ++++++++++++++ scripting/appletscript.h | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/applet.cpp b/applet.cpp index 654ae80d4..023e29f75 100644 --- a/applet.cpp +++ b/applet.cpp @@ -518,6 +518,9 @@ void Applet::constraintsUpdated(Plasma::Constraints constraints) // INSTEAD put such code into flushUpdatedConstraints Q_UNUSED(constraints) //kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location(); + if (d->script) { + d->script->constraintsUpdated(constraints); + } } QString Applet::name() const @@ -848,7 +851,7 @@ Qt::Orientations Applet::expandingDirections() const QList Applet::contextActions() { //kDebug() << "empty context actions"; - return QList(); + return d->script ? d->script->contextActions() : QList(); } QColor Applet::color() const @@ -1274,6 +1277,9 @@ void Applet::showConfigurationInterface() dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name())); dialog->show(); } + else if(d->script) { + d->script->showConfigurationInterface(); + } } KPluginInfo::List Applet::knownApplets(const QString &category, diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index 214294f9d..2fe620eb7 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -75,6 +75,20 @@ QSizeF AppletScript::size() const return QSizeF(); } +void AppletScript::constraintsUpdated(Plasma::Constraints constraints) +{ + Q_UNUSED(constraints); +} + +QList AppletScript::contextActions() +{ + return QList(); +} + +void AppletScript::showConfigurationInterface() +{ +} + DataEngine* AppletScript::dataEngine(const QString &engine) const { Q_ASSERT(d->applet); diff --git a/scripting/appletscript.h b/scripting/appletscript.h index defdc8816..a30841747 100644 --- a/scripting/appletscript.h +++ b/scripting/appletscript.h @@ -30,6 +30,7 @@ #include #include +class QAction; class QPainter; class QStyleOptionGraphicsItem; @@ -66,7 +67,7 @@ public: * * @param painter the QPainter to use * @param option the style option containing such flags as selection, level of detail, etc - **/ + */ virtual void paintInterface(QPainter* painter, const QStyleOptionGraphicsItem* option, const QRect &contentsRect); @@ -77,8 +78,39 @@ public: */ virtual QSizeF contentSizeHint() const; + /** + * Returns the area within which contents can be painted. + **/ Q_INVOKABLE QSizeF size() const; + /** + * Called when any of the geometry constraints have been updated. + * + * This is always called prior to painting and should be used as an + * opportunity to layout the widget, calculate sizings, etc. + * + * Do not call update() from this method; an update() will be triggered + * at the appropriate time for the applet. + * + * @param constraints the type of constraints that were updated + */ + virtual void constraintsUpdated(Plasma::Constraints constraints); + + /** + * Returns a list of context-related QAction instances. + * + * @return A list of actions. The default implementation returns an + * empty list. + */ + virtual QList contextActions(); + +public Q_SLOTS: + + /** + * Show a configuration dialog. + */ + virtual void showConfigurationInterface(); + protected: /** * @arg engine name of the engine @@ -88,7 +120,7 @@ protected: /** * @return absolute path to the main script file for this plasmoid - **/ + */ QString mainScript() const; /**