diff options
| author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-03-07 14:09:17 +0100 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-11 12:49:41 +0100 |
| commit | 6f85819fdcdc508410d7a271d648dd558a1a1b51 (patch) | |
| tree | 683e06b9bcce501b7bed31cc9ba8267a76e67938 /src/controls | |
| parent | b19f991a2c1fb9f0ce3ce833b55a0d11d8077032 (diff) | |
Menu: Make popup menus close from child to parent
Some window managers use fading effects to close popups, resulting on
an unnatural animation if menus close from parent to child.
Change-Id: I5860b65b2905752f74c8abdad05988980c167323
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls')
| -rw-r--r-- | src/controls/qtmenu.cpp | 9 | ||||
| -rw-r--r-- | src/controls/qtmenupopupwindow.cpp | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/controls/qtmenu.cpp b/src/controls/qtmenu.cpp index d2c7e863e..688ecb65a 100644 --- a/src/controls/qtmenu.cpp +++ b/src/controls/qtmenu.cpp @@ -300,8 +300,13 @@ void QtMenu::__closeMenu() void QtMenu::__dismissMenu() { - if (m_popupWindow) - m_popupWindow->dismissMenu(); + QtMenuPopupWindow *topMenuWindow = m_popupWindow; + while (topMenuWindow) { + QtMenuPopupWindow *pw = qobject_cast<QtMenuPopupWindow *>(topMenuWindow->transientParent()); + if (!pw) + topMenuWindow->dismissMenu(); + topMenuWindow = pw; + } } void QtMenu::windowVisibleChanged(bool v) diff --git a/src/controls/qtmenupopupwindow.cpp b/src/controls/qtmenupopupwindow.cpp index 74534c2dd..64fdd11f3 100644 --- a/src/controls/qtmenupopupwindow.cpp +++ b/src/controls/qtmenupopupwindow.cpp @@ -86,7 +86,7 @@ void QtMenuPopupWindow::setParentWindow(QQuickWindow *parentWindow) if (parentWindow) { connect(parentWindow, SIGNAL(destroyed()), this, SLOT(dismissMenu())); if (QtMenuPopupWindow *pw = qobject_cast<QtMenuPopupWindow *>(parentWindow)) - connect(this, SIGNAL(menuDismissed()), pw, SLOT(dismissMenu())); + connect(pw, SIGNAL(menuDismissed()), this, SLOT(dismissMenu())); } } @@ -106,7 +106,7 @@ void QtMenuPopupWindow::setGeometry(int posx, int posy, int w, int h) } if (posy + h > s.height()) - posy = s.height() - h; + posy = s.height() - h; else if (posy < 0) posy = 0; @@ -115,9 +115,8 @@ void QtMenuPopupWindow::setGeometry(int posx, int posy, int w, int h) void QtMenuPopupWindow::dismissMenu() { - close(); - emit menuDismissed(); + close(); } void QtMenuPopupWindow::updateSize() |
