From aa3540b7be3dd0f5a96de1df5c4771d789127204 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 9 Oct 2019 11:28:54 +0200 Subject: QMacStyle - fix the background color for tool button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/styles/mac/qmacstyle_mac.mm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/plugins/styles') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 0a216e540d..63dc49fd18 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -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); -- cgit v1.2.3