summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-05 10:03:00 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-08 19:41:17 +0000
commit8d3b9841e1732337db67c79571567ac9294b3d7c (patch)
treed0ce8004edd60402caf4f00889d77610ca502b41
parent5474f28c42ce0c853ddd08a8fd2f31948fcd968b (diff)
Cocoa: change background color of selected menu items
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ø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm6
1 files changed, 5 insertions, 1 deletions
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<QPlatformTheme::Palette, QPalette*> 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]);