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

List:       kde-commits
Subject:    KDE/kdebase/workspace/libs/plasma/widgets
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-10-02 20:07:50
Message-ID: 1222978070.232061.17008.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 867107 by mart:

implement a sizehint that permits to use the frame just as a simple
header (i.e when empty return the height of the title font+margins)


 M  +19 -2     frame.cpp  
 M  +1 -0      frame.h  


--- trunk/KDE/kdebase/workspace/libs/plasma/widgets/frame.cpp #867106:867107
@@ -208,8 +208,8 @@
 
     if (!d->text.isNull()) {
         QFontMetricsF fm(QApplication::font());
-        QRectF textRect = contentsRect();
-        textRect.translate(0, -fm.height());
+        QRectF textRect = d->svg->contentsRect();
+        textRect.setHeight(fm.height());
         painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::TextColor));
         painter->drawText(textRect, Qt::AlignHCenter|Qt::AlignTop, d->text);
     }
@@ -232,6 +232,23 @@
     }
 }
 
+QSizeF Frame::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
+{
+    QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);
+
+    if (!d->image && !layout()) {
+        QFontMetricsF fm(QApplication::font());
+
+        qreal left, top, right, bottom;
+        d->svg->getMargins(left, top, right, bottom);
+
+        hint.setHeight(fm.height() + top + bottom);
+    }
+
+    return hint;
+}
+
+
 } // namespace Plasma
 
 #include <frame.moc>
--- trunk/KDE/kdebase/workspace/libs/plasma/widgets/frame.h #867106:867107
@@ -118,6 +118,7 @@
                QWidget *widget = 0);
 
     void resizeEvent(QGraphicsSceneResizeEvent *event);
+    QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const;
 
 private:
     FramePrivate * const d;
[prev in list] [next in list] [prev in thread] [next in thread] 

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