QMacStyle - fix the background color for tool button

when it's in 'ON' state ("inverted" color in 'Dark' appearance).
Number are rather arbitrary and extracted with 'Digital Color Meter'
app to make it look similar to the native panel (to be honest,
this tool button on a toolbar not to be found in many native apps,
they use different buttons anyway).

Fixes: QTBUG-71526
Change-Id: Ie61e60b77f097f04550006612e4aab6f11bb954b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Timur Pocheptsov 2019-10-09 11:28:54 +02:00
parent 60deb69034
commit aa3540b7be

View File

@ -328,6 +328,20 @@ static const int closeButtonSize = 14;
static const qreal closeButtonCornerRadius = 2.0;
#endif // QT_CONFIG(tabbar)
#ifndef QT_NO_ACCESSIBILITY // This ifdef to avoid "unused function" warning.
QBrush brushForToolButton(bool isOnKeyWindow)
{
// When a toolbutton in a toolbar is in the 'ON' state, we draw a
// partially transparent background. The colors must be different
// for 'Aqua' and 'DarkAqua' appearances though.
if (isDarkMode())
return isOnKeyWindow ? QColor(73, 73, 73, 100) : QColor(56, 56, 56, 100);
return isOnKeyWindow ? QColor(0, 0, 0, 28) : QColor(0, 0, 0, 21);
}
#endif // QT_NO_ACCESSIBILITY
static const int headerSectionArrowHeight = 6;
static const int headerSectionSeparatorInset = 2;
@ -5603,8 +5617,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
if (view)
isKey = [view.window isKeyWindow];
QBrush brush(isKey ? QColor(0, 0, 0, 28)
: QColor(0, 0, 0, 21));
QBrush brush(brushForToolButton(isKey));
QPainterPath path;
path.addRoundedRect(QRectF(tb->rect.x(), tb->rect.y(), tb->rect.width(), tb->rect.height() + 4), 4, 4);
p->setRenderHint(QPainter::Antialiasing);