diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-20 10:16:31 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-20 10:37:45 (GMT) |
commit | 8fb9ed08c60b667737a9ae1b209da61fe9c67200 (patch) | |
tree | 31107a87808a53ff9abd779b20c6b4d0f090d116 | |
parent | d9fa92933ff6ff1afad342f7f94e37f810cf8176 (diff) | |
download | Qt-8fb9ed08c60b667737a9ae1b209da61fe9c67200.zip Qt-8fb9ed08c60b667737a9ae1b209da61fe9c67200.tar.gz Qt-8fb9ed08c60b667737a9ae1b209da61fe9c67200.tar.bz2 |
Fix for tabwidget usesScrollButton being overriden by stylesheet
Setting a stylesheet or reparenting a widget into a
widget using style sheet would cause the usesScrollButtons
to be reset. Instead we now keep the flag whenever
it has been explicitly set by the user rather than
querying from the style again.
Task-number: QTBUG-3370
Reviewed-by: jbache
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qtabbar_p.h | 3 | ||||
-rw-r--r-- | tests/auto/qtabbar/tst_qtabbar.cpp | 6 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 3935c55..8ef6017 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1948,7 +1948,8 @@ void QTabBar::changeEvent(QEvent *event) Q_D(QTabBar); if (event->type() == QEvent::StyleChange) { d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); - d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); + if (!d->useScrollButtonsSetByUser) + d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); d->refresh(); } else if (event->type() == QEvent::FontChange) { d->refresh(); @@ -2003,6 +2004,7 @@ bool QTabBar::usesScrollButtons() const void QTabBar::setUsesScrollButtons(bool useButtons) { Q_D(QTabBar); + d->useScrollButtonsSetByUser = true; if (d->useScrollButtons == useButtons) return; d->useScrollButtons = useButtons; diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index 9f3285b..2e8fb6d 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -75,7 +75,7 @@ class QTabBarPrivate : public QWidgetPrivate public: QTabBarPrivate() :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), - drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), + drawBase(true), scrollOffset(0), useScrollButtonsSetByUser(false) , expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) #ifdef Q_WS_MAC @@ -187,6 +187,7 @@ public: QSize iconSize; Qt::TextElideMode elideMode; bool useScrollButtons; + bool useScrollButtonsSetByUser; bool expanding; bool closeButtonOnTabs; diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp index 2db72b9..e83312d 100644 --- a/tests/auto/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/qtabbar/tst_qtabbar.cpp @@ -295,6 +295,10 @@ void tst_QTabBar::setUsesScrollButtons() if (usesArrows != -128) tabBar.setUsesScrollButtons(usesArrows); QTEST(tabBar.usesScrollButtons(), "expectedArrows"); + + // Make sure style sheet does not override user set mode + tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}"); + QTEST(tabBar.usesScrollButtons(), "expectedArrows"); } void tst_QTabBar::removeLastTab() @@ -532,7 +536,7 @@ void tst_QTabBar::task251184_removeTab() QCOMPARE(bar.count(), 1); QCOMPARE(bar.currentIndex(), 0); - QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); + QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); } |