diff options
Diffstat (limited to 'src/gui/widgets/qmenu.cpp')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index cc39b7f..54d1612 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -602,14 +602,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } #ifndef QT_NO_STATUSTIP } else if (previousAction) { - QWidget *w = causedPopup.widget; - while (QMenu *m = qobject_cast<QMenu*>(w)) - w = m->d_func()->causedPopup.widget; - if (w) { - QString empty; - QStatusTipEvent tip(empty); - QApplication::sendEvent(w, &tip); - } + previousAction->d_func()->showStatusText(topCausedWidget(), QString()); #endif } if (hideActiveMenu) { @@ -623,6 +616,15 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } } +//return the top causedPopup.widget that is not a QMenu +QWidget *QMenuPrivate::topCausedWidget() const +{ + QWidget* top = causedPopup.widget; + while (QMenu* m = qobject_cast<QMenu *>(top)) + top = m->d_func()->causedPopup.widget; + return top; +} + QAction *QMenuPrivate::actionAt(QPoint p) const { if (!q_func()->rect().contains(p)) //sanity check @@ -1094,10 +1096,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e QAccessible::updateAccessibility(q, actionIndex, QAccessible::Selection); } #endif - QWidget *w = causedPopup.widget; - while (QMenu *m = qobject_cast<QMenu*>(w)) - w = m->d_func()->causedPopup.widget; - action->showStatusText(w); + action->showStatusText(topCausedWidget()); } else { actionAboutToTrigger = 0; } @@ -1801,10 +1800,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #ifndef QT_NO_MENUBAR // if this menu is part of a chain attached to a QMenuBar, set the // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type - QWidget* top = this; - while (QMenu* m = qobject_cast<QMenu *>(top)) - top = m->d_func()->causedPopup.widget; - setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(top) != 0); + setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0); #endif ensurePolished(); // Get the right font @@ -2752,18 +2748,14 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } if (!key_consumed) { - if (QWidget *caused = d->causedPopup.widget) { - while(QMenu *m = qobject_cast<QMenu*>(caused)) - caused = m->d_func()->causedPopup.widget; #ifndef QT_NO_MENUBAR - if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { - QAction *oldAct = mb->d_func()->currentAction; - QApplication::sendEvent(mb, e); - if (mb->d_func()->currentAction != oldAct) - key_consumed = true; - } -#endif + if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) { + QAction *oldAct = mb->d_func()->currentAction; + QApplication::sendEvent(mb, e); + if (mb->d_func()->currentAction != oldAct) + key_consumed = true; } +#endif } #ifdef Q_OS_WIN32 |