diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-03-13 19:43:15 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-03-16 00:13:28 +0000 |
commit | 0c059db57d47cb20bf069fce3e444f9eb8e9f33c (patch) | |
tree | 50c342217184fc934994f886d2c5f2066474cdb5 /src/widgets/widgets | |
parent | 2fb706f9a842474e534e7c6e2915d9096f5a10d1 (diff) |
QMenu: Realign submenu first action with its parent menu action
There was an offset equivalent to all the margins we add to
the action rectangles. We need to subtract it in order for
both menu items, parent and sub-menu, to be aligned. This
amount is given by the sub-menu's first action position
relative to its popup.
Change-Id: I141bbe3cfb81825a25b12e4059b93e61c29df518
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 024f9a75a1..363647aee0 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -3641,6 +3641,13 @@ void QMenu::internalDelayedPopup() if (subMenuPos.x() > screen.right()) subMenuPos.setX(QCursor::pos().x()); + const auto &subMenuActions = d->activeMenu->actions(); + if (!subMenuActions.isEmpty()) { + // Offset by the submenu's 1st action position to align with the current action + const auto subMenuActionRect = d->activeMenu->actionGeometry(subMenuActions.first()); + subMenuPos.ry() -= subMenuActionRect.top(); + } + d->activeMenu->popup(subMenuPos); d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); |