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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/lib
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2007-05-31 22:40:38
Message-ID: 1180651238.677283.6387.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 670285 by aseigo:

applets are no aware of their constraints. the simple solution is often the best one.


 M  +13 -0     applet.cpp  
 M  +17 -0     applet.h  
 M  +1 -0      corona.cpp  
 M  +6 -0      corona.h  


--- trunk/KDE/kdebase/workspace/plasma/lib/applet.cpp #670284:670285
@@ -28,6 +28,8 @@
 #include <KStandardDirs>
 #include <KService>
 #include <KServiceTypeTrader>
+
+#include "corona.h"
 #include "dataenginemanager.h"
 
 namespace Plasma
@@ -135,8 +137,19 @@
 
 void Applet::constraintsUpdated()
 {
+    kDebug() << "constraints are FormFactor: " << formFactor() << ", Location: " << location() << endl;
 }
 
+FormFactor Applet::formFactor() const
+{
+    return static_cast<Corona*>(scene())->formFactor();
+}
+
+Location Applet::location() const
+{
+    return static_cast<Corona*>(scene())->location();
+}
+
 QString Applet::globalName() const
 {
     return d->appletDescription->service()->library();
--- trunk/KDE/kdebase/workspace/plasma/lib/applet.h #670284:670285
@@ -98,17 +98,34 @@
          * 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.
+         *
          * @property constraint
          */
         virtual void constraintsUpdated();
 
         /**
+         * Returns the current form factor the applet is being displayed in.
+         * @see Plasma::FormFactor
+         */
+        FormFactor formFactor() const;
+
+        /**
+         * Returns the location of the scene which is displaying applet.
+         * @see Plasma::Location
+         */
+        Location location() const;
+
+        /**
          * Returns a list of all known applets in a hash keyed by a unique
          * identifier for each applet
          *
          * @return list of applets
          **/
         static KPluginInfo::List knownApplets();
+
         /**
          * Reimplement this slot to show a configuration dialog and let the user
          * play with the plasmoid options. Called when the user selects the configure entry
--- trunk/KDE/kdebase/workspace/plasma/lib/corona.cpp #670284:670285
@@ -198,6 +198,7 @@
     Applet* applet = Applet::loadApplet(name);
     if (applet) {
         addItem(applet);
+        //applet->constraintsUpdated();
         d->applets << applet;
     } else {
         kDebug() << "Plasmoid " << name << " could not be loaded." << endl;
--- trunk/KDE/kdebase/workspace/plasma/lib/corona.h #670284:670285
@@ -73,6 +73,12 @@
     void setFormFactor(FormFactor formFactor);
 
 public Q_SLOTS:
+    /**
+     * Adds a plasmoid applet to the scene
+     *
+     * @param name the plugin name for the applet, as given by 
+     *        KPluginInfo::pluginName()
+     */
     void addPlasmoid(const QString& name);
 
 protected:
[prev in list] [next in list] [prev in thread] [next in thread] 

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