forked from qt-creator/qt-creator
Theming: fix disabled menu items in dark theme
In the dark theme (fusion style under linux), disabled menu items looked bad due to (1) SH_EtchDisabledText being enabled and (2) a bright color for the etch effect. This patch adds color values for normal and disabled text colors for menu items. It also adds a color value "style" which indicates that the color should just stay at the default of the style. The default theme uses this value for the new menu item colors, while the dark theme fixes the ugly colors. The patch also disables etching for disabled text. Task-number: QTCREATORBUG-13447 Change-Id: Ib54504693d28cf2c71f3fc5a88d3de014230b12b Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Thorben Kroeger <thorbenkroeger@gmail.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
Eike Ziller
parent
5dcd9fe694
commit
e91e1a742c
@@ -359,7 +359,7 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const
|
||||
ret = true;
|
||||
break;
|
||||
case QStyle::SH_EtchDisabledText:
|
||||
if (panelWidget(widget))
|
||||
if (panelWidget(widget) || qobject_cast<const QMenu *> (widget) )
|
||||
ret = false;
|
||||
break;
|
||||
case QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren:
|
||||
@@ -614,7 +614,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget))
|
||||
if (!panelWidget(widget) && !qobject_cast<const QMenu *>(widget))
|
||||
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||
|
||||
switch (element) {
|
||||
@@ -645,6 +645,25 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_MenuItem:
|
||||
painter->save();
|
||||
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||
const bool enabled = mbi->state & State_Enabled;
|
||||
QStyleOptionMenuItem item = *mbi;
|
||||
item.rect = mbi->rect;
|
||||
const QColor color = creatorTheme()->color(enabled
|
||||
? Theme::MenuItemTextColorNormal
|
||||
: Theme::MenuItemTextColorDisabled);
|
||||
if (color.isValid()) {
|
||||
QPalette pal = mbi->palette;
|
||||
pal.setBrush(QPalette::Text, color);
|
||||
item.palette = pal;
|
||||
}
|
||||
QProxyStyle::drawControl(element, &item, painter, widget);
|
||||
}
|
||||
painter->restore();
|
||||
break;
|
||||
|
||||
case CE_MenuBarItem:
|
||||
painter->save();
|
||||
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||
|
||||
Reference in New Issue
Block a user