diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2012-11-15 16:45:04 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-15 18:15:50 +0100 |
commit | e9b6eb7795f5f87b705af0cae855c46c5c135297 (patch) | |
tree | 4ced30013cf0bc2bbb78d7b0b91fcb0e9a0be557 /src/widgets | |
parent | f7d99ad50f11ee7c263d4c2bdbe024355a1ab3e9 (diff) |
Improve highligted colorization on mac with Fusion style
This mimics the platform behavior of using blue color when
the system palette is in use.
Change-Id: I9ad6a552614a3466a930ad5b28fc70d9343d2022
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle_p.h | 28 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 8e52a4b425..4121292cc7 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1417,7 +1417,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio QRect leftRect; QRect rect = bar->rect; QColor textColor = option->palette.text().color(); - QColor alternateTextColor = option->palette.highlightedText().color(); + QColor alternateTextColor = d->highlightedText(option->palette); painter->save(); bool vertical = false, inverted = false; diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h index 1c8089e736..affb85bbb1 100644 --- a/src/widgets/styles/qfusionstyle_p.h +++ b/src/widgets/styles/qfusionstyle_p.h @@ -55,6 +55,8 @@ #include "qcommonstyle.h" #include "qcommonstyle_p.h" +#include <qpa/qplatformtheme.h> +#include "private/qguiapplication_p.h" #ifndef QT_NO_STYLE_FUSION @@ -83,10 +85,32 @@ public: return QColor(255, 255, 255, 30); } + // On mac we want a standard blue color used when the system palette is used + bool isMacSystemPalette(const QPalette &pal) const { + Q_UNUSED(pal); +#ifdef Q_OS_MAC + const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette(); + if (themePalette->color(QPalette::Normal, QPalette::Highlight) == + pal.color(QPalette::Normal, QPalette::Highlight) && + themePalette->color(QPalette::Normal, QPalette::HighlightedText) == + pal.color(QPalette::Normal, QPalette::HighlightedText)) + return true; +#endif + return false; + } + QColor highlight(const QPalette &pal) const { + if (isMacSystemPalette(pal)) + return QColor(60, 140, 230); return pal.color(QPalette::Active, QPalette::Highlight); } + QColor highlightedText(const QPalette &pal) const { + if (isMacSystemPalette(pal)) + return Qt::white; + return pal.color(QPalette::Active, QPalette::HighlightedText); + } + QColor outline(const QPalette &pal) const { if (!pal.window().texture().isNull()) return QColor(0, 0, 0, 160); @@ -94,7 +118,7 @@ public: } QColor highlightedOutline(const QPalette &pal) const { - QColor highlightedOutline = pal.highlight().color().darker(125); + QColor highlightedOutline = highlight(pal).darker(125); if (highlightedOutline.value() > 160) highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160); return highlightedOutline; @@ -109,7 +133,7 @@ public: QColor buttonColor(const QPalette &pal) const { QColor buttonColor = pal.button().color(); int val = qGray(buttonColor.rgb()); - buttonColor = buttonColor.lighter(100 + qMax(0, (180- val)/6)); + buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6)); buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value()); return buttonColor; } |