diff options
author | John Brooks <special@dereferenced.net> | 2010-06-29 12:01:38 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2010-06-29 12:01:56 (GMT) |
commit | 43498a0994eb949e94e9635be68b88567e55831c (patch) | |
tree | 0ac4ced709874a42b0c49a18b8a4bffd7bf13cda /src/gui | |
parent | 704f8c2ccde7a01d5ecc6c13ff5cc1d5f5b09519 (diff) | |
download | Qt-43498a0994eb949e94e9635be68b88567e55831c.zip Qt-43498a0994eb949e94e9635be68b88567e55831c.tar.gz Qt-43498a0994eb949e94e9635be68b88567e55831c.tar.bz2 |
Improved QCommandLinkButton's vertical spacing
When no description is present, the text is centered alongside the
icon. The top and bottom margins are now an equal 10px.
Merge-request: 2424
Reviewed-by: Jens Bache-Wiig <jbache@trolltech.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/qcommandlinkbutton.cpp | 18 |
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 */ |