QMacStyle and QCocoaTheme: Fix selected item color for non-native menubar

Change-Id: I3b55e9ce896383338cf6ed768d912ca1835b7742
Task-number: QTBUG-28960
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Gabriel de Dietrich 2016-02-26 10:15:43 -08:00
parent 717ff94639
commit 8b94ceaff8
2 changed files with 6 additions and 3 deletions

View File

@ -143,6 +143,7 @@ static QMacPaletteMap mac_widget_colors[] = {
QMacPaletteMap(QPlatformTheme::LabelPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive), QMacPaletteMap(QPlatformTheme::LabelPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive),
QMacPaletteMap(QPlatformTheme::GroupBoxPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive), QMacPaletteMap(QPlatformTheme::GroupBoxPalette, kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive),
QMacPaletteMap(QPlatformTheme::MenuPalette, kThemeTextColorMenuItemActive, kThemeTextColorMenuItemDisabled), QMacPaletteMap(QPlatformTheme::MenuPalette, kThemeTextColorMenuItemActive, kThemeTextColorMenuItemDisabled),
QMacPaletteMap(QPlatformTheme::MenuBarPalette, kThemeTextColorMenuItemActive, kThemeTextColorMenuItemDisabled),
//### TODO: The zeros below gives white-on-black text. //### TODO: The zeros below gives white-on-black text.
QMacPaletteMap(QPlatformTheme::TextEditPalette, 0, 0), QMacPaletteMap(QPlatformTheme::TextEditPalette, 0, 0),
QMacPaletteMap(QPlatformTheme::TextLineEditPalette, 0, 0), QMacPaletteMap(QPlatformTheme::TextLineEditPalette, 0, 0),
@ -167,7 +168,8 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); pal.setColor(QPalette::Disabled, QPalette::WindowText, qc);
pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
} }
if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette) { if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette
|| mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) {
qc = qt_mac_colorForTheme(kThemeBrushMenuBackground); qc = qt_mac_colorForTheme(kThemeBrushMenuBackground);
pal.setBrush(QPalette::Background, qc); pal.setBrush(QPalette::Background, qc);
qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemActive); qc = qt_mac_colorForThemeTextColor(kThemeTextColorMenuItemActive);

View File

@ -4608,7 +4608,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
HIRect menuRect = qt_hirectForQRect(mi->menuRect); HIRect menuRect = qt_hirectForQRect(mi->menuRect);
HIRect itemRect = qt_hirectForQRect(mi->rect); HIRect itemRect = qt_hirectForQRect(mi->rect);
if ((opt->state & State_Selected) && (opt->state & State_Enabled) && (opt->state & State_Sunken)){ const bool selected = (opt->state & State_Selected) && (opt->state & State_Enabled) && (opt->state & State_Sunken);
if (selected) {
// Draw a selected menu item background: // Draw a selected menu item background:
HIThemeMenuItemDrawInfo mdi; HIThemeMenuItemDrawInfo mdi;
mdi.version = qt_mac_hitheme_version; mdi.version = qt_mac_hitheme_version;
@ -4636,7 +4637,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
Qt::AlignCenter | Qt::TextHideMnemonic | Qt::TextDontClip Qt::AlignCenter | Qt::TextHideMnemonic | Qt::TextDontClip
| Qt::TextSingleLine, | Qt::TextSingleLine,
mi->palette, mi->state & State_Enabled, mi->palette, mi->state & State_Enabled,
mi->text, QPalette::ButtonText); mi->text, selected ? QPalette::HighlightedText : QPalette::ButtonText);
} }
} }
break; break;