diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-03-19 12:09:40 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-03-21 19:41:23 +0000 |
commit | 4ac00ca901f1cbd503b858eb1e5ed19079c31f44 (patch) | |
tree | 1683e4257f37f901300388bb152cb0ee0efbd707 /src/widgets/styles/qcommonstyle.cpp | |
parent | eaabd0c5450ad849e24878d38dd05d5b23d7eec3 (diff) |
QTabBar: let styles draw tab text with foreground role
QTabBar::setTabTextColor's documentation and implementation suggests
that the set color will always be used unless invalid, and that the
foreground role is used otherwise. QTabBar then sets the foregroundRole
palette entry to the specified color before calling the style. The intent
is evidently that the tabTextColor is used no matter the foregroundRole
(which by default is the role that contrasts with the background role).
If the styles always paint the text with WindowText, then the tabTextColor
gets ignored if the foregroundRole is not WindowText (perhaps because
the backgroundRole is set to Base).
Fix this by respecting the widget's foregroundRole when painting the tab
label in the common style (which is the only style that implements
drawControl for CE_TabBarTabLabel). QMacStyle and QStyleSheetStyle
need to be adjusted to prepare the palette consistently with the logic
in QTabBar.
Pick-to: 6.3 6.2
Fixes: QTBUG-101456
Change-Id: I077a2034eebfe3f56cea28917494f4db01e48747
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index cdd061f8d5..f324925607 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -2004,7 +2004,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon); } - proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); + proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, + widget ? widget->foregroundRole() : QPalette::WindowText); if (verticalTabs) p->restore(); |