QMacStyle: Fix QTabBar appearance on Yosemite

The selected tab text color should be white except when the
window is not active. Also, no text shadow should be rendered
in any case. Finally, there's no need to move the tab shape up
anymore.

Task-number: QTBUG-40833
Change-Id: Ibb35f0bb7a12fb005202fd8c082eb9bb19645b2b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2014-08-25 15:52:30 +02:00
parent f8da177c0f
commit e9e66079b1

View File

@ -3811,6 +3811,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
return; return;
} }
} }
bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
HIThemeTabDrawInfo tdi; HIThemeTabDrawInfo tdi;
tdi.version = 1; tdi.version = 1;
tdi.style = kThemeTabNonFront; tdi.style = kThemeTabNonFront;
@ -3851,10 +3854,13 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
else else
tdi.adornment = kHIThemeTabAdornmentNone; tdi.adornment = kHIThemeTabAdornmentNone;
tdi.kind = kHIThemeTabKindNormal; tdi.kind = kHIThemeTabKindNormal;
if (!verticalTabs)
tabRect.setY(tabRect.y() - 1); if (!usingYosemiteOrLater) {
else if (!verticalTabs)
tabRect.setX(tabRect.x() - 1); tabRect.setY(tabRect.y() - 1);
else
tabRect.setX(tabRect.x() - 1);
}
QStyleOptionTab::TabPosition tp = tabOpt->position; QStyleOptionTab::TabPosition tp = tabOpt->position;
QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition; QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition;
if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) { if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) {
@ -3919,18 +3925,21 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
ThemeTabDirection ttd = getTabDirection(myTab.shape); ThemeTabDirection ttd = getTabDirection(myTab.shape);
bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
bool selected = (myTab.state & QStyle::State_Selected); bool selected = (myTab.state & QStyle::State_Selected);
bool usingModernOSX = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6; bool usingLionOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6;
bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
if (usingModernOSX && selected && !myTab.documentMode) if (usingLionOrLater && selected && !myTab.documentMode
myTab.palette.setColor(QPalette::WindowText, QColor(Qt::white)); && (!usingYosemiteOrLater || myTab.state & State_Active))
myTab.palette.setColor(QPalette::WindowText, Qt::white);
// Check to see if we use have the same as the system font // Check to see if we use have the same as the system font
// (QComboMenuItem is internal and should never be seen by the // (QComboMenuItem is internal and should never be seen by the
// outside world, unless they read the source, in which case, it's // outside world, unless they read the source, in which case, it's
// their own fault). // their own fault).
bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem"); bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem");
if ((usingModernOSX && selected) || verticalTabs || nonDefaultFont || !tab->icon.isNull() bool isSelectedAndNeedsShadow = selected && usingLionOrLater && !usingYosemiteOrLater;
|| !myTab.leftButtonSize.isNull() || !myTab.rightButtonSize.isNull()) { if (isSelectedAndNeedsShadow || verticalTabs || nonDefaultFont || !tab->icon.isNull()
|| !myTab.leftButtonSize.isEmpty() || !myTab.rightButtonSize.isEmpty()) {
int heightOffset = 0; int heightOffset = 0;
if (verticalTabs) { if (verticalTabs) {
heightOffset = -1; heightOffset = -1;
@ -3940,7 +3949,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
} }
myTab.rect.setHeight(myTab.rect.height() + heightOffset); myTab.rect.setHeight(myTab.rect.height() + heightOffset);
if (myTab.documentMode || (usingModernOSX && selected)) { if (myTab.documentMode || isSelectedAndNeedsShadow) {
p->save(); p->save();
rotateTabPainter(p, myTab.shape, myTab.rect); rotateTabPainter(p, myTab.shape, myTab.rect);