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

List:       kde-commits
Subject:    playground/base/plasma/applets/train-clock
From:       Sebastian Kügler <sebas () kde ! org>
Date:       2008-06-27 1:13:47
Message-ID: 1214529227.947888.27111.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 824980 by sebas:

Fix up sizing a bit more. THere's still some race condition in
there, it needs an extra update at some point.

This patch makes it size in the first place, though.


 M  +14 -6     clock.cpp  


--- trunk/playground/base/plasma/applets/train-clock/clock.cpp #824979:824980
@@ -119,17 +119,28 @@
 
 void Clock::constraintsEvent(Plasma::Constraints constraints)
 {
+    m_margin = qRound(contentsRect().height() / 20);
     if (constraints & Plasma::FormFactorConstraint) {
         if (formFactor() == Plasma::Vertical ||
             formFactor() == Plasma::Horizontal) {
+            m_margin = 0;
             kDebug() << "Horizontal or Vertical FormFactor";
         } else {
             kDebug() << "Other FormFactor";
         }
     }
     if (constraints & Plasma::SizeConstraint) {
+        int aspect = 3.1;
+        if (formFactor() == Plasma::Horizontal) {
+            // We have a fixed height, set some sensible width
+            setMinimumWidth(contentsRect().height() * aspect);
+        } else if (formFactor() == Plasma::Vertical) {
+            // We have a fixed width, set some sensible height
+            setMinimumHeight((int)contentsRect().width() / aspect);
+        }
         updateSizes();
     }
+    updateSizes();
 }
 
 void Clock::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
@@ -356,11 +367,7 @@
     // Plasma::Applet::shouldConserveResources() is true
     Q_UNUSED(option);
     if (m_time.isValid() && m_date.isValid()) {
-        //if (m_contentSize != geometry().size()) {
-        //    updateSizes();
-        //}
 
-        // *** First, set some properties!
         p->setFont (KGlobalSettings::smallestReadableFont());
         p->setPen(QPen(m_fgColor));
         p->setRenderHint(QPainter::SmoothPixmapTransform);
@@ -390,12 +397,13 @@
 
             p->drawText(m_dateRect, dateString,
                         QTextOption (Qt::AlignCenter));
+            kDebug() << "Painting" << dateString;
         }
 
         // Conditionally paint panel Background
-        if (formFactor() == Plasma::Horizontal) {
+        //if (formFactor() == Plasma::Horizontal) {
             m_theme->paint(p, contentsRect, "panel-bg");
-        }
+        //}
 
         m_theme->resize(m_timeRect.width(), m_timeRect.height());
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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