[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/libs/plasma
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2008-03-02 21:37:00
Message-ID: 1204493820.884370.15880.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 781447 by sebsauer:

redirect also the constraintsUpdated(), contextActions() and \
showConfigurationInterface() methods to the scriptengine.



 M  +7 -1      applet.cpp  
 M  +14 -0     scripting/appletscript.cpp  
 M  +34 -2     scripting/appletscript.h  


--- trunk/KDE/kdebase/workspace/libs/plasma/applet.cpp #781446:781447
@@ -518,6 +518,9 @@
     //      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 @@
 QList<QAction*> Applet::contextActions()
 {
     //kDebug() << "empty context actions";
-    return QList<QAction*>();
+    return d->script ? d->script->contextActions() : QList<QAction*>();
 }
 
 QColor Applet::color() const
@@ -1274,6 +1277,9 @@
         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,
--- trunk/KDE/kdebase/workspace/libs/plasma/scripting/appletscript.cpp #781446:781447
@@ -75,6 +75,20 @@
     return QSizeF();
 }
 
+void AppletScript::constraintsUpdated(Plasma::Constraints constraints)
+{
+    Q_UNUSED(constraints);
+}
+
+QList<QAction*> AppletScript::contextActions()
+{
+    return QList<QAction*>();
+}
+
+void AppletScript::showConfigurationInterface()
+{
+}
+
 DataEngine* AppletScript::dataEngine(const QString &engine) const
 {
     Q_ASSERT(d->applet);
--- trunk/KDE/kdebase/workspace/libs/plasma/scripting/appletscript.h #781446:781447
@@ -30,6 +30,7 @@
 #include <plasma/plasma_export.h>
 #include <plasma/scripting/scriptengine.h>
 
+class QAction;
 class QPainter;
 class QStyleOptionGraphicsItem;
 
@@ -66,7 +67,7 @@
      *
      * @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 @@
      */
     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<QAction*> contextActions();
+
+public Q_SLOTS:
+
+    /**
+     * Show a configuration dialog.
+     */
+    virtual void showConfigurationInterface();
+
 protected:
     /**
      * @arg engine name of the engine
@@ -88,7 +120,7 @@
 
     /**
      * @return absolute path to the main script file for this plasmoid
-     **/
+     */
     QString mainScript() const;
 
     /**


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic