summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qcommandlinkbutton.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp
index e8fe299..d3b5869 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/gui/widgets/qcommandlinkbutton.cpp
@@ -118,7 +118,7 @@ public:
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 @@ QFont QCommandLinkButtonPrivate::descriptionFont() const
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 @@ QSize QCommandLinkButton::minimumSizeHint() const
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 QCommandLinkButton::heightForWidth(int width) const
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 */