QtWidgets: Open submenus also on left mouse button press

This patch allows to open submenus also on left mouse button press.

Previously submenus could be opened only on right mouse button press
as ContextMenu event which was inconvenient especially for long submenu
popup timeout.

Task-number: QTBUG-53054
Change-Id: I1bd78ed4436f738c8838f7f4687ffebb94b66725
Reviewed-by: Félix Bourbonnais <thor400.75@gmail.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Błażej Szczygieł 2016-05-04 18:24:48 +02:00
parent 4762fabce1
commit afa0e9bf6a

View File

@ -2697,11 +2697,16 @@ QMenu::event(QEvent *e)
return true; return true;
} }
} break; } break;
case QEvent::ContextMenu: case QEvent::MouseButtonPress:
if (d->delayState.timer.isActive()) { case QEvent::ContextMenu: {
bool canPopup = true;
if (e->type() == QEvent::MouseButtonPress)
canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton);
if (canPopup && d->delayState.timer.isActive()) {
d->delayState.stop(); d->delayState.stop();
internalDelayedPopup(); internalDelayedPopup();
} }
}
break; break;
case QEvent::Resize: { case QEvent::Resize: {
QStyleHintReturnMask menuMask; QStyleHintReturnMask menuMask;