diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2012-12-20 10:53:05 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-07 11:49:28 (GMT) |
commit | a1eaf0169f041f599895fac90570df601559a526 (patch) | |
tree | 4885ccf7a28d1d9447cfca015b8d0d6d518584d2 /src/gui | |
parent | 7801f57ef3d79e30836f3470d1f7cbecf7a082ba (diff) | |
download | Qt-a1eaf0169f041f599895fac90570df601559a526.zip Qt-a1eaf0169f041f599895fac90570df601559a526.tar.gz Qt-a1eaf0169f041f599895fac90570df601559a526.tar.bz2 |
Mac: Fixed text rendering in selected tab button
We resort to custom Qt rendering when selected since it looks better
than using Carbon's HITheme engine.
This is a backport of Qt 5's 65b39b3cdcdfe175d80ccf9428168ed51be77fd8,
and also reverts commit f7bba6cc700f5f6b1ff6a40b8c475924de206022.
Change-Id: I684db730f05bead16e16a0d1c8f20164e9fc70b7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/styles/qmacstyle_mac.mm | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 0cdd077..971c6ba 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3656,13 +3656,17 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QStyleOptionTabV3 myTab = *tab; ThemeTabDirection ttd = getTabDirection(myTab.shape); bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; + bool selected = (myTab.state & QStyle::State_Selected); + + if (selected && !myTab.documentMode) + myTab.palette.setColor(QPalette::WindowText, QColor(Qt::white)); // Check to see if we use have the same as the system font // (QComboMenuItem is internal and should never be seen by the // 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 (verticalTabs || nonDefaultFont || !tab->icon.isNull() + if (selected || verticalTabs || nonDefaultFont || !tab->icon.isNull() || !myTab.leftButtonSize.isNull() || !myTab.rightButtonSize.isNull()) { int heightOffset = 0; if (verticalTabs) { @@ -3673,39 +3677,24 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } myTab.rect.setHeight(myTab.rect.height() + heightOffset); - if (myTab.documentMode) { + if (myTab.documentMode || selected) { p->save(); rotateTabPainter(p, myTab.shape, myTab.rect); + QColor shadowColor = QColor(myTab.documentMode ? Qt::white : Qt::black); + shadowColor.setAlpha(75); QPalette np = tab->palette; - np.setColor(QPalette::WindowText, QColor(255, 255, 255, 75)); - QRect nr = subElementRect(SE_TabBarTabText, opt, w); - nr.moveTop(-1); - int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; - proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, - tab->text, QPalette::WindowText); - p->restore(); - QCommonStyle::drawControl(ce, &myTab, p, w); - } else if (qMacVersion() >= QSysInfo::MV_10_7 && (tab->state & State_Selected)) { - p->save(); - rotateTabPainter(p, myTab.shape, myTab.rect); + np.setColor(QPalette::WindowText, shadowColor); - QPalette np = tab->palette; - np.setColor(QPalette::WindowText, QColor(0, 0, 0, 75)); QRect nr = subElementRect(SE_TabBarTabText, opt, w); nr.moveTop(-1); int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, tab->text, QPalette::WindowText); - - np.setColor(QPalette::WindowText, QColor(255, 255, 255, 255)); - nr.moveTop(-2); - proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, - tab->text, QPalette::WindowText); p->restore(); - } else { - QCommonStyle::drawControl(ce, &myTab, p, w); } + + QCommonStyle::drawControl(ce, &myTab, p, w); } else { p->save(); CGContextSetShouldAntialias(cg, true); |