From 8d3b9841e1732337db67c79571567ac9294b3d7c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 5 Sep 2018 10:03:00 +0200 Subject: Cocoa: change background color of selected menu items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 582d221b29 caused a regression when drawing menu items in e.g a QComboBox. After that change, QCocoaSystemSettings would set the QPalette::Highlight color to [NSColor selectedMenuItemTextColor]. But the Highlight color is the background color, not the text color. And we also use [NSColor selectedMenuItemTextColor] as the QPalette::HighlightedText color. The result is that highlighed menu items end up with the same foreground and background color (white), which means that they "disappear". The color that we used before the patch, alternateSelectedControlColor, could be used, but has the downside that it doesn't follow the appearance color in system settings (like it should, compared to native apps). And it's also slightly to blue. But using keyboardFocusIndicatorColor seems like a perfect match. Fixes: QTBUG-69500 Change-Id: I07f091a5130a7308525743948d2a435226658a6f Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoasystemsettings.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index a6cdf4211f..60eb8cdf68 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -169,7 +169,11 @@ QHash qt_mac_createRolePalettes() // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; } else { - selectedMenuItemColor = [NSColor selectedMenuItemTextColor]; + // selectedMenuItemColor would presumably be the correct color to use as the background + // for selected menu items. But that color is always blue, and doesn't follow the + // appearance color in system preferences. So we therefore deliberatly choose to use + // keyboardFocusIndicatorColor instead, which appears to have the same color value. + selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; } pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); qc = qt_mac_toQColor([NSColor labelColor]); -- cgit v1.2.3