src/gui/widgets/qcommandlinkbutton.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
--- a/src/gui/widgets/qcommandlinkbutton.cpp	Tue Jul 06 15:10:48 2010 +0300
+++ b/src/gui/widgets/qcommandlinkbutton.cpp	Wed Aug 18 10:37:55 2010 +0300
@@ -118,7 +118,7 @@
     int topMargin() const { return 10; }
     int leftMargin() const { return 7; }
     int rightMargin() const { return 4; }
-    int bottomMargin() const { return 4; }
+    int bottomMargin() const { return 10; }
 
     QString description;
     QColor currentColor;
@@ -174,8 +174,15 @@
 QRect QCommandLinkButtonPrivate::titleRect() const
 {
     Q_Q(const QCommandLinkButton);
-    return q->rect().adjusted(textOffset(), topMargin(),
-                              -rightMargin(), 0);
+    QRect r = q->rect().adjusted(textOffset(), topMargin(), -rightMargin(), 0);
+    if (description.isEmpty())
+    {
+        QFontMetrics fm(titleFont());
+        r.setTop(r.top() + qMax(0, (q->icon().actualSize(q->iconSize()).height()
+                 - fm.height()) / 2));
+    }
+
+    return r;
 }
 
 QRect QCommandLinkButtonPrivate::descriptionRect() const
@@ -254,7 +261,7 @@
     Q_D(const QCommandLinkButton);
     QSize size = sizeHint();
     int minimumHeight = qMax(d->descriptionOffset() + d->bottomMargin(),
-                             iconSize().height() + d->topMargin());
+                             icon().actualSize(iconSize()).height() + d->topMargin());
     size.setHeight(minimumHeight);
     return size;
 }
@@ -328,7 +335,8 @@
     int heightWithoutDescription = d->descriptionOffset() + d->bottomMargin();
     // find the width available for the description area
     return qMax(heightWithoutDescription + d->descriptionHeight(width),
-                iconSize().height() + d->topMargin() + d->bottomMargin());
+                icon().actualSize(iconSize()).height() + d->topMargin() +
+                d->bottomMargin());
 }
 
 /*! \reimp */