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,10 +2697,15 @@ QMenu::event(QEvent *e)
return true;
}
} break;
case QEvent::ContextMenu:
if (d->delayState.timer.isActive()) {
d->delayState.stop();
internalDelayedPopup();
case QEvent::MouseButtonPress:
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();
internalDelayedPopup();
}
}
break;
case QEvent::Resize: {