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>
bb10
J-P Nurmi 2014-06-28 15:47:58 +02:00
parent 8638895f6b
commit 5de4ed9db3
4 changed files with 13 additions and 2 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -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

View File

@ -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);
}