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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/digital-clock
From:       Sebastian Kügler <sebas () kde ! org>
Date:       2008-11-17 3:14:31
Message-ID: 1226891671.767563.8914.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 885323 by sebas:

Correctly update the size when the date string has changed

Until now, it would lag one update (which can be the initial one giving
a bad first impression) behind when determining its minimumwidth in the
panel. It correctly takes as much space as needed right after startup
and also after config changes.
BUG:166883

 M  +10 -2     clock.cpp  
 M  +1 -0      clock.h  


--- trunk/KDE/kdebase/workspace/plasma/applets/digital-clock/clock.cpp #885322:885323
@@ -56,6 +56,7 @@
       m_showDay(false),
       m_showSeconds(false),
       m_showTimezone(false),
+      m_dateString(0),
       m_layout(0)
 {
     KGlobal::locale()->insertCatalog("libplasmaclock");
@@ -116,7 +117,9 @@
     if (formFactor() == Plasma::Horizontal) {
         // We have a fixed height, set some sensible width
         if (m_showDate || m_showTimezone) {
-            setMinimumWidth(qMax(m_dateRect.width(), (int)(contentsRect().height() * aspect)));
+            QFontMetricsF metrics(KGlobalSettings::smallestReadableFont());
+            int w = (int)metrics.size(Qt::TextSingleLine, m_dateString).width();
+            setMinimumWidth(qMax(w, (int)(contentsRect().height() * aspect)));
         } else {
             setMinimumWidth((int)(contentsRect().height() * aspect));
         }
@@ -281,7 +284,12 @@
             } else if (m_showTimezone) {
                 dateString = prettyTimezone();
             }
-
+            if (m_dateString != dateString) {
+                // If this string has changed (for example due to changes in the config
+                // we have to reset the sizing of the applet
+                m_dateString = dateString;
+                updateSize();
+            }
             // Check sizes
             QFont f = KGlobalSettings::smallestReadableFont();
             f.setPointSizeF(qMax(contentsRect.height()/10, f.pointSize()));
--- trunk/KDE/kdebase/workspace/plasma/applets/digital-clock/clock.h #885322:885323
@@ -73,6 +73,7 @@
 
         QTime m_time;
         QDate m_date;
+        QString m_dateString;
         QVBoxLayout *m_layout;
         QTime m_lastTimeSeen;
         QPixmap m_toolTipIcon;
[prev in list] [next in list] [prev in thread] [next in thread] 

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