Fix current tab text color on Mac when a proxy style is installed

We move the code forcing white text on the current tab to
QMacStyle. This removes the small encapsulation violation
even though we need to check for the tab text color in the
style and modify the palette.

Amends 2fbc143202.

Change-Id: If31dc11ae389ee5315e84ab03cf1c08540d81640
Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-06-23 10:47:23 -07:00 committed by Błażej Szczygieł
parent 9c9382a85f
commit d138a239d2
2 changed files with 6 additions and 4 deletions

View File

@ -4210,6 +4210,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// outside world, unless they read the source, in which case, it's
// their own fault).
bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem");
if (!myTab.documentMode && (myTab.state & State_Selected) && (myTab.state & State_Active))
if (const auto *tabBar = qobject_cast<const QTabBar *>(w))
if (!tabBar->tabTextColor(tabBar->currentIndex()).isValid())
myTab.palette.setColor(QPalette::WindowText, Qt::white);
if (verticalTabs || nonDefaultFont || !tab->icon.isNull()
|| !myTab.leftButtonSize.isEmpty() || !myTab.rightButtonSize.isEmpty()) {
int heightOffset = 0;

View File

@ -176,10 +176,6 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
if (tab.textColor.isValid())
option->palette.setColor(q->foregroundRole(), tab.textColor);
else if (q->style()->inherits("QMacStyle")
&& isCurrent && !documentMode && q->isActiveWindow()) {
option->palette.setColor(QPalette::WindowText, Qt::white);
}
option->icon = tab.icon;
option->iconSize = q->iconSize(); // Will get the default value then.