summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-27 12:50:13 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-27 14:54:19 (GMT)
commit8dd8090f5f5c4bfddef87d9244a353f42ddf9db4 (patch)
tree93a66c1cc322d3c63118922d8a16a078c8614127 /src/gui
parente534abc781cb5751736d24a1a5610370c243b519 (diff)
downloadQt-8dd8090f5f5c4bfddef87d9244a353f42ddf9db4.zip
Qt-8dd8090f5f5c4bfddef87d9244a353f42ddf9db4.tar.gz
Qt-8dd8090f5f5c4bfddef87d9244a353f42ddf9db4.tar.bz2
QTabBar: fix text being croped when there is an icon on the tab
By making sure the computation in QTabBar::tabSizeHint and QCommonStylePrivate::tabLayout are the same Reviewed-by: jbache
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qcommonstyle.cpp22
-rw-r--r--src/gui/widgets/qtabbar.cpp9
2 files changed, 12 insertions, 19 deletions
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index ccdce28..9dee6eb 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1194,6 +1194,11 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget
tr.setLeft(tr.left() + 6 + 2 +
(verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width()));
}
+ // right widget
+ if (!opt->rightButtonSize.isEmpty()) {
+ tr.setRight(tr.right() - 6 - 2 -
+ (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width()));
+ }
// icon
if (!opt->icon.isNull()) {
@@ -1206,24 +1211,11 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget
(opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled,
(opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off );
- int left = opt->rect.left();
- int offset = 4;
- if (opt->leftButtonSize.isEmpty())
- offset += 2;
- else
- left += opt->leftButtonSize.width() + (6 + 2) + 2;
-
- *iconRect = QRect(left + offset, tr.center().y() - tabIconSize.height() / 2,
+ *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2,
tabIconSize.width(), tabIconSize .height());
if (!verticalTabs)
*iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect);
- tr.setLeft(tr.left() + tabIconSize.width() + offset + 2);
- }
-
- // right widget
- if (!opt->rightButtonSize.isEmpty()) {
- tr.setRight(tr.right() - 6 - 2 -
- (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width()));
+ tr.setLeft(tr.left() + tabIconSize.width() + 4);
}
if (!verticalTabs)
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index d8246c8..f3775c2 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1293,6 +1293,7 @@ QSize QTabBarPrivate::minimumTabSizeHint(int index)
*/
QSize QTabBar::tabSizeHint(int index) const
{
+ //Note: this must match with the computations in QCommonStylePrivate::tabLayout
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
QStyleOptionTabV3 opt;
@@ -1309,18 +1310,18 @@ QSize QTabBar::tabSizeHint(int index) const
int widgetWidth = 0;
int widgetHeight = 0;
int padding = 0;
- if (opt.leftButtonSize.isValid()) {
+ if (!opt.leftButtonSize.isEmpty()) {
padding += 6 + 2;
widgetWidth += opt.leftButtonSize.width();
widgetHeight += opt.leftButtonSize.height();
}
- if (opt.rightButtonSize.isValid()) {
+ if (!opt.rightButtonSize.isEmpty()) {
padding += 6 + 2;
widgetWidth += opt.rightButtonSize.width();
widgetHeight += opt.rightButtonSize.height();
}
- if (opt.iconSize.isValid())
- padding += 2;
+ if (!opt.icon.isNull())
+ padding += 4;
QSize csz;
if (verticalTabs(d->shape)) {