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

List:       kde-commits
Subject:    kdebase/kicker/applets/lockout
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2003-08-23 1:33:56
[Download RAW message or body]

CVS commit by aseigo: 

proper size switching and choosing


  M +26 -29    lockout.cpp   1.17
  M +1 -0      lockout.h   1.3


--- kdebase/kicker/applets/lockout/lockout.cpp  #1.16:1.17
@@ -110,17 +110,24 @@ Lockout::~Lockout()
 // having a size of 44. So we rather cut those 2 pixels instead of changing
 // direction and wasting a lot of space.
-int Lockout::widthForHeight( int height ) const
+void Lockout::checkLayout( int height ) const
 {
     QSize s = minimumSizeHint();
-    if ( layout->direction() == QBoxLayout::LeftToRight &&
-         s.width() -2 <= height ) {
+    QBoxLayout::Direction direction = layout->direction();
+
+    if ( direction == QBoxLayout::LeftToRight &&
+         ( ( orientation() == Vertical   && s.width() - 2 >= height ) ||
+           ( orientation() == Horizontal && s.width() - 2 < height ) ) ) {
         layout->setDirection( QBoxLayout::TopToBottom );
     }
-
-    else if ( layout->direction() == QBoxLayout::TopToBottom &&
-              s.height() -2 > height ) {
+    else if ( direction == QBoxLayout::TopToBottom &&
+              ( ( orientation() == Vertical   && s.height() - 2 < height ) ||
+                ( orientation() == Horizontal && s.height() - 2 >= height ) ) ) {
         layout->setDirection( QBoxLayout::LeftToRight );
     }
+}
 
+int Lockout::widthForHeight( int height ) const
+{
+    checkLayout( height );
     return sizeHint().width();
 }
@@ -128,15 +135,5 @@ int Lockout::widthForHeight( int height 
 int Lockout::heightForWidth( int width ) const
 {
-    QSize s = minimumSizeHint();
-    if ( layout->direction() == QBoxLayout::TopToBottom &&
-         s.height() -2 <= width ) {
-        layout->setDirection( QBoxLayout::LeftToRight );
-    }
-
-    else if ( layout->direction() == QBoxLayout::LeftToRight &&
-         s.width() -2 > width ) {
-        layout->setDirection( QBoxLayout::TopToBottom );
-    }
-
+    checkLayout( width );
     return sizeHint().height();
 }

--- kdebase/kicker/applets/lockout/lockout.h  #1.2:1.3
@@ -54,4 +54,5 @@ private slots:
 private:
     void propagateMouseEvent( QMouseEvent * );
+    void checkLayout( int height ) const;
 
     TrayButton *lockButton, *logoutButton;


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

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