diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-17 16:33:14 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-18 12:09:16 (GMT) |
commit | 6f55976270b22142da78b80abbebf018539587de (patch) | |
tree | 33963225cd9bc45e911e5230a33bdc45be6e8927 /src/gui | |
parent | b6070e9a069219e4049fcf017d6a160b80bf37b7 (diff) | |
download | Qt-6f55976270b22142da78b80abbebf018539587de.zip Qt-6f55976270b22142da78b80abbebf018539587de.tar.gz Qt-6f55976270b22142da78b80abbebf018539587de.tar.bz2 |
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')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 22 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_p.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index fc88d06..761a060 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 diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index c021063..5757885 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -292,6 +292,9 @@ public: bool hasMouseMoved(const QPoint &globalPos); + void updateLayoutDirection(); + + //menu fading/scrolling effects bool doChildEffects; |