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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/containments/panel
From:       Marco Martin <notmart () gmail ! com>
Date:       2009-06-12 11:11:53
Message-ID: 1244805113.539600.7200.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 980638 by mart:

when the panel is auto resized wait a bit before doing it again to
prevent autoresize loops
BUG: 188381


 M  +12 -1     panel.cpp  
 M  +2 -0      panel.h  


--- trunk/KDE/kdebase/workspace/plasma/containments/panel/panel.cpp #980637:980638
@@ -95,6 +95,7 @@
       m_addPanelAction(0),
       m_currentSize(QSize(Kephal::ScreenUtils::screenSize(screen()).width(), 35)),
       m_maskDirty(true),
+      m_canResize(true),
       m_spacerIndex(-1),
       m_spacer(0),
       m_lastSpace(0)
@@ -263,6 +264,11 @@
     }
 }
 
+void Panel::enableUpdateSize()
+{
+    m_canResize = true;
+}
+
 void Panel::layoutApplet(Plasma::Applet* applet, const QPointF &pos)
 {
     // this gets called whenever an applet is added, and we add it to our layout
@@ -340,6 +346,8 @@
         return;
     }
 
+    connect(applet, SIGNAL(sizeHintChanged(Qt::SizeHint)), this, SLOT(updateSize()));
+
     lay->removeItem(applet);
 
     //shrink the panel if possible
@@ -357,7 +365,7 @@
 {
     Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(sender());
 
-    if (applet) {
+    if (m_canResize && applet) {
         if (formFactor() == Plasma::Horizontal) {
             const int delta = applet->preferredWidth() - applet->size().width();
             //setting the preferred width when delta = 0 and preferredWidth() < minimumWidth()
@@ -373,6 +381,9 @@
         }
 
         resize(preferredSize());
+        //for a while we won't execute updateSize() again
+        m_canResize = false;
+        QTimer::singleShot(400, this, SLOT(enableUpdateSize()));
     }
 }
 
--- trunk/KDE/kdebase/workspace/plasma/containments/panel/panel.h #980637:980638
@@ -64,6 +64,7 @@
     void addPanel();
     void addPanel(const QString &plugin);
     void adjustLastSpace();
+    void enableUpdateSize();
 
 private:
     /**
@@ -85,6 +86,7 @@
     QSize m_currentSize;
     QRect m_lastViewGeom;
     bool m_maskDirty;
+    bool m_canResize;
     int m_spacerIndex;
     Spacer *m_spacer;
     QGraphicsWidget *m_lastSpace;
[prev in list] [next in list] [prev in thread] [next in thread] 

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