diff options
author | Liang Qi <liang.qi@qt.io> | 2017-09-06 13:26:31 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-09-06 13:26:31 +0200 |
commit | 19dd2ca93b8b95a5e2792b29ed62ea23800fb53e (patch) | |
tree | 17685d2a9628ec5936155e09da3edd74c9244b0e /src/widgets/widgets/qmenu.cpp | |
parent | 942922652481347659a0dae78758c334778a58d2 (diff) | |
parent | d332a2d3ccb485c9decd6c47fa5a5fc02b59d27e (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
examples/opengl/qopenglwidget/main.cpp
src/3rdparty/pcre2/src/pcre2_printint.c
src/plugins/platforms/cocoa/qnsview.mm
src/widgets/widgets/qcombobox.cpp
Change-Id: I37ced9da1e8056f95851568bcc52cd5dc34f56af
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 0355bb44f7..c1fb409380 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -41,6 +41,8 @@ #ifndef QT_NO_MENU +#include <QtWidgets/private/qtwidgetsglobal_p.h> + #include "qdebug.h" #include "qstyle.h" #include "qevent.h" @@ -56,7 +58,7 @@ #ifndef QT_NO_ACCESSIBILITY # include "qaccessible.h" #endif -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) # include <private/qeffects_p.h> #endif #if QT_CONFIG(whatsthis) @@ -64,7 +66,9 @@ #endif #include "qmenu_p.h" +#if QT_CONFIG(menubar) #include "qmenubar_p.h" +#endif #include "qwidgetaction.h" #if QT_CONFIG(toolbutton) #include "qtoolbutton.h" @@ -498,7 +502,7 @@ void QMenuPrivate::hideUpToMenuBar() QWidget *caused = causedPopup.widget; hideMenu(q); //hide after getting causedPopup while(caused) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { mb->d_func()->setCurrentAction(0); mb->d_func()->setKeyboardMode(false); @@ -522,7 +526,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) { if (!menu) return; -#if !defined(QT_NO_EFFECTS) +#if QT_CONFIG(effects) QSignalBlocker blocker(menu); aboutToHide = true; // Flash item which is about to trigger (if any). @@ -544,7 +548,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) aboutToHide = false; blocker.unblock(); -#endif // QT_NO_EFFECTS +#endif // QT_CONFIG(effects) if (activeMenu == menu) activeMenu = 0; menu->d_func()->causedPopup.action = 0; @@ -675,7 +679,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } if (hideActiveMenu && previousAction != currentAction) { if (popup == -1) { -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) // kill any running effect qFadeEffect(0); qScrollEffect(0); @@ -1280,7 +1284,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) bool passOnEvent = false; QWidget *next_widget = 0; QPoint cpos = caused->mapFromGlobal(e->globalPos()); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { passOnEvent = mb->rect().contains(cpos); } else @@ -1322,7 +1326,7 @@ void QMenuPrivate::activateCausedStack(const QVector<QPointer<QWidget> > &caused } else if (action_e == QAction::Hover) { emit qmenu->hovered(action); } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) { if (action_e == QAction::Trigger) { emit qmenubar->triggered(action); @@ -1417,7 +1421,7 @@ void QMenuPrivate::_q_actionTriggered() QVector< QPointer<QWidget> > list; for(QWidget *widget = q->parentWidget(); widget; ) { if (qobject_cast<QMenu*>(widget) -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) || qobject_cast<QMenuBar*>(widget) #endif ) { @@ -2318,7 +2322,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->doChildEffects = true; d->updateLayoutDirection(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) // if this menu is part of a chain attached to a QMenuBar, set the // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0); @@ -2414,11 +2418,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (snapToMouse) // position flowing left from the mouse pos.setX(mouse.x() - size.width()); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) // if the menu is in a menubar or is a submenu, it should be right-aligned if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget)) pos.rx() -= size.width(); -#endif //QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) if (pos.x() < screen.left() + desktopFrame) pos.setX(qMax(p.x(), screen.left() + desktopFrame)); @@ -2479,7 +2483,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } } setGeometry(QRect(pos, size)); -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll; int vGuess = QEffects::DownScroll; if (isRightToLeft()) { @@ -2492,7 +2496,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) hGuess = QEffects::LeftScroll; } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) || (qobject_cast<QMenuBar*>(d->causedPopup.widget) && pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y())) @@ -2500,7 +2504,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #endif if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) { bool doChildEffects = true; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) { doChildEffects = mb->d_func()->doChildEffects; mb->d_func()->doChildEffects = false; @@ -2662,7 +2666,7 @@ void QMenu::hideEvent(QHideEvent *) QAccessibleEvent event(this, QAccessible::PopupMenuEnd); QAccessible::updateAccessibility(&event); #endif -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) mb->d_func()->setCurrentAction(0); #endif @@ -3211,7 +3215,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { d->hideMenu(this); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())) { mb->d_func()->setKeyboardMode(false); } @@ -3273,7 +3277,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) { QPointer<QWidget> caused = d->causedPopup.widget; d->hideMenu(this); // hide after getting causedPopup -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { mb->d_func()->setCurrentAction(d->menuAction); mb->d_func()->setKeyboardMode(true); @@ -3350,7 +3354,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } if (!key_consumed) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) { QAction *oldAct = mb->d_func()->currentAction; QApplication::sendEvent(mb, e); |