diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2014-03-18 11:56:10 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-20 10:24:22 (GMT) |
commit | b6e15e047d7f981cbd987e60a1adcf62a57010a1 (patch) | |
tree | 18b3f90d6a333f7897c8df369b4e51a4a88b63cd /src/gui/widgets | |
parent | 020d873a5753c4c147d11ac98682d270554e1d05 (diff) | |
download | Qt-b6e15e047d7f981cbd987e60a1adcf62a57010a1.zip Qt-b6e15e047d7f981cbd987e60a1adcf62a57010a1.tar.gz Qt-b6e15e047d7f981cbd987e60a1adcf62a57010a1.tar.bz2 |
QMenu: Enable sloppy submenu mouse navigation
Since we're in the 21st century, we set QCommonStyle to return true
to the SH_Menu_SloppySubMenus style hint. This unlocks all the logic
already available in QMenu.
This is a backport of I134c87e348d98d1f46055e0bfef2b4a4a3d2993a
from qt/qtbase and includes some previous enhancements.
Task-number: QTBUG-20094
[ChangeLog][QtWidgets][QMenu] Enable sloppy submenu mouse navigation
Change-Id: If4141a3d849123850e40af92ac5aede9ed767bdf
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 2a7477a..0e4ecde 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2872,8 +2872,14 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) d->mouseDown = this; } if (d->sloppyRegion.contains(e->pos())) { - d->sloppyAction = action; - d->sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); + if (d->sloppyAction != action && d->sloppyDelayTimer != 0) { + killTimer(d->sloppyDelayTimer); + d->sloppyDelayTimer = 0; + } + if (d->sloppyDelayTimer == 0) { + d->sloppyAction = action; + d->sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); + } } else if (action != d->currentAction) { d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); } |