diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2012-02-27 11:54:21 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-28 10:00:56 (GMT) |
commit | 24398afa413d38c4fc38d09d1a218cf514ed3987 (patch) | |
tree | ac4f883ad33db5bab43b6b444b49242f7a11dd18 /src/gui/widgets | |
parent | 74e777a76b9ac63107a32422c28ad79cd2217250 (diff) | |
download | Qt-24398afa413d38c4fc38d09d1a218cf514ed3987.zip Qt-24398afa413d38c4fc38d09d1a218cf514ed3987.tar.gz Qt-24398afa413d38c4fc38d09d1a218cf514ed3987.tar.bz2 |
Fix submenu positioning
Submenus are now positioned to the correct side of the parent menu
based on layout direction, if there is enough space on screen to fit
the menu. If there is insufficient space, then the menu is positioned
to the other side of the parent menu. In case that also causes submenu
to be partially ofscreen (very wide menu relative to the screen),
then the submenu will be aligned with the screen edge and will overlap
the parent menu. This seems like a lesser evil compared to having
submenu partially offscreen, which could obscure important details
such as checkmarks.
Task-number: QTBUG-23568
Change-Id: I6a9ab2c232713a2ee5a6dde3227c40419d46bd3d
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
(cherry picked from commit 64e0560ff451676fc96dfadd21bef436ac25bb52)
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 2eaeacc..f18b305 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1967,13 +1967,21 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset) && (pos.x() < parentActionRect.right())) { + pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() < screen.x()) pos.rx() = parentActionRect.right(); + if (pos.x() + menuSize.width() > screen.x() + screen.width()) + pos.rx() = screen.x(); } } else { if ((pos.x() < parentActionRect.right() + subMenuOffset) && (pos.x() + menuSize.width() > parentActionRect.left())) { + pos.rx() = parentActionRect.right(); + if (pos.x() + menuSize.width() > screen.x() + screen.width()) pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() < screen.x()) + pos.rx() = screen.x() + screen.width() - menuSize.width(); } } } |