diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-17 17:33:14 +0100 |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-18 13:09:16 +0100 |
commit | 6f55976270b22142da78b80abbebf018539587de (patch) | |
tree | 33963225cd9bc45e911e5230a33bdc45be6e8927 /src/gui/widgets/qmenu.cpp | |
parent | b6070e9a069219e4049fcf017d6a160b80bf37b7 (diff) | |
download | qt4-tools-6f55976270b22142da78b80abbebf018539587de.tar.gz |
QMenu: make the menu follow its parent/caused layout direction
The autotest are included
Task-number: QTBUG-5884
Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/widgets/qmenu.cpp')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index fc88d06600..761a0609e0 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -654,6 +654,24 @@ void QMenuPrivate::_q_overrideMenuActionDestroyed() menuAction=defaultMenuAction; } + +void QMenuPrivate::updateLayoutDirection() +{ + Q_Q(QMenu); + //we need to mimic the cause of the popup's layout direction + //to allow setting it on a mainwindow for example + //we call setLayoutDirection_helper to not overwrite a user-defined value + if (!q->testAttribute(Qt::WA_SetLayoutDirection)) { + if (QWidget *w = causedPopup.widget) + setLayoutDirection_helper(w->layoutDirection()); + else if (QWidget *w = q->parentWidget()) + setLayoutDirection_helper(w->layoutDirection()); + else + setLayoutDirection_helper(QApplication::layoutDirection()); + } +} + + /*! Returns the action associated with this menu. */ @@ -1797,6 +1815,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->tearoffHighlighted = 0; d->motions = 0; d->doChildEffects = true; + d->updateLayoutDirection(); #ifndef QT_NO_MENUBAR // if this menu is part of a chain attached to a QMenuBar, set the @@ -2347,6 +2366,9 @@ QMenu::event(QEvent *e) { Q_D(QMenu); switch (e->type()) { + case QEvent::Polish: + d->updateLayoutDirection(); + break; case QEvent::ShortcutOverride: { QKeyEvent *kev = static_cast<QKeyEvent*>(e); if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down |