Menu icon behaviour fixed.
This commit is contained in:
@@ -493,6 +493,30 @@ namespace AzQtComponents
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CE_MenuItem:
|
||||
{
|
||||
const QMenu* menu = qobject_cast<const QMenu*>(widget);
|
||||
QAction* action = menu->activeAction();
|
||||
if (action)
|
||||
{
|
||||
QMenu* subMenu = action->menu();
|
||||
if (subMenu)
|
||||
{
|
||||
QVariant noHover = subMenu->property("noHover");
|
||||
if (noHover.isValid() && noHover.toBool())
|
||||
{
|
||||
// First draw as standard to get the correct hover background for the complete control.
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
// Now draw the icon as non-hovered so control behaves as designed.
|
||||
const QStyleOptionMenuItem* opt = qstyleoption_cast<const QStyleOptionMenuItem*>(option);
|
||||
QStyleOptionMenuItem myOpt = *(const_cast<QStyleOptionMenuItem*>(opt));
|
||||
myOpt.state &= ~QStyle::State_Selected;
|
||||
return QProxyStyle::drawControl(element, &myOpt, painter, widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||
|
||||
Reference in New Issue
Block a user