diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-06-28 15:47:58 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@digia.com> | 2014-06-30 14:57:40 +0200 |
commit | 5de4ed9db38c7a1a480e5979c2bb3b0340c8a230 (patch) | |
tree | 4df6b9293e13f0bab3916993c319982f4bd0ead1 /src/widgets | |
parent | 8638895f6be4bd6566e771603a42f9f99b0c1d97 (diff) |
QMac/FusionStyle: fix the background color for transient scrollbars
Task-number: QTBUG-39922
Change-Id: I4b313296ae845bc9e116494aa66c577b432b4a67
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/qmacstyle_mac.mm | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 10 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper_p.h | 1 |
4 files changed, 13 insertions, 2 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 2172c9082f..82c53def7d 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2493,7 +2493,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption QColor arrowColor = option->palette.foreground().color(); arrowColor.setAlpha(220); - const QColor bgColor = option->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(option->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (transient) { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8bc454a795..8cb7ce1c87 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5133,7 +5133,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())]; // mac os behaviour: as soon as one color channel is >= 128, // the bg is considered bright, scroller is dark - const QColor bgColor = opt->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (isDarkBg) diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index fc73488154..6be07a3f45 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -45,6 +45,8 @@ #include <private/qmath_p.h> #include <private/qstyle_p.h> #include <qmath.h> +#include <qscrollbar.h> +#include <qabstractscrollarea.h> #include "qstylehelper_p.h" #include <qstringbuilder.h> @@ -387,5 +389,13 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec } } + +QColor backgroundColor(const QPalette &pal, const QWidget* widget) +{ + if (qobject_cast<const QScrollBar *>(widget) && widget->parent() && + qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent())) + return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); + return pal.color(QPalette::Base); +} } QT_END_NAMESPACE diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index 6355cbc985..73e5c94dcd 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -86,6 +86,7 @@ namespace QStyleHelper bool isInstanceOf(QObject *obj, QAccessible::Role role); bool hasAncestor(QObject *obj, QAccessible::Role role); #endif + QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); } |