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

List:       kde-commits
Subject:    KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib
From:       John Tapsell <john.tapsell () kdemail ! net>
Date:       2009-11-22 14:32:48
Message-ID: 1258900368.668996.4763.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1052808 by johnflux:

Improve the stability of resizing of label items
BUG:199434


 M  +26 -3     FancyPlotter.cc  


--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/FancyPlotter.cc \
#1052807:1052808 @@ -90,6 +90,27 @@
         QString mShortText;
         QString mLongText;
 };
+
+//This label is for QLabel's that change their sizeHint frequently, to prevent them \
from constantly resizing +class StableSizeLabel : public QLabel {
+  public:
+    StableSizeLabel() : QLabel() {
+    }
+    virtual QSize sizeHint() const {
+        QSize newSizeHint = QLabel::sizeHint();
+        if(mSizeHint.isEmpty() ||
+           newSizeHint.height() != mSizeHint.height() ||
+           newSizeHint.width() > mSizeHint.width() ||
+           newSizeHint.width() < 0.7 * mSizeHint.width()) {
+            mSizeHint = newSizeHint;
+            mSizeHint.setWidth(mSizeHint.width()*1.1); //Add 10% to keep it stable
+            return mSizeHint;
+        }
+        return mSizeHint;
+    }
+  private:
+    mutable QSize mSizeHint;
+};
 class FancyPlotterLabel : public QWidget {
   public:
     FancyPlotterLabel(QWidget *parent) : QWidget(parent) {
@@ -97,7 +118,7 @@
         layout->setContentsMargins(0,0,0,0);
         label = new MultiLengthLabel();
         layout->addWidget(label);
-        value = new QLabel();
+        value = new StableSizeLabel();
         layout->addWidget(value);
         layout->addStretch(1);
         setLayout(layout);
@@ -571,8 +592,10 @@
                         }
                     }
 
-                    if(sensor->maxValue != 0 && sensor->unit() != "%")
-                        lastValue = i18nc("%1 and %2 are sensor's last and maximum \
value", "%1 of %2", lastValue, mPlotter->valueAsString(sensor->maxValue, precision) \
); +                    if(sensor->maxValue != 0 && sensor->unit() != "%") {
+                        //Use a multi length string incase we do not have enough \
room +                        lastValue = i18n("%1 of %2" "\xc2\x9c" "%1", lastValue, \
mPlotter->valueAsString(sensor->maxValue, precision) ); +                    }
                 } else {
                     lastValue = i18n("Error");
                 }


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

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