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

List:       kde-core-devel
Subject:    [PATCH] BIC changes to KPanelApplet
From:       John Firebaugh <jfirebaugh () kde ! org>
Date:       2002-03-08 17:20:11
[Download RAW message or body]

Fredrik Höglund noted that the taskbar applet does not republish icon 
geometries when changing the panel's alignment, but not position, via dnd. 
This is because applets are not notified when the alignment changes, only 
position. I want to fix this now since it requires BIC. The following patch 
does so and sets the stage for cleaning up the notification for arrangement 
changes. It is source, but not binary compatible. We can decide for KDE 4 how 
much source compatibility to keep -- the comments indicate the maximum that 
would be removed.

Note that it requires changes to kdebase/kicker that I haven't made yet.

-John
["kpanelapplet.diff" (text/x-diff)]

Index: kpanelapplet.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kpanelapplet.cpp,v
retrieving revision 1.20
diff -u -3 -p -r1.20 kpanelapplet.cpp
--- kpanelapplet.cpp	2002/03/04 00:51:50	1.20
+++ kpanelapplet.cpp	2002/03/08 17:06:17
@@ -30,8 +30,8 @@ KPanelApplet::KPanelApplet(const QString
                            int actions, QWidget *parent, const char *name, WFlags f)
   : QFrame(parent, name, f)
   , _type(type)
-  , _orient( Horizontal )
-  , _dir(Up)
+  , _position( pBottom )
+  , _alignment( LeftTop )
   , _config(0)
   , _actions(actions)
 {
@@ -50,20 +50,46 @@ KPanelApplet::~KPanelApplet()
   delete _config;
 }
 
-void KPanelApplet::slotSetOrientation(Orientation o)
+void KPanelApplet::slotSetArrangement( Position p, Alignment a )
 {
-  _orient = o;
-  orientationChange( o );
+  if( _position == p && _alignment == a )
+    return;
+
+  _position = p;
+  _alignment = a;
+
+  arrangementChanged( p, a );
+}
+
+// FIXME: Remove implementation for KDE 4
+void KPanelApplet::arrangementChanged( Position, Alignment )
+{
+  orientationChange( orientation() );
   QResizeEvent e( size(), size() );
   resizeEvent( &e );
+  popupDirectionChange( popupDirection() );
 }
 
-void KPanelApplet::slotSetPopupDirection(Direction d)
+Qt::Orientation KPanelApplet::orientation() const
 {
-  _dir = d;
-  popupDirectionChange( d );
+  if( _position == pTop || _position == pBottom ) {
+    return Horizontal;
+  } else {
+    return Vertical;
+  }
 }
 
+// FIXME: Remove for KDE 4
+KPanelApplet::Direction KPanelApplet::popupDirection()
+{
+    switch( _position ) {
+    case pTop:     return Down;
+    case pRight:   return Left;
+    case pLeft:    return Right;
+    default:
+    case pBottom:  return Up;
+    }
+}
 
 void KPanelApplet::action( Action a )
 {
Index: kpanelapplet.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kpanelapplet.h,v
retrieving revision 1.25
diff -u -3 -p -r1.25 kpanelapplet.h
--- kpanelapplet.h	2002/03/04 00:51:51	1.25
+++ kpanelapplet.h	2002/03/08 17:06:17
@@ -108,6 +108,10 @@ public:
      * which items the context menu over the applet handle contains.
      */
     enum Action { About = 1, Help = 2, Preferences = 4, ReportBug = 8 };
+    // FIXME: Remove 'p' from element names for KDE 4.
+    enum Position { pLeft = 0, pRight, pTop, pBottom };
+    enum Alignment { LeftTop = 0, Center, RightBottom };
+    // FIXME: Remove for KDE 4.
     enum Direction { Up = 0, Down, Left, Right };
 
     /**
@@ -232,13 +236,8 @@ public slots:
     /**
      * Don't reimplement, this is used internally
      **/
-    void slotSetOrientation(Orientation o);
+    void slotSetArrangement( Position p, Alignment a );
 
-    /**
-     * Don't reimplement, this is used internally
-     **/
-    void slotSetPopupDirection(Direction d);
-
 protected:
 
     /**
@@ -281,35 +280,51 @@ protected:
     /**
      * @return the applet's orientation. (horizontal or vertical)
      **/
-    Orientation orientation() const { return _orient; }
-
+    Orientation orientation() const;
 
     /**
      * The orientation changed to @p orientation. Reimplement this
      * change handler in order to adjust the look of your applet.
+     *
+     * @deprecated Reimplement arrangementChanged instead.
      **/
+    // FIXME: Remove for KDE 4
     virtual void orientationChange( Orientation /* orientation*/) {}
 
     /**
      * You may need this if you want to popup menus at the right position.
      *
      * See @ref  popupDirectionChange()
+     *
+     * @deprecated Use position() instead.
      **/
-    Direction popupDirection() const { return _dir; }
-
+    // FIXME: Remove for KDE 4
+    Direction popupDirection();
 
     /**
      * The popup direction changed to @p direction. Reimplement this
      * change handler in order to adjust the look of your applet.
+     *
+     * @deprecated Reimplement arrangementChanged instead.
      **/
+    // FIXME: Remove for KDE 4
     virtual void popupDirectionChange( Direction /*direction*/ ) {}
 
+    Position position() const { return _position; }
+    Alignment alignment() const { return _alignment; }
 
+    /**
+     * The panel on which this applet resides has changed its
+     * arrangement. It is now at pos @p p and aligned @p a.
+     * Reimplement this change handler in order to adjust the
+     * look of your applet.
+     **/
+    virtual void arrangementChanged( Position p, Alignment a );
 
 private:
     Type         _type;
-    Orientation  _orient;
-    Direction    _dir;
+    Position     _position;
+    Alignment    _alignment;
     KConfig*     _config;
     int          _actions;
 protected:


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

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