summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-09-24 17:20:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 15:55:10 +0200
commit65b39b3cdcdfe175d80ccf9428168ed51be77fd8 (patch)
treec48d80b53d16fbb709878eb123287560a84f7779 /src/widgets
parent0ef459d7a2f067773645ffd247317fe6cc20cc22 (diff)
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. Change-Id: Iefcc2bebb1ba58d0d99f078c4960c5126542f637 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 415f72c576..cd46bd1ca8 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -4002,13 +4002,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) {
@@ -4019,12 +4023,15 @@ 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));
+ np.setColor(QPalette::WindowText, shadowColor);
+
QRect nr = subElementRect(SE_TabBarTabText, opt, w);
nr.moveTop(-1);
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic;