qmenu.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmenu.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qmenu.h"-
35-
36#ifndef QT_NO_MENU-
37-
38#include "qdebug.h"-
39#include "qstyle.h"-
40#include "qevent.h"-
41#include "qtimer.h"-
42#include "qlayout.h"-
43#include "qpainter.h"-
44#include <qpa/qplatformtheme.h>-
45#ifdef Q_OS_OSX-
46#include "qmacnativewidget_mac.h"-
47#endif-
48#include "qapplication.h"-
49#include "qdesktopwidget.h"-
50#ifndef QT_NO_ACCESSIBILITY-
51# include "qaccessible.h"-
52#endif-
53#ifndef QT_NO_EFFECTS-
54# include <private/qeffects_p.h>-
55#endif-
56#ifndef QT_NO_WHATSTHIS-
57# include <qwhatsthis.h>-
58#endif-
59-
60#include "qmenu_p.h"-
61#include "qmenubar_p.h"-
62#include "qwidgetaction.h"-
63#include "qtoolbutton.h"-
64#include "qpushbutton.h"-
65#include "qtooltip.h"-
66#include <private/qpushbutton_p.h>-
67#include <private/qaction_p.h>-
68#include <private/qguiapplication_p.h>-
69-
70QT_BEGIN_NAMESPACE-
71-
72QMenu *QMenuPrivate::mouseDown = 0;-
73-
74/* QMenu code */-
75// internal class used for the torn off popup-
76class QTornOffMenu : public QMenu-
77{-
78 Q_OBJECT-
79 class QTornOffMenuPrivate : public QMenuPrivate-
80 {-
81 Q_DECLARE_PUBLIC(QMenu)-
82 public:-
83 QTornOffMenuPrivate(QMenu *p) : causedMenu(p) {-
84 tornoff = 1;-
85 causedPopup.widget = 0;-
86 causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action;-
87 causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack();-
88 }
never executed: end of block
0
89 QVector<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; }
never executed: return causedStack;
0
90 QPointer<QMenu> causedMenu;-
91 QVector<QPointer<QWidget> > causedStack;-
92 };-
93public:-
94 QTornOffMenu(QMenu *p) : QMenu(*(new QTornOffMenuPrivate(p)))-
95 {-
96 Q_D(QTornOffMenu);-
97 // make the torn-off menu a sibling of p (instead of a child)-
98 QWidget *parentWidget = d->causedStack.isEmpty() ? p : d->causedStack.last();
d->causedStack.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
99 if (parentWidget->parentWidget())
parentWidget->parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
100 parentWidget = parentWidget->parentWidget();
never executed: parentWidget = parentWidget->parentWidget();
0
101 setParent(parentWidget, Qt::Window | Qt::Tool);-
102 setAttribute(Qt::WA_DeleteOnClose, true);-
103 setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);-
104 setWindowTitle(p->windowTitle());-
105 setEnabled(p->isEnabled());-
106 //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*)));-
107 //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*)));-
108 QList<QAction*> items = p->actions();-
109 for(int i = 0; i < items.count(); i++)
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
110 addAction(items.at(i));
never executed: addAction(items.at(i));
0
111 }
never executed: end of block
0
112 void syncWithMenu(QMenu *menu, QActionEvent *act)-
113 {-
114 Q_D(QTornOffMenu);-
115 if(menu != d->causedMenu)
menu != d->causedMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
116 return;
never executed: return;
0
117 if (act->type() == QEvent::ActionAdded) {
act->type() ==...t::ActionAddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
118 insertAction(act->before(), act->action());-
119 } else if (act->type() == QEvent::ActionRemoved)
never executed: end of block
act->type() ==...:ActionRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 removeAction(act->action());
never executed: removeAction(act->action());
0
121 }
never executed: end of block
0
122 void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE-
123 {-
124 QMenu::actionEvent(e);-
125 setFixedSize(sizeHint());-
126 }
never executed: end of block
0
127public slots:-
128 void onTrigger(QAction *action) { d_func()->activateAction(action, QAction::Trigger, false); }
never executed: end of block
0
129 void onHovered(QAction *action) { d_func()->activateAction(action, QAction::Hover, false); }
never executed: end of block
0
130private:-
131 Q_DECLARE_PRIVATE(QTornOffMenu)
never executed: return reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));
never executed: return reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));
0
132 friend class QMenuPrivate;-
133};-
134-
135void QMenuPrivate::init()-
136{-
137 Q_Q(QMenu);-
138#ifndef QT_NO_WHATSTHIS-
139 q->setAttribute(Qt::WA_CustomWhatsThis);-
140#endif-
141 q->setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu);-
142 defaultMenuAction = menuAction = new QAction(q);-
143 menuAction->d_func()->menu = q;-
144 q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q));-
145 if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) {
q->style()->st...ollable, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
146 scroll = new QMenuPrivate::QMenuScroller;-
147 scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;-
148 }
never executed: end of block
0
149-
150 setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu());-
151 sloppyState.initialize(q);-
152 delayState.initialize(q);-
153 mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q);-
154}
never executed: end of block
0
155-
156void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu)-
157{-
158 Q_Q(QMenu);-
159 if (!platformMenu.isNull() && !platformMenu->parent())
!platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!platformMenu->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
160 delete platformMenu.data();
never executed: delete platformMenu.data();
0
161-
162 platformMenu = menu;-
163 if (!platformMenu.isNull()) {
!platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
164 QObject::connect(platformMenu, SIGNAL(aboutToShow()), q, SLOT(_q_platformMenuAboutToShow()));-
165 QObject::connect(platformMenu, SIGNAL(aboutToHide()), q, SIGNAL(aboutToHide()));-
166 }
never executed: end of block
0
167}
never executed: end of block
0
168-
169// forward declare function-
170static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu);-
171-
172void QMenuPrivate::syncPlatformMenu()-
173{-
174 Q_Q(QMenu);-
175 if (platformMenu.isNull())
platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
176 return;
never executed: return;
0
177-
178 QPlatformMenuItem *beforeItem = Q_NULLPTR;-
179 const QList<QAction*> actions = q->actions();-
180 for (QList<QAction*>::const_reverse_iterator it = actions.rbegin(), end = actions.rend(); it != end; ++it) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 QPlatformMenuItem *menuItem = platformMenu->createMenuItem();-
182 QAction *action = *it;-
183 menuItem->setTag(reinterpret_cast<quintptr>(action));-
184 QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection);-
185 QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection);-
186 copyActionToPlatformItem(action, menuItem, platformMenu.data());-
187 platformMenu->insertMenuItem(menuItem, beforeItem);-
188 beforeItem = menuItem;-
189 }
never executed: end of block
0
190 platformMenu->syncSeparatorsCollapsible(collapsibleSeparators);-
191 platformMenu->setEnabled(q->isEnabled());-
192}
never executed: end of block
0
193-
194int QMenuPrivate::scrollerHeight() const-
195{-
196 Q_Q(const QMenu);-
197 return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
never executed: return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
0
198}-
199-
200//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't-
201QRect QMenuPrivate::popupGeometry(const QWidget *widget) const-
202{-
203 if (QGuiApplicationPrivate::platformTheme() &&
QGuiApplicatio...latformTheme()Description
TRUEnever evaluated
FALSEnever evaluated
0
204 QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
QGuiApplicatio...Menu).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
205 return QApplication::desktop()->screenGeometry(widget);
never executed: return QApplication::desktop()->screenGeometry(widget);
0
206 } else {-
207 return QApplication::desktop()->availableGeometry(widget);
never executed: return QApplication::desktop()->availableGeometry(widget);
0
208 }-
209}-
210-
211//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't-
212QRect QMenuPrivate::popupGeometry(int screen) const-
213{-
214 if (QGuiApplicationPrivate::platformTheme() &&
QGuiApplicatio...latformTheme()Description
TRUEnever evaluated
FALSEnever evaluated
0
215 QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
QGuiApplicatio...Menu).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
216 return QApplication::desktop()->screenGeometry(screen);
never executed: return QApplication::desktop()->screenGeometry(screen);
0
217 } else {-
218 return QApplication::desktop()->availableGeometry(screen);
never executed: return QApplication::desktop()->availableGeometry(screen);
0
219 }-
220}-
221-
222QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const-
223{-
224 QVector<QPointer<QWidget> > ret;-
225 for(QWidget *widget = causedPopup.widget; widget; ) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
226 ret.append(widget);-
227 if (QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget))
QTornOffMenu *...Menu*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
228 ret += qtmenu->d_func()->causedStack;
never executed: ret += qtmenu->d_func()->causedStack;
0
229 if (QMenu *qmenu = qobject_cast<QMenu*>(widget))
QMenu *qmenu =...Menu*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
230 widget = qmenu->d_func()->causedPopup.widget;
never executed: widget = qmenu->d_func()->causedPopup.widget;
0
231 else-
232 break;
never executed: break;
0
233 }-
234 return ret;
never executed: return ret;
0
235}-
236-
237void QMenuPrivate::updateActionRects() const-
238{-
239 Q_Q(const QMenu);-
240 updateActionRects(popupGeometry(q));-
241}
never executed: end of block
0
242-
243void QMenuPrivate::updateActionRects(const QRect &screen) const-
244{-
245 Q_Q(const QMenu);-
246 if (!itemsDirty)
!itemsDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
247 return;
never executed: return;
0
248-
249 q->ensurePolished();-
250-
251 //let's reinitialize the buffer-
252 actionRects.resize(actions.count());-
253 actionRects.fill(QRect());-
254-
255 int lastVisibleAction = getLastVisibleAction();-
256-
257 int max_column_width = 0,-
258 dh = screen.height(),-
259 y = 0;-
260 QStyle *style = q->style();-
261 QStyleOption opt;-
262 opt.init(q);-
263 const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),-
264 vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),-
265 icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);-
266 const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);-
267 const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);-
268 const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
269-
270 //for compatibility now - will have to refactor this away-
271 tabWidth = 0;-
272 maxIconWidth = 0;-
273 hasCheckableItems = false;-
274 ncols = 1;-
275-
276 for (int i = 0; i < actions.count(); ++i) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
277 QAction *action = actions.at(i);-
278 if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action))
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
!action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
widgetItems.contains(action)Description
TRUEnever evaluated
FALSEnever evaluated
0
279 continue;
never executed: continue;
0
280 //..and some members-
281 hasCheckableItems |= action->isCheckable();-
282 QIcon is = action->icon();-
283 if (!is.isNull()) {
!is.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
284 maxIconWidth = qMax<uint>(maxIconWidth, icone + 4);-
285 }
never executed: end of block
0
286 }
never executed: end of block
0
287-
288 //calculate size-
289 QFontMetrics qfm = q->fontMetrics();-
290 bool previousWasSeparator = true; // this is true to allow removing the leading separators-
291 for(int i = 0; i <= lastVisibleAction; i++) {
i <= lastVisibleActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
292 QAction *action = actions.at(i);-
293 const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
!action->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!action->icon().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
294 const bool isPlainSeparator = (isSection && !q->style()->styleHint(QStyle::SH_Menu_SupportsSections))
isSectionDescription
TRUEnever evaluated
FALSEnever evaluated
!q->style()->s...portsSections)Description
TRUEnever evaluated
FALSEnever evaluated
0
295 || (action->isSeparator() && !isSection);
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
!isSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
296-
297 if (!action->isVisible() ||
!action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
298 (collapsibleSeparators && previousWasSeparator && isPlainSeparator))
collapsibleSeparatorsDescription
TRUEnever evaluated
FALSEnever evaluated
previousWasSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
isPlainSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
299 continue; // we continue, this action will get an empty QRect
never executed: continue;
0
300-
301 previousWasSeparator = isPlainSeparator;-
302-
303 //let the style modify the above size..-
304 QStyleOptionMenuItem opt;-
305 q->initStyleOption(&opt, action);-
306 const QFontMetrics &fm = opt.fontMetrics;-
307-
308 QSize sz;-
309 if (QWidget *w = widgetItems.value(action)) {
QWidget *w = w....value(action)Description
TRUEnever evaluated
FALSEnever evaluated
0
310 sz = w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize());-
311 } else {
never executed: end of block
0
312 //calc what I think the size is..-
313 if (action->isSeparator()) {
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
314 sz = QSize(2, 2);-
315 } else {
never executed: end of block
0
316 QString s = action->text();-
317 int t = s.indexOf(QLatin1Char('\t'));-
318 if (t != -1) {
t != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
319 tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1)));-
320 s = s.left(t);-
321 #ifndef QT_NO_SHORTCUT-
322 } else {
never executed: end of block
0
323 QKeySequence seq = action->shortcut();-
324 if (!seq.isEmpty())
!seq.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
325 tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
never executed: tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
0
326 #endif-
327 }
never executed: end of block
0
328 sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());-
329 sz.setHeight(qMax(fm.height(), qfm.height()));-
330-
331 QIcon is = action->icon();-
332 if (!is.isNull()) {
!is.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
333 QSize is_sz = QSize(icone, icone);-
334 if (is_sz.height() > sz.height())
is_sz.height() > sz.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
335 sz.setHeight(is_sz.height());
never executed: sz.setHeight(is_sz.height());
0
336 }
never executed: end of block
0
337 }
never executed: end of block
0
338 sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q);-
339 }
never executed: end of block
0
340-
341-
342 if (!sz.isEmpty()) {
!sz.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
343 max_column_width = qMax(max_column_width, sz.width());-
344 //wrapping-
345 if (!scroll &&
!scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
346 y+sz.height()+vmargin > dh - (deskFw * 2)) {
y+sz.height()+...- (deskFw * 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
347 ncols++;-
348 y = vmargin;-
349 }
never executed: end of block
0
350 y += sz.height();-
351 //update the item-
352 actionRects[i] = QRect(0, 0, sz.width(), sz.height());-
353 }
never executed: end of block
0
354 }
never executed: end of block
0
355-
356 max_column_width += tabWidth; //finally add in the tab width-
357 const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();-
358 const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));-
359 max_column_width = qMax(min_column_width, max_column_width);-
360-
361 //calculate position-
362 const int base_y = vmargin + fw + topmargin +-
363 (scroll ? scroll->scrollOffset : 0) +
scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
364 tearoffHeight;-
365 int x = hmargin + fw + leftmargin;-
366 y = base_y;-
367-
368 for(int i = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
369 QRect &rect = actionRects[i];-
370 if (rect.isNull())
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
371 continue;
never executed: continue;
0
372 if (!scroll &&
!scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
373 y+rect.height() > dh - deskFw * 2) {
y+rect.height(...h - deskFw * 2Description
TRUEnever evaluated
FALSEnever evaluated
0
374 x += max_column_width + hmargin;-
375 y = base_y;-
376 }
never executed: end of block
0
377 rect.translate(x, y); //move-
378 rect.setWidth(max_column_width); //uniform width-
379-
380 //we need to update the widgets geometry-
381 if (QWidget *widget = widgetItems.value(actions.at(i))) {
QWidget *widge...actions.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
382 widget->setGeometry(rect);-
383 widget->setVisible(actions.at(i)->isVisible());-
384 }
never executed: end of block
0
385-
386 y += rect.height();-
387 }
never executed: end of block
0
388 itemsDirty = 0;-
389}
never executed: end of block
0
390-
391QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen)-
392{-
393 Q_Q(QMenu);-
394 QSize ret = screen.size();-
395 itemsDirty = true;-
396 updateActionRects(screen);-
397 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);-
398 ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw);-
399 return ret;
never executed: return ret;
0
400}-
401-
402int QMenuPrivate::getLastVisibleAction() const-
403{-
404 //let's try to get the last visible action-
405 int lastVisibleAction = actions.count() - 1;-
406 for (;lastVisibleAction >= 0; --lastVisibleAction) {
lastVisibleAction >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
407 const QAction *action = actions.at(lastVisibleAction);-
408 if (action->isVisible()) {
action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
409 //removing trailing separators-
410 if (action->isSeparator() && collapsibleSeparators)
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
collapsibleSeparatorsDescription
TRUEnever evaluated
FALSEnever evaluated
0
411 continue;
never executed: continue;
0
412 break;
never executed: break;
0
413 }-
414 }
never executed: end of block
0
415 return lastVisibleAction;
never executed: return lastVisibleAction;
0
416}-
417-
418-
419QRect QMenuPrivate::actionRect(QAction *act) const-
420{-
421 int index = actions.indexOf(act);-
422 if (index == -1)
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
423 return QRect();
never executed: return QRect();
0
424-
425 updateActionRects();-
426-
427 //we found the action-
428 return actionRects.at(index);
never executed: return actionRects.at(index);
0
429}-
430-
431void QMenuPrivate::hideUpToMenuBar()-
432{-
433 Q_Q(QMenu);-
434 bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide);-
435 if (!tornoff) {
!tornoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
436 QWidget *caused = causedPopup.widget;-
437 hideMenu(q); //hide after getting causedPopup-
438 while(caused) {
causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
439#ifndef QT_NO_MENUBAR-
440 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
QMenuBar *mb =...uBar*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
441 mb->d_func()->setCurrentAction(0);-
442 mb->d_func()->setKeyboardMode(false);-
443 caused = 0;-
444 } else
never executed: end of block
0
445#endif-
446 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
QMenu *m = qob...Menu*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
447 caused = m->d_func()->causedPopup.widget;-
448 if (!m->d_func()->tornoff)
!m->d_func()->tornoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
449 hideMenu(m);
never executed: hideMenu(m);
0
450 if (!fadeMenus) // Mac doesn't clear the action until after hidden.
!fadeMenusDescription
TRUEnever evaluated
FALSEnever evaluated
0
451 m->d_func()->setCurrentAction(0);
never executed: m->d_func()->setCurrentAction(0);
0
452 } else { caused = 0;
never executed: end of block
0
453 }
never executed: end of block
0
454 }-
455 }
never executed: end of block
0
456 setCurrentAction(0);-
457}
never executed: end of block
0
458-
459void QMenuPrivate::hideMenu(QMenu *menu)-
460{-
461 if (!menu)
!menuDescription
TRUEnever evaluated
FALSEnever evaluated
0
462 return;
never executed: return;
0
463#if !defined(QT_NO_EFFECTS)-
464 QSignalBlocker blocker(menu);-
465 aboutToHide = true;-
466 // Flash item which is about to trigger (if any).-
467 if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)
menu->style()-...TriggeredItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
468 && currentAction && currentAction == actionAboutToTrigger
currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
currentAction ...AboutToTriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
469 && menu->actions().contains(currentAction)) {
menu->actions(...currentAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
470 QEventLoop eventLoop;-
471 QAction *activeAction = currentAction;-
472-
473 menu->setActiveAction(0);-
474 QTimer::singleShot(60, &eventLoop, SLOT(quit()));-
475 eventLoop.exec();-
476-
477 // Select and wait 20 ms.-
478 menu->setActiveAction(activeAction);-
479 QTimer::singleShot(20, &eventLoop, SLOT(quit()));-
480 eventLoop.exec();-
481 }
never executed: end of block
0
482-
483 aboutToHide = false;-
484 blocker.unblock();-
485#endif // QT_NO_EFFECTS-
486 if (activeMenu == menu)
activeMenu == menuDescription
TRUEnever evaluated
FALSEnever evaluated
0
487 activeMenu = 0;
never executed: activeMenu = 0;
0
488 menu->d_func()->causedPopup.action = 0;-
489 menu->close();-
490 menu->d_func()->causedPopup.widget = 0;-
491}
never executed: end of block
0
492-
493void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst)-
494{-
495 Q_Q(QMenu);-
496 if (action) {
actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
497 if (action->isEnabled()) {
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
498 if (!delay)
!delayDescription
TRUEnever evaluated
FALSEnever evaluated
0
499 q->internalDelayedPopup();
never executed: q->internalDelayedPopup();
0
500 else if (action->menu() && !action->menu()->isVisible())
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
!action->menu()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
501 delayState.start(delay, action);
never executed: delayState.start(delay, action);
0
502 else if (!action->menu())
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
503 delayState.stop();
never executed: delayState.stop();
0
504 if (activateFirst && action->menu())
activateFirstDescription
TRUEnever evaluated
FALSEnever evaluated
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
505 action->menu()->d_func()->setFirstActionActive();
never executed: action->menu()->d_func()->setFirstActionActive();
0
506 }
never executed: end of block
0
507 } else if (QMenu *menu = activeMenu) { //hide the current item
never executed: end of block
QMenu *menu = activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
508 hideMenu(menu);-
509 }
never executed: end of block
0
510}
never executed: end of block
0
511-
512void QMenuPrivate::setSyncAction()-
513{-
514 Q_Q(QMenu);-
515 QAction *current = currentAction;-
516 if(current && (!current->isEnabled() || current->menu() || current->isSeparator()))
currentDescription
TRUEnever evaluated
FALSEnever evaluated
!current->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
current->menu()Description
TRUEnever evaluated
FALSEnever evaluated
current->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
517 current = 0;
never executed: current = 0;
0
518 for(QWidget *caused = q; caused;) {
causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
519 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
QMenu *m = qob...Menu*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
520 caused = m->d_func()->causedPopup.widget;-
521 if (m->d_func()->eventLoop)
m->d_func()->eventLoopDescription
TRUEnever evaluated
FALSEnever evaluated
0
522 m->d_func()->syncAction = current; // synchronous operation
never executed: m->d_func()->syncAction = current;
0
523 } else {
never executed: end of block
0
524 break;
never executed: break;
0
525 }-
526 }-
527}
never executed: end of block
0
528-
529-
530void QMenuPrivate::setFirstActionActive()-
531{-
532 Q_Q(QMenu);-
533 updateActionRects();-
534 for(int i = 0, saccum = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
535 const QRect &rect = actionRects.at(i);-
536 if (rect.isNull())
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
537 continue;
never executed: continue;
0
538 if (scroll && scroll->scrollFlags & QMenuScroller::ScrollUp) {
scrollDescription
TRUEnever evaluated
FALSEnever evaluated
scroll->scroll...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
539 saccum -= rect.height();-
540 if (saccum > scroll->scrollOffset - scrollerHeight())
saccum > scrol...rollerHeight()Description
TRUEnever evaluated
FALSEnever evaluated
0
541 continue;
never executed: continue;
0
542 }
never executed: end of block
0
543 QAction *act = actions.at(i);-
544 if (!act->isSeparator() &&
!act->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
545 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
q->style()->st...isabled, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
546 || act->isEnabled())) {
act->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
547 setCurrentAction(act);-
548 break;
never executed: break;
0
549 }-
550 }
never executed: end of block
0
551}
never executed: end of block
0
552-
553// popup == -1 means do not popup, 0 means immediately, others mean use a timer-
554void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason reason, bool activateFirst)-
555{-
556 Q_Q(QMenu);-
557 tearoffHighlighted = 0;-
558-
559 if (action
actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
560 && (action->isSeparator()
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
561 || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q))))
!action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!q->style()->s...isabled, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
562 action = Q_NULLPTR;
never executed: action = nullptr;
0
563-
564 // Reselect the currently active action in case mouse moved over other menu items when-
565 // moving from sub menu action to sub menu (QTBUG-20094).-
566 if (reason != SelectedFromKeyboard) {
reason != SelectedFromKeyboardDescription
TRUEnever evaluated
FALSEnever evaluated
0
567 if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
QMenu *menu = ...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
568 if (causedPopup.action && menu->d_func()->activeMenu == q)
causedPopup.actionDescription
TRUEnever evaluated
FALSEnever evaluated
menu->d_func()...ctiveMenu == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
569 // Reselect parent menu action only if mouse is over a menu and parent menu action is not already selected (QTBUG-47987)-
570 if (hasReceievedEnter && menu->d_func()->currentAction != causedPopup.action)
hasReceievedEnterDescription
TRUEnever evaluated
FALSEnever evaluated
menu->d_func()...edPopup.actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
571 menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
never executed: menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
0
572 }
never executed: end of block
0
573 }
never executed: end of block
0
574-
575 if (currentAction)
currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
576 q->update(actionRect(currentAction));
never executed: q->update(actionRect(currentAction));
0
577-
578 QMenu *hideActiveMenu = activeMenu;-
579 QAction *previousAction = currentAction;-
580-
581 currentAction = action;-
582 if (action) {
actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
583 if (!action->isSeparator()) {
!action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
584 activateAction(action, QAction::Hover);-
585 if (popup != -1) {
popup != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
586 // if the menu is visible then activate the required action,-
587 // otherwise we just mark the action as currentAction-
588 // and activate it when the menu will be popuped.-
589 if (q->isVisible())
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
590 popupAction(currentAction, popup, activateFirst);
never executed: popupAction(currentAction, popup, activateFirst);
0
591 }
never executed: end of block
0
592 q->update(actionRect(action));-
593-
594 if (reason == SelectedFromKeyboard) {
reason == SelectedFromKeyboardDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 QWidget *widget = widgetItems.value(action);-
596 if (widget) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
597 if (widget->focusPolicy() != Qt::NoFocus)
widget->focusP...!= Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
598 widget->setFocus(Qt::TabFocusReason);
never executed: widget->setFocus(Qt::TabFocusReason);
0
599 } else {
never executed: end of block
0
600 //when the action has no QWidget, the QMenu itself should-
601 // get the focus-
602 // Since the menu is a pop-up, it uses the popup reason.-
603 if (!q->hasFocus()) {
!q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
604 q->setFocus(Qt::PopupFocusReason);-
605 }
never executed: end of block
0
606 }
never executed: end of block
0
607 }-
608 }
never executed: end of block
0
609#ifndef QT_NO_STATUSTIP-
610 } else if (previousAction) {
never executed: end of block
previousActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
611 previousAction->d_func()->showStatusText(topCausedWidget(), QString());-
612#endif-
613 }
never executed: end of block
0
614 if (hideActiveMenu && previousAction != currentAction) {
hideActiveMenuDescription
TRUEnever evaluated
FALSEnever evaluated
previousAction... currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
615 if (popup == -1) {
popup == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
616#ifndef QT_NO_EFFECTS-
617 // kill any running effect-
618 qFadeEffect(0);-
619 qScrollEffect(0);-
620#endif-
621 hideMenu(hideActiveMenu);-
622 } else if (!currentAction || !currentAction->menu()) {
never executed: end of block
!currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
!currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
623 sloppyState.startTimerIfNotRunning();-
624 }
never executed: end of block
0
625 }
never executed: end of block
0
626}
never executed: end of block
0
627-
628void QMenuSloppyState::reset()-
629{-
630 m_enabled = false;-
631 m_first_mouse = true;-
632 m_init_guard = false;-
633 m_uni_dir_discarded_count = 0;-
634 m_time.stop();-
635 m_reset_action = Q_NULLPTR;-
636 m_origin_action = Q_NULLPTR;-
637 m_action_rect = QRect();-
638 m_previous_point = QPointF();-
639 if (m_sub_menu) {
m_sub_menuDescription
TRUEnever evaluated
FALSEnever evaluated
0
640 QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = Q_NULLPTR;-
641 m_sub_menu = Q_NULLPTR;-
642 }
never executed: end of block
0
643}
never executed: end of block
0
644void QMenuSloppyState::enter()-
645{-
646 QMenuPrivate *menuPriv = QMenuPrivate::get(m_menu);-
647-
648 if (m_discard_state_when_entering_parent && m_sub_menu == menuPriv->activeMenu) {
m_discard_stat...ntering_parentDescription
TRUEnever evaluated
FALSEnever evaluated
m_sub_menu == ...iv->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
649 menuPriv->hideMenu(m_sub_menu);-
650 reset();-
651 }
never executed: end of block
0
652 if (m_parent)
m_parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
653 m_parent->childEnter();
never executed: m_parent->childEnter();
0
654}
never executed: end of block
0
655-
656void QMenuSloppyState::childEnter()-
657{-
658 stopTimer();-
659 if (m_parent)
m_parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
660 m_parent->childEnter();
never executed: m_parent->childEnter();
0
661}
never executed: end of block
0
662-
663void QMenuSloppyState::leave()-
664{-
665 if (!m_dont_start_time_on_leave) {
!m_dont_start_time_on_leaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
666 if (m_parent)
m_parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
667 m_parent->childLeave();
never executed: m_parent->childLeave();
0
668 startTimerIfNotRunning();-
669 }
never executed: end of block
0
670}
never executed: end of block
0
671-
672void QMenuSloppyState::childLeave()-
673{-
674 if (m_enabled && !QMenuPrivate::get(m_menu)->hasReceievedEnter) {
m_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!QMenuPrivate:...ReceievedEnterDescription
TRUEnever evaluated
FALSEnever evaluated
0
675 startTimerIfNotRunning();-
676 if (m_parent)
m_parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
677 m_parent->childLeave();
never executed: m_parent->childLeave();
0
678 }
never executed: end of block
0
679}
never executed: end of block
0
680-
681void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu)-
682{-
683 m_enabled = true;-
684 m_init_guard = true;-
685 m_time.stop();-
686 m_action_rect = actionRect;-
687 m_sub_menu = subMenu;-
688 QMenuPrivate::get(subMenu)->sloppyState.m_parent = this;-
689 m_reset_action = resetAction;-
690 m_origin_action = resetAction;-
691}
never executed: end of block
0
692-
693bool QMenuSloppyState::hasParentActiveDelayTimer() const-
694{-
695 return m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive();
never executed: return m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive();
m_parentDescription
TRUEnever evaluated
FALSEnever evaluated
m_parent->m_menuDescription
TRUEnever evaluated
FALSEnever evaluated
QMenuPrivate::...mer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
696}-
697-
698class ResetOnDestroy-
699{-
700public:-
701 ResetOnDestroy(QMenuSloppyState *sloppyState, bool *guard)-
702 : toReset(sloppyState)-
703 , guard(guard)-
704 {-
705 *guard = false;-
706 }
never executed: end of block
0
707-
708 ~ResetOnDestroy()-
709 {-
710 if (!*guard)
!*guardDescription
TRUEnever evaluated
FALSEnever evaluated
0
711 toReset->reset();
never executed: toReset->reset();
0
712 }
never executed: end of block
0
713-
714 QMenuSloppyState *toReset;-
715 bool *guard;-
716};-
717-
718void QMenuSloppyState::timeout()-
719{-
720 QMenuPrivate *menu_priv = QMenuPrivate::get(m_menu);-
721-
722 bool reallyHasMouse = menu_priv->hasReceievedEnter;-
723 if (!reallyHasMouse) {
!reallyHasMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
724 // Check whether the menu really has a mouse, because only active popup-
725 // menu gets the enter/leave events. Currently Cocoa is an exception.-
726 const QPoint lastCursorPos = QGuiApplicationPrivate::lastCursorPosition.toPoint();-
727 reallyHasMouse = m_menu->frameGeometry().contains(lastCursorPos);-
728 }
never executed: end of block
0
729-
730 if (menu_priv->currentAction == m_reset_action
menu_priv->cur...m_reset_actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
731 && reallyHasMouse
reallyHasMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
732 && (menu_priv->currentAction
menu_priv->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
733 && menu_priv->currentAction->menu() == menu_priv->activeMenu)) {
menu_priv->cur...iv->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
734 return;
never executed: return;
0
735 }-
736-
737 ResetOnDestroy resetState(this, &m_init_guard);-
738-
739 if (hasParentActiveDelayTimer() || !m_menu->isVisible())
hasParentActiveDelayTimer()Description
TRUEnever evaluated
FALSEnever evaluated
!m_menu->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
740 return;
never executed: return;
0
741-
742 if (m_sub_menu)
m_sub_menuDescription
TRUEnever evaluated
FALSEnever evaluated
0
743 menu_priv->hideMenu(m_sub_menu);
never executed: menu_priv->hideMenu(m_sub_menu);
0
744-
745 if (reallyHasMouse)
reallyHasMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
746 menu_priv->setCurrentAction(m_reset_action,0);
never executed: menu_priv->setCurrentAction(m_reset_action,0);
0
747 else-
748 menu_priv->setCurrentAction(Q_NULLPTR, 0);
never executed: menu_priv->setCurrentAction(nullptr, 0);
0
749}-
750-
751//return the top causedPopup.widget that is not a QMenu-
752QWidget *QMenuPrivate::topCausedWidget() const-
753{-
754 QWidget* top = causedPopup.widget;-
755 while (QMenu* m = qobject_cast<QMenu *>(top))
QMenu* m = qob...<QMenu *>(top)Description
TRUEnever evaluated
FALSEnever evaluated
0
756 top = m->d_func()->causedPopup.widget;
never executed: top = m->d_func()->causedPopup.widget;
0
757 return top;
never executed: return top;
0
758}-
759-
760QAction *QMenuPrivate::actionAt(QPoint p) const-
761{-
762 if (!q_func()->rect().contains(p)) //sanity check
!q_func()->rect().contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
0
763 return 0;
never executed: return 0;
0
764-
765 for(int i = 0; i < actionRects.count(); i++) {
i < actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
766 if (actionRects.at(i).contains(p))
actionRects.at(i).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
0
767 return actions.at(i);
never executed: return actions.at(i);
0
768 }
never executed: end of block
0
769 return 0;
never executed: return 0;
0
770}-
771-
772void QMenuPrivate::setOverrideMenuAction(QAction *a)-
773{-
774 Q_Q(QMenu);-
775 QObject::disconnect(menuAction, SIGNAL(destroyed()), q, SLOT(_q_overrideMenuActionDestroyed()));-
776 if (a) {
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
777 menuAction = a;-
778 QObject::connect(a, SIGNAL(destroyed()), q, SLOT(_q_overrideMenuActionDestroyed()));-
779 } else { //we revert back to the default action created by the QMenu itself
never executed: end of block
0
780 menuAction = defaultMenuAction;-
781 }
never executed: end of block
0
782}-
783-
784void QMenuPrivate::_q_overrideMenuActionDestroyed()-
785{-
786 menuAction=defaultMenuAction;-
787}
never executed: end of block
0
788-
789-
790void QMenuPrivate::updateLayoutDirection()-
791{-
792 Q_Q(QMenu);-
793 //we need to mimic the cause of the popup's layout direction-
794 //to allow setting it on a mainwindow for example-
795 //we call setLayoutDirection_helper to not overwrite a user-defined value-
796 if (!q->testAttribute(Qt::WA_SetLayoutDirection)) {
!q->testAttrib...youtDirection)Description
TRUEnever evaluated
FALSEnever evaluated
0
797 if (QWidget *w = causedPopup.widget)
QWidget *w = c...edPopup.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 setLayoutDirection_helper(w->layoutDirection());
never executed: setLayoutDirection_helper(w->layoutDirection());
0
799 else if (QWidget *w = q->parentWidget())
QWidget *w = q->parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
800 setLayoutDirection_helper(w->layoutDirection());
never executed: setLayoutDirection_helper(w->layoutDirection());
0
801 else-
802 setLayoutDirection_helper(QApplication::layoutDirection());
never executed: setLayoutDirection_helper(QApplication::layoutDirection());
0
803 }-
804}
never executed: end of block
0
805-
806-
807/*!-
808 Returns the action associated with this menu.-
809*/-
810QAction *QMenu::menuAction() const-
811{-
812 return d_func()->menuAction;
never executed: return d_func()->menuAction;
0
813}-
814-
815/*!-
816 \property QMenu::title-
817 \brief The title of the menu-
818-
819 This is equivalent to the QAction::text property of the menuAction().-
820-
821 By default, this property contains an empty string.-
822*/-
823QString QMenu::title() const-
824{-
825 return d_func()->menuAction->text();
never executed: return d_func()->menuAction->text();
0
826}-
827-
828void QMenu::setTitle(const QString &text)-
829{-
830 d_func()->menuAction->setText(text);-
831}
never executed: end of block
0
832-
833/*!-
834 \property QMenu::icon-
835-
836 \brief The icon of the menu-
837-
838 This is equivalent to the QAction::icon property of the menuAction().-
839-
840 By default, if no icon is explicitly set, this property contains a null icon.-
841*/-
842QIcon QMenu::icon() const-
843{-
844 return d_func()->menuAction->icon();
never executed: return d_func()->menuAction->icon();
0
845}-
846-
847void QMenu::setIcon(const QIcon &icon)-
848{-
849 d_func()->menuAction->setIcon(icon);-
850}
never executed: end of block
0
851-
852-
853//actually performs the scrolling-
854void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active)-
855{-
856 Q_Q(QMenu);-
857 if (!scroll || !scroll->scrollFlags)
!scrollDescription
TRUEnever evaluated
FALSEnever evaluated
!scroll->scrollFlagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 return;
never executed: return;
0
859 updateActionRects();-
860 int newOffset = 0;-
861 const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
(scroll->scrol...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
0
862 const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
(scroll->scrol...r::ScrollDown)Description
TRUEnever evaluated
FALSEnever evaluated
0
863 const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);-
864 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);-
865-
866 if (location == QMenuScroller::ScrollTop) {
location == QM...ler::ScrollTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
867 for(int i = 0, saccum = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
868 if (actions.at(i) == action) {
actions.at(i) == actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
869 newOffset = topScroll - saccum;-
870 break;
never executed: break;
0
871 }-
872 saccum += actionRects.at(i).height();-
873 }
never executed: end of block
0
874 } else {
never executed: end of block
0
875 for(int i = 0, saccum = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
876 saccum += actionRects.at(i).height();-
877 if (actions.at(i) == action) {
actions.at(i) == actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
878 if (location == QMenuScroller::ScrollCenter)
location == QM...::ScrollCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
879 newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
never executed: newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
0
880 else-
881 newOffset = (q->height() - botScroll) - saccum;
never executed: newOffset = (q->height() - botScroll) - saccum;
0
882 break;
never executed: break;
0
883 }-
884 }
never executed: end of block
0
885 if(newOffset)
newOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
886 newOffset -= fw * 2;
never executed: newOffset -= fw * 2;
0
887 }
never executed: end of block
0
888-
889 //figure out which scroll flags-
890 uint newScrollFlags = QMenuScroller::ScrollNone;-
891 if (newOffset < 0) //easy and cheap one
newOffset < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
892 newScrollFlags |= QMenuScroller::ScrollUp;
never executed: newScrollFlags |= QMenuScroller::ScrollUp;
0
893 int saccum = newOffset;-
894 for(int i = 0; i < actionRects.count(); i++) {
i < actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
895 saccum += actionRects.at(i).height();-
896 if (saccum > q->height()) {
saccum > q->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
897 newScrollFlags |= QMenuScroller::ScrollDown;-
898 break;
never executed: break;
0
899 }-
900 }
never executed: end of block
0
901-
902 if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) {
!(newScrollFla...r::ScrollDown)Description
TRUEnever evaluated
FALSEnever evaluated
(scroll->scrol...r::ScrollDown)Description
TRUEnever evaluated
FALSEnever evaluated
0
903 newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin; //last item at bottom-
904 }
never executed: end of block
0
905-
906 if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) {
!(newScrollFla...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
(scroll->scrol...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
0
907 newOffset = 0; //first item at top-
908 }
never executed: end of block
0
909-
910 if (newScrollFlags & QMenuScroller::ScrollUp)
newScrollFlags...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
911 newOffset -= vmargin;
never executed: newOffset -= vmargin;
0
912-
913 QRect screen = popupGeometry(q);-
914 const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);-
915 if (q->height() < screen.height()-(desktopFrame*2)-1) {
q->height() < ...ktopFrame*2)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
916 QRect geom = q->geometry();-
917 if (newOffset > scroll->scrollOffset && (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)) { //scroll up
newOffset > sc...->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
(scroll->scrol...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
0
918 const int newHeight = geom.height()-(newOffset-scroll->scrollOffset);-
919 if(newHeight > geom.height())
newHeight > geom.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
920 geom.setHeight(newHeight);
never executed: geom.setHeight(newHeight);
0
921 } else if(scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollDown) {
never executed: end of block
scroll->scroll...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
922 int newTop = geom.top() + (newOffset-scroll->scrollOffset);-
923 if (newTop < desktopFrame+screen.top())
newTop < deskt...e+screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
924 newTop = desktopFrame+screen.top();
never executed: newTop = desktopFrame+screen.top();
0
925 if (newTop < geom.top()) {
newTop < geom.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
926 geom.setTop(newTop);-
927 newOffset = 0;-
928 newScrollFlags &= ~QMenuScroller::ScrollUp;-
929 }
never executed: end of block
0
930 }
never executed: end of block
0
931 if (geom.bottom() > screen.bottom() - desktopFrame)
geom.bottom() ...- desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
932 geom.setBottom(screen.bottom() - desktopFrame);
never executed: geom.setBottom(screen.bottom() - desktopFrame);
0
933 if (geom.top() < desktopFrame+screen.top())
geom.top() < d...e+screen.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
934 geom.setTop(desktopFrame+screen.top());
never executed: geom.setTop(desktopFrame+screen.top());
0
935 if (geom != q->geometry()) {
geom != q->geometry()Description
TRUEnever evaluated
FALSEnever evaluated
0
936#if 0-
937 if (newScrollFlags & QMenuScroller::ScrollDown &&-
938 q->geometry().top() - geom.top() >= -newOffset)-
939 newScrollFlags &= ~QMenuScroller::ScrollDown;-
940#endif-
941 q->setGeometry(geom);-
942 }
never executed: end of block
0
943 }
never executed: end of block
0
944-
945 //actually update flags-
946 const int delta = qMin(0, newOffset) - scroll->scrollOffset; //make sure the new offset is always negative-
947 if (!itemsDirty && delta) {
!itemsDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
deltaDescription
TRUEnever evaluated
FALSEnever evaluated
0
948 //we've scrolled so we need to update the action rects-
949 for (int i = 0; i < actionRects.count(); ++i) {
i < actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
950 QRect &current = actionRects[i];-
951 current.moveTop(current.top() + delta);-
952-
953 //we need to update the widgets geometry-
954 if (QWidget *w = widgetItems.value(actions.at(i)))
QWidget *w = w...actions.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
955 w->setGeometry(current);
never executed: w->setGeometry(current);
0
956 }
never executed: end of block
0
957 }
never executed: end of block
0
958 scroll->scrollOffset += delta;-
959 scroll->scrollFlags = newScrollFlags;-
960 if (active)
activeDescription
TRUEnever evaluated
FALSEnever evaluated
0
961 setCurrentAction(action);
never executed: setCurrentAction(action);
0
962-
963 q->update(); //issue an update so we see all the new state..-
964}
never executed: end of block
0
965-
966void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool active)-
967{-
968 Q_Q(QMenu);-
969 updateActionRects();-
970 if(location == QMenuScroller::ScrollBottom) {
location == QM...::ScrollBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
971 for(int i = actions.size()-1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
972 QAction *act = actions.at(i);-
973 if (actionRects.at(i).isNull())
actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
974 continue;
never executed: continue;
0
975 if (!act->isSeparator() &&
!act->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
976 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
q->style()->st...isabled, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
977 || act->isEnabled())) {
act->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
978 if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
scroll->scroll...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
979 scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active);
never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active);
0
980 else if(active)
activeDescription
TRUEnever evaluated
FALSEnever evaluated
0
981 setCurrentAction(act, /*popup*/-1, QMenuPrivate::SelectedFromKeyboard);
never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
0
982 break;
never executed: break;
0
983 }-
984 }
never executed: end of block
0
985 } else if(location == QMenuScroller::ScrollTop) {
never executed: end of block
location == QM...ler::ScrollTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
986 for(int i = 0; i < actions.size(); ++i) {
i < actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
987 QAction *act = actions.at(i);-
988 if (actionRects.at(i).isNull())
actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
989 continue;
never executed: continue;
0
990 if (!act->isSeparator() &&
!act->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
991 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
q->style()->st...isabled, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
992 || act->isEnabled())) {
act->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
993 if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
scroll->scroll...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
994 scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active);
never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active);
0
995 else if(active)
activeDescription
TRUEnever evaluated
FALSEnever evaluated
0
996 setCurrentAction(act, /*popup*/-1, QMenuPrivate::SelectedFromKeyboard);
never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
0
997 break;
never executed: break;
0
998 }-
999 }
never executed: end of block
0
1000 }
never executed: end of block
0
1001}
never executed: end of block
0
1002-
1003//only directional-
1004void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool page, bool active)-
1005{-
1006 Q_Q(QMenu);-
1007 if (!scroll || !(scroll->scrollFlags & direction)) //not really possible...
!scrollDescription
TRUEnever evaluated
FALSEnever evaluated
!(scroll->scro...s & direction)Description
TRUEnever evaluated
FALSEnever evaluated
0
1008 return;
never executed: return;
0
1009 updateActionRects();-
1010 const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
(scroll->scrol...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
0
1011 const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
(scroll->scrol...r::ScrollDown)Description
TRUEnever evaluated
FALSEnever evaluated
0
1012 const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);-
1013 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);-
1014 const int offset = topScroll ? topScroll-vmargin : 0;
topScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1015 if (direction == QMenuScroller::ScrollUp) {
direction == Q...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
1016 for(int i = 0, saccum = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1017 saccum -= actionRects.at(i).height();-
1018 if (saccum <= scroll->scrollOffset-offset) {
saccum <= scro...lOffset-offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1019 scrollMenu(actions.at(i), page ? QMenuScroller::ScrollBottom : QMenuScroller::ScrollTop, active);-
1020 break;
never executed: break;
0
1021 }-
1022 }
never executed: end of block
0
1023 } else if (direction == QMenuScroller::ScrollDown) {
never executed: end of block
direction == Q...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
1024 bool scrolled = false;-
1025 for(int i = 0, saccum = 0; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1026 const int iHeight = actionRects.at(i).height();-
1027 saccum -= iHeight;-
1028 if (saccum <= scroll->scrollOffset-offset) {
saccum <= scro...lOffset-offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1029 const int scrollerArea = q->height() - botScroll - fw*2;-
1030 int visible = (scroll->scrollOffset-offset) - saccum;-
1031 for(i++ ; i < actions.count(); i++) {
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1032 visible += actionRects.at(i).height();-
1033 if (visible > scrollerArea - topScroll) {
visible > scro...ea - topScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1034 scrolled = true;-
1035 scrollMenu(actions.at(i), page ? QMenuScroller::ScrollTop : QMenuScroller::ScrollBottom, active);-
1036 break;
never executed: break;
0
1037 }-
1038 }
never executed: end of block
0
1039 break;
never executed: break;
0
1040 }-
1041 }
never executed: end of block
0
1042 if(!scrolled) {
!scrolledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1043 scroll->scrollFlags &= ~QMenuScroller::ScrollDown;-
1044 q->update();-
1045 }
never executed: end of block
0
1046 }
never executed: end of block
0
1047}
never executed: end of block
0
1048-
1049/* This is poor-mans eventfilters. This avoids the use of-
1050 eventFilter (which can be nasty for users of QMenuBar's). */-
1051bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)-
1052{-
1053 Q_Q(QMenu);-
1054 QPoint pos = q->mapFromGlobal(e->globalPos());-
1055 if (scroll && !activeMenu) { //let the scroller "steal" the event
scrollDescription
TRUEnever evaluated
FALSEnever evaluated
!activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
1056 bool isScroll = false;-
1057 if (pos.x() >= 0 && pos.x() < q->width()) {
pos.x() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
pos.x() < q->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1058 for(int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown; dir = dir << 1) {
dir <= QMenuSc...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
1059 if (scroll->scrollFlags & dir) {
scroll->scrollFlags & dirDescription
TRUEnever evaluated
FALSEnever evaluated
0
1060 if (dir == QMenuScroller::ScrollUp)
dir == QMenuScroller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
1061 isScroll = (pos.y() <= scrollerHeight());
never executed: isScroll = (pos.y() <= scrollerHeight());
0
1062 else if (dir == QMenuScroller::ScrollDown)
dir == QMenuSc...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
1063 isScroll = (pos.y() >= q->height() - scrollerHeight());
never executed: isScroll = (pos.y() >= q->height() - scrollerHeight());
0
1064 if (isScroll) {
isScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1065 scroll->scrollDirection = dir;-
1066 break;
never executed: break;
0
1067 }-
1068 }
never executed: end of block
0
1069 }
never executed: end of block
0
1070 }
never executed: end of block
0
1071 if (isScroll) {
isScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1072 scroll->scrollTimer.start(50, q);-
1073 return true;
never executed: return true;
0
1074 } else {-
1075 scroll->scrollTimer.stop();-
1076 }
never executed: end of block
0
1077 }-
1078-
1079 if (tearoff) { //let the tear off thingie "steal" the event..
tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
1080 QRect tearRect(0, 0, q->width(), q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q));-
1081 if (scroll && scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
scrollDescription
TRUEnever evaluated
FALSEnever evaluated
scroll->scroll...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
1082 tearRect.translate(0, scrollerHeight());
never executed: tearRect.translate(0, scrollerHeight());
0
1083 q->update(tearRect);-
1084 if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) {
tearRect.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
hasMouseMoved(e->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1085 setCurrentAction(0);-
1086 tearoffHighlighted = 1;-
1087 if (e->type() == QEvent::MouseButtonRelease) {
e->type() == Q...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
1088 if (!tornPopup)
!tornPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1089 tornPopup = new QTornOffMenu(q);
never executed: tornPopup = new QTornOffMenu(q);
0
1090 tornPopup->setGeometry(q->geometry());-
1091 tornPopup->show();-
1092 hideUpToMenuBar();-
1093 }
never executed: end of block
0
1094 return true;
never executed: return true;
0
1095 }-
1096 tearoffHighlighted = 0;-
1097 }
never executed: end of block
0
1098-
1099 if (q->frameGeometry().contains(e->globalPos()))
q->frameGeomet...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1100 return false; //otherwise if the event is in our rect we want it..
never executed: return false;
0
1101-
1102 for(QWidget *caused = causedPopup.widget; caused;) {
causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1103 bool passOnEvent = false;-
1104 QWidget *next_widget = 0;-
1105 QPoint cpos = caused->mapFromGlobal(e->globalPos());-
1106#ifndef QT_NO_MENUBAR-
1107 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
QMenuBar *mb =...uBar*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
1108 passOnEvent = mb->rect().contains(cpos);-
1109 } else
never executed: end of block
0
1110#endif-
1111 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
QMenu *m = qob...Menu*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
1112 passOnEvent = m->rect().contains(cpos);-
1113 next_widget = m->d_func()->causedPopup.widget;-
1114 }
never executed: end of block
0
1115 if (passOnEvent) {
passOnEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
1116 if (e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
e->type() != Q...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
mouseDown == causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1117 QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(),-
1118 e->button(), e->buttons(), e->modifiers(), e->source());-
1119 QApplication::sendEvent(caused, &new_e);-
1120 return true;
never executed: return true;
0
1121 }-
1122 }
never executed: end of block
0
1123 caused = next_widget;-
1124 if (!caused)
!causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1125 sloppyState.leave(); // Start timers
never executed: sloppyState.leave();
0
1126 }
never executed: end of block
0
1127 return false;
never executed: return false;
0
1128}-
1129-
1130void QMenuPrivate::activateCausedStack(const QVector<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)-
1131{-
1132 QBoolBlocker guard(activationRecursionGuard);-
1133 if(self)
selfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1134 action->activate(action_e);
never executed: action->activate(action_e);
0
1135-
1136 for(int i = 0; i < causedStack.size(); ++i) {
i < causedStack.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1137 QPointer<QWidget> widget = causedStack.at(i);-
1138 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1139 continue;
never executed: continue;
0
1140 //fire-
1141 if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
QMenu *qmenu =...Menu*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1142 widget = qmenu->d_func()->causedPopup.widget;-
1143 if (action_e == QAction::Trigger) {
action_e == QAction::TriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1144 emit qmenu->triggered(action);-
1145 } else if (action_e == QAction::Hover) {
never executed: end of block
action_e == QAction::HoverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1146 emit qmenu->hovered(action);-
1147 }
never executed: end of block
0
1148#ifndef QT_NO_MENUBAR-
1149 } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
never executed: end of block
QMenuBar *qmen...uBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1150 if (action_e == QAction::Trigger) {
action_e == QAction::TriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1151 emit qmenubar->triggered(action);-
1152 } else if (action_e == QAction::Hover) {
never executed: end of block
action_e == QAction::HoverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1153 emit qmenubar->hovered(action);-
1154 }
never executed: end of block
0
1155 break; //nothing more..
never executed: break;
0
1156#endif-
1157 }-
1158 }
never executed: end of block
0
1159}
never executed: end of block
0
1160-
1161void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e, bool self)-
1162{-
1163 Q_Q(QMenu);-
1164#ifndef QT_NO_WHATSTHIS-
1165 bool inWhatsThisMode = QWhatsThis::inWhatsThisMode();-
1166#endif-
1167 if (!action || !q->isEnabled()
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
!q->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1168 || (action_e == QAction::Trigger
action_e == QAction::TriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1169#ifndef QT_NO_WHATSTHIS-
1170 && !inWhatsThisMode
!inWhatsThisModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1171#endif-
1172 && (action->isSeparator() ||!action->isEnabled())))
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
!action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1173 return;
never executed: return;
0
1174-
1175 /* I have to save the caused stack here because it will be undone after popup execution (ie in the hide).-
1176 Then I iterate over the list to actually send the events. --Sam-
1177 */-
1178 const QVector<QPointer<QWidget> > causedStack = calcCausedStack();-
1179 if (action_e == QAction::Trigger) {
action_e == QAction::TriggerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1180#ifndef QT_NO_WHATSTHIS-
1181 if (!inWhatsThisMode)
!inWhatsThisModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1182 actionAboutToTrigger = action;
never executed: actionAboutToTrigger = action;
0
1183#endif-
1184-
1185 if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
q->testAttribu...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
1186 hideUpToMenuBar();-
1187 } else {
never executed: end of block
0
1188 for(QWidget *widget = QApplication::activePopupWidget(); widget; ) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1189 if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
QMenu *qmenu =...Menu*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1190 if(qmenu == q)
qmenu == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
1191 hideUpToMenuBar();
never executed: hideUpToMenuBar();
0
1192 widget = qmenu->d_func()->causedPopup.widget;-
1193 } else {
never executed: end of block
0
1194 break;
never executed: break;
0
1195 }-
1196 }-
1197 }
never executed: end of block
0
1198-
1199#ifndef QT_NO_WHATSTHIS-
1200 if (inWhatsThisMode) {
inWhatsThisModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1201 QString s = action->whatsThis();-
1202 if (s.isEmpty())
s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1203 s = whatsThis;
never executed: s = whatsThis;
0
1204 QWhatsThis::showText(q->mapToGlobal(actionRect(action).center()), s, q);-
1205 return;
never executed: return;
0
1206 }-
1207#endif-
1208 }
never executed: end of block
0
1209-
1210-
1211 activateCausedStack(causedStack, action, action_e, self);-
1212-
1213-
1214 if (action_e == QAction::Hover) {
action_e == QAction::HoverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1215#ifndef QT_NO_ACCESSIBILITY-
1216 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1217 int actionIndex = indexOf(action);-
1218 QAccessibleEvent focusEvent(q, QAccessible::Focus);-
1219 focusEvent.setChild(actionIndex);-
1220 QAccessible::updateAccessibility(&focusEvent);-
1221 }
never executed: end of block
0
1222#endif-
1223 action->showStatusText(topCausedWidget());-
1224 } else {
never executed: end of block
0
1225 actionAboutToTrigger = 0;-
1226 }
never executed: end of block
0
1227}-
1228-
1229void QMenuPrivate::_q_actionTriggered()-
1230{-
1231 Q_Q(QMenu);-
1232 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
QAction *actio...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
0
1233 QPointer<QAction> actionGuard = action;-
1234 if (platformMenu && widgetItems.value(action))
platformMenuDescription
TRUEnever evaluated
FALSEnever evaluated
widgetItems.value(action)Description
TRUEnever evaluated
FALSEnever evaluated
0
1235 platformMenu->dismiss();
never executed: platformMenu->dismiss();
0
1236 emit q->triggered(action);-
1237 if (!activationRecursionGuard && actionGuard) {
!activationRecursionGuardDescription
TRUEnever evaluated
FALSEnever evaluated
actionGuardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1238 //in case the action has not been activated by the mouse-
1239 //we check the parent hierarchy-
1240 QVector< QPointer<QWidget> > list;-
1241 for(QWidget *widget = q->parentWidget(); widget; ) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1242 if (qobject_cast<QMenu*>(widget)
qobject_cast<QMenu*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1243#ifndef QT_NO_MENUBAR-
1244 || qobject_cast<QMenuBar*>(widget)
qobject_cast<Q...uBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1245#endif-
1246 ) {-
1247 list.append(widget);-
1248 widget = widget->parentWidget();-
1249 } else {
never executed: end of block
0
1250 break;
never executed: break;
0
1251 }-
1252 }-
1253 activateCausedStack(list, action, QAction::Trigger, false);-
1254 }
never executed: end of block
0
1255 }
never executed: end of block
0
1256}
never executed: end of block
0
1257-
1258void QMenuPrivate::_q_actionHovered()-
1259{-
1260 Q_Q(QMenu);-
1261 if (QAction * action = qobject_cast<QAction *>(q->sender())) {
QAction * acti...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
0
1262 emit q->hovered(action);-
1263 }
never executed: end of block
0
1264}
never executed: end of block
0
1265-
1266void QMenuPrivate::_q_platformMenuAboutToShow()-
1267{-
1268 Q_Q(QMenu);-
1269-
1270#ifdef Q_OS_OSX-
1271 if (platformMenu)-
1272 Q_FOREACH (QAction *action, q->actions())-
1273 if (QWidget *widget = widgetItems.value(action))-
1274 if (widget->parent() == q) {-
1275 QPlatformMenuItem *menuItem = platformMenu->menuItemForTag(reinterpret_cast<quintptr>(action));-
1276 moveWidgetToPlatformItem(widget, menuItem);-
1277 platformMenu->syncMenuItem(menuItem);-
1278 }-
1279#endif-
1280-
1281 emit q->aboutToShow();-
1282}
never executed: end of block
0
1283-
1284bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos)-
1285{-
1286 //determines if the mouse has moved (ie its initial position has-
1287 //changed by more than QApplication::startDragDistance()-
1288 //or if there were at least 6 mouse motions)-
1289 return motions > 6 ||
never executed: return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
motions > 6Description
TRUEnever evaluated
FALSEnever evaluated
0
1290 QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
never executed: return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
QApplication::...hattanLength()Description
TRUEnever evaluated
FALSEnever evaluated
0
1291}-
1292-
1293-
1294/*!-
1295 Initialize \a option with the values from this menu and information from \a action. This method-
1296 is useful for subclasses when they need a QStyleOptionMenuItem, but don't want-
1297 to fill in all the information themselves.-
1298-
1299 \sa QStyleOption::initFrom(), QMenuBar::initStyleOption()-
1300*/-
1301void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const-
1302{-
1303 if (!option || !action)
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1304 return;
never executed: return;
0
1305-
1306 Q_D(const QMenu);-
1307 option->initFrom(this);-
1308 option->palette = palette();-
1309 option->state = QStyle::State_None;-
1310-
1311 if (window()->isActiveWindow())
window()->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1312 option->state |= QStyle::State_Active;
never executed: option->state |= QStyle::State_Active;
0
1313 if (isEnabled() && action->isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1314 && (!action->menu() || action->menu()->isEnabled()))
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
action->menu()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1315 option->state |= QStyle::State_Enabled;
never executed: option->state |= QStyle::State_Enabled;
0
1316 else-
1317 option->palette.setCurrentColorGroup(QPalette::Disabled);
never executed: option->palette.setCurrentColorGroup(QPalette::Disabled);
0
1318-
1319 option->font = action->font().resolve(font());-
1320 option->fontMetrics = QFontMetrics(option->font);-
1321-
1322 if (d->currentAction && d->currentAction == action && !d->currentAction->isSeparator()) {
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->currentAction == actionDescription
TRUEnever evaluated
FALSEnever evaluated
!d->currentAct...>isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
1323 option->state |= QStyle::State_Selected-
1324 | (d->mouseDown ? QStyle::State_Sunken : QStyle::State_None);-
1325 }
never executed: end of block
0
1326-
1327 option->menuHasCheckableItems = d->hasCheckableItems;-
1328 if (!action->isCheckable()) {
!action->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1329 option->checkType = QStyleOptionMenuItem::NotCheckable;-
1330 } else {
never executed: end of block
0
1331 option->checkType = (action->actionGroup() && action->actionGroup()->isExclusive())
action->actionGroup()Description
TRUEnever evaluated
FALSEnever evaluated
action->action...>isExclusive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1332 ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive;-
1333 option->checked = action->isChecked();-
1334 }
never executed: end of block
0
1335 if (action->menu())
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
1336 option->menuItemType = QStyleOptionMenuItem::SubMenu;
never executed: option->menuItemType = QStyleOptionMenuItem::SubMenu;
0
1337 else if (action->isSeparator())
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
1338 option->menuItemType = QStyleOptionMenuItem::Separator;
never executed: option->menuItemType = QStyleOptionMenuItem::Separator;
0
1339 else if (d->defaultAction == action)
d->defaultAction == actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1340 option->menuItemType = QStyleOptionMenuItem::DefaultItem;
never executed: option->menuItemType = QStyleOptionMenuItem::DefaultItem;
0
1341 else-
1342 option->menuItemType = QStyleOptionMenuItem::Normal;
never executed: option->menuItemType = QStyleOptionMenuItem::Normal;
0
1343 if (action->isIconVisibleInMenu())
action->isIconVisibleInMenu()Description
TRUEnever evaluated
FALSEnever evaluated
0
1344 option->icon = action->icon();
never executed: option->icon = action->icon();
0
1345 QString textAndAccel = action->text();-
1346#ifndef QT_NO_SHORTCUT-
1347 if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
textAndAccel.i...r('\t')) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1348 QKeySequence seq = action->shortcut();-
1349 if (!seq.isEmpty())
!seq.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1350 textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
never executed: textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
0
1351 }
never executed: end of block
0
1352#endif-
1353 option->text = textAndAccel;-
1354 option->tabWidth = d->tabWidth;-
1355 option->maxIconWidth = d->maxIconWidth;-
1356 option->menuRect = rect();-
1357}
never executed: end of block
0
1358-
1359/*!-
1360 \class QMenu-
1361 \brief The QMenu class provides a menu widget for use in menu-
1362 bars, context menus, and other popup menus.-
1363-
1364 \ingroup mainwindow-classes-
1365 \ingroup basicwidgets-
1366 \inmodule QtWidgets-
1367-
1368 A menu widget is a selection menu. It can be either a pull-down-
1369 menu in a menu bar or a standalone context menu. Pull-down menus-
1370 are shown by the menu bar when the user clicks on the respective-
1371 item or presses the specified shortcut key. Use-
1372 QMenuBar::addMenu() to insert a menu into a menu bar. Context-
1373 menus are usually invoked by some special keyboard key or by-
1374 right-clicking. They can be executed either asynchronously with-
1375 popup() or synchronously with exec(). Menus can also be invoked in-
1376 response to button presses; these are just like context menus-
1377 except for how they are invoked.-
1378-
1379 \table 100%-
1380 \row-
1381 \li \inlineimage fusion-menu.png-
1382 \li \inlineimage windowsxp-menu.png-
1383 \li \inlineimage macintosh-menu.png-
1384 \endtable-
1385 \caption Fig. A menu shown in \l{Fusion Style Widget Gallery}{Fusion widget style},-
1386 \l{Windows XP Style Widget Gallery}{Windows XP widget style},-
1387 and \l{Macintosh Style Widget Gallery}{Macintosh widget style}.-
1388-
1389 \section1 Actions-
1390-
1391 A menu consists of a list of action items. Actions are added with-
1392 the addAction(), addActions() and insertAction() functions. An action-
1393 is represented vertically and rendered by QStyle. In addition, actions-
1394 can have a text label, an optional icon drawn on the very left side,-
1395 and shortcut key sequence such as "Ctrl+X".-
1396-
1397 The existing actions held by a menu can be found with actions().-
1398-
1399 There are four kinds of action items: separators, actions that-
1400 show a submenu, widgets, and actions that perform an action.-
1401 Separators are inserted with addSeparator(), submenus with addMenu(),-
1402 and all other items are considered action items.-
1403-
1404 When inserting action items you usually specify a receiver and a-
1405 slot. The receiver will be notifed whenever the item is-
1406 \l{QAction::triggered()}{triggered()}. In addition, QMenu provides-
1407 two signals, activated() and highlighted(), which signal the-
1408 QAction that was triggered from the menu.-
1409-
1410 You clear a menu with clear() and remove individual action items-
1411 with removeAction().-
1412-
1413 A QMenu can also provide a tear-off menu. A tear-off menu is a-
1414 top-level window that contains a copy of the menu. This makes it-
1415 possible for the user to "tear off" frequently used menus and-
1416 position them in a convenient place on the screen. If you want-
1417 this functionality for a particular menu, insert a tear-off handle-
1418 with setTearOffEnabled(). When using tear-off menus, bear in mind-
1419 that the concept isn't typically used on Microsoft Windows so-
1420 some users may not be familiar with it. Consider using a QToolBar-
1421 instead.-
1422-
1423 Widgets can be inserted into menus with the QWidgetAction class.-
1424 Instances of this class are used to hold widgets, and are inserted-
1425 into menus with the addAction() overload that takes a QAction.-
1426-
1427 Conversely, actions can be added to widgets with the addAction(),-
1428 addActions() and insertAction() functions.-
1429-
1430 \warning To make QMenu visible on the screen, exec() or popup() should be-
1431 used instead of show().-
1432-
1433 \section1 QMenu on Qt for Windows CE-
1434-
1435 If a menu is integrated into the native menubar on Windows Mobile we-
1436 do not support the signals: aboutToHide (), aboutToShow () and hovered ().-
1437 It is not possible to display an icon in a native menu on Windows Mobile.-
1438-
1439 \section1 QMenu on \macos with Qt Build Against Cocoa-
1440-
1441 QMenu can be inserted only once in a menu/menubar. Subsequent insertions will-
1442 have no effect or will result in a disabled menu item.-
1443-
1444 See the \l{mainwindows/menus}{Menus} example for an example of how-
1445 to use QMenuBar and QMenu in your application.-
1446-
1447 \b{Important inherited functions:} addAction(), removeAction(), clear(),-
1448 addSeparator(), and addMenu().-
1449-
1450 \sa QMenuBar, {fowler}{GUI Design Handbook: Menu, Drop-Down and Pop-Up},-
1451 {Application Example}, {Menus Example}-
1452*/-
1453-
1454-
1455/*!-
1456 Constructs a menu with parent \a parent.-
1457-
1458 Although a popup menu is always a top-level widget, if a parent is-
1459 passed the popup menu will be deleted when that parent is-
1460 destroyed (as with any other QObject).-
1461*/-
1462QMenu::QMenu(QWidget *parent)-
1463 : QWidget(*new QMenuPrivate, parent, Qt::Popup)-
1464{-
1465 Q_D(QMenu);-
1466 d->init();-
1467}
never executed: end of block
0
1468-
1469/*!-
1470 Constructs a menu with a \a title and a \a parent.-
1471-
1472 Although a popup menu is always a top-level widget, if a parent is-
1473 passed the popup menu will be deleted when that parent is-
1474 destroyed (as with any other QObject).-
1475-
1476 \sa title-
1477*/-
1478QMenu::QMenu(const QString &title, QWidget *parent)-
1479 : QWidget(*new QMenuPrivate, parent, Qt::Popup)-
1480{-
1481 Q_D(QMenu);-
1482 d->init();-
1483 d->menuAction->setText(title);-
1484}
never executed: end of block
0
1485-
1486/*! \internal-
1487 */-
1488QMenu::QMenu(QMenuPrivate &dd, QWidget *parent)-
1489 : QWidget(dd, parent, Qt::Popup)-
1490{-
1491 Q_D(QMenu);-
1492 d->init();-
1493}
never executed: end of block
0
1494-
1495/*!-
1496 Destroys the menu.-
1497*/-
1498QMenu::~QMenu()-
1499{-
1500 Q_D(QMenu);-
1501 if (!d->widgetItems.isEmpty()) { // avoid detach on shared null hash
!d->widgetItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1502 QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();-
1503 for (; it != d->widgetItems.end(); ++it) {
it != d->widgetItems.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
1504 if (QWidget *widget = it.value()) {
QWidget *widget = it.value()Description
TRUEnever evaluated
FALSEnever evaluated
0
1505 QWidgetAction *action = static_cast<QWidgetAction *>(it.key());-
1506 action->releaseWidget(widget);-
1507 *it = 0;-
1508 }
never executed: end of block
0
1509 }
never executed: end of block
0
1510 }
never executed: end of block
0
1511-
1512 if (d->eventLoop)
d->eventLoopDescription
TRUEnever evaluated
FALSEnever evaluated
0
1513 d->eventLoop->exit();
never executed: d->eventLoop->exit();
0
1514 hideTearOffMenu();-
1515}
never executed: end of block
0
1516-
1517/*!-
1518 \overload-
1519-
1520 This convenience function creates a new action with \a text.-
1521 The function adds the newly created action to the menu's-
1522 list of actions, and returns it.-
1523-
1524 QMenu takes ownership of the returned QAction.-
1525-
1526 \sa QWidget::addAction()-
1527*/-
1528QAction *QMenu::addAction(const QString &text)-
1529{-
1530 QAction *ret = new QAction(text, this);-
1531 addAction(ret);-
1532 return ret;
never executed: return ret;
0
1533}-
1534-
1535/*!-
1536 \overload-
1537-
1538 This convenience function creates a new action with an \a icon-
1539 and some \a text. The function adds the newly created action to-
1540 the menu's list of actions, and returns it.-
1541-
1542 QMenu takes ownership of the returned QAction.-
1543-
1544 \sa QWidget::addAction()-
1545*/-
1546QAction *QMenu::addAction(const QIcon &icon, const QString &text)-
1547{-
1548 QAction *ret = new QAction(icon, text, this);-
1549 addAction(ret);-
1550 return ret;
never executed: return ret;
0
1551}-
1552-
1553/*!-
1554 \overload-
1555-
1556 This convenience function creates a new action with the text \a-
1557 text and an optional shortcut \a shortcut. The action's-
1558 \l{QAction::triggered()}{triggered()} signal is connected to the-
1559 \a receiver's \a member slot. The function adds the newly created-
1560 action to the menu's list of actions and returns it.-
1561-
1562 QMenu takes ownership of the returned QAction.-
1563-
1564 \sa QWidget::addAction()-
1565*/-
1566QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)-
1567{-
1568 QAction *action = new QAction(text, this);-
1569#ifdef QT_NO_SHORTCUT-
1570 Q_UNUSED(shortcut);-
1571#else-
1572 action->setShortcut(shortcut);-
1573#endif-
1574 QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);-
1575 addAction(action);-
1576 return action;
never executed: return action;
0
1577}-
1578-
1579/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)-
1580-
1581 \since 5.6-
1582-
1583 \overload-
1584-
1585 This convenience function creates a new action with the text \a-
1586 text and an optional shortcut \a shortcut. The action's-
1587 \l{QAction::triggered()}{triggered()} signal is connected to the-
1588 \a method of the \a receiver. The function adds the newly created-
1589 action to the menu's list of actions and returns it.-
1590-
1591 QMenu takes ownership of the returned QAction.-
1592*/-
1593-
1594/*!\fn QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)-
1595-
1596 \since 5.6-
1597-
1598 \overload-
1599-
1600 This convenience function creates a new action with the text \a-
1601 text and an optional shortcut \a shortcut. The action's-
1602 \l{QAction::triggered()}{triggered()} signal is connected to the-
1603 \a functor. The function adds the newly created-
1604 action to the menu's list of actions and returns it.-
1605-
1606 QMenu takes ownership of the returned QAction.-
1607*/-
1608-
1609/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)-
1610-
1611 \since 5.6-
1612-
1613 \overload-
1614-
1615 This convenience function creates a new action with the text \a-
1616 text and an optional shortcut \a shortcut. The action's-
1617 \l{QAction::triggered()}{triggered()} signal is connected to the-
1618 \a functor. The function adds the newly created-
1619 action to the menu's list of actions and returns it.-
1620-
1621 If \a context is destroyed, the functor will not be called.-
1622-
1623 QMenu takes ownership of the returned QAction.-
1624*/-
1625-
1626/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)-
1627-
1628 \since 5.6-
1629-
1630 \overload-
1631-
1632 This convenience function creates a new action with an \a icon-
1633 and some \a text and an optional shortcut \a shortcut. The action's-
1634 \l{QAction::triggered()}{triggered()} signal is connected to the-
1635 \a method of the \a receiver. The function adds the newly created-
1636 action to the menu's list of actions and returns it.-
1637-
1638 QMenu takes ownership of the returned QAction.-
1639*/-
1640-
1641/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0)-
1642-
1643 \since 5.6-
1644-
1645 \overload-
1646-
1647 This convenience function creates a new action with an \a icon-
1648 and some \a text and an optional shortcut \a shortcut. The action's-
1649 \l{QAction::triggered()}{triggered()} signal is connected to the-
1650 \a functor. The function adds the newly created-
1651 action to the menu's list of actions and returns it.-
1652-
1653 QMenu takes ownership of the returned QAction.-
1654*/-
1655-
1656/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)-
1657-
1658 \since 5.6-
1659-
1660 \overload-
1661-
1662 This convenience function creates a new action with an \a icon-
1663 and some \a text and an optional shortcut \a shortcut. The action's-
1664 \l{QAction::triggered()}{triggered()} signal is connected to the-
1665 \a functor. The function adds the newly created-
1666 action to the menu's list of actions and returns it.-
1667-
1668 If \a context is destroyed, the functor will not be called.-
1669-
1670 QMenu takes ownership of the returned QAction.-
1671*/-
1672-
1673/*!-
1674 \overload-
1675-
1676 This convenience function creates a new action with an \a icon and-
1677 some \a text and an optional shortcut \a shortcut. The action's-
1678 \l{QAction::triggered()}{triggered()} signal is connected to the-
1679 \a member slot of the \a receiver object. The function adds the-
1680 newly created action to the menu's list of actions, and returns it.-
1681-
1682 QMenu takes ownership of the returned QAction.-
1683-
1684 \sa QWidget::addAction()-
1685*/-
1686QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver,-
1687 const char* member, const QKeySequence &shortcut)-
1688{-
1689 QAction *action = new QAction(icon, text, this);-
1690#ifdef QT_NO_SHORTCUT-
1691 Q_UNUSED(shortcut);-
1692#else-
1693 action->setShortcut(shortcut);-
1694#endif-
1695 QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);-
1696 addAction(action);-
1697 return action;
never executed: return action;
0
1698}-
1699-
1700/*!-
1701 This convenience function adds \a menu as a submenu to this menu.-
1702 It returns \a menu's menuAction(). This menu does not take-
1703 ownership of \a menu.-
1704-
1705 \sa QWidget::addAction(), QMenu::menuAction()-
1706*/-
1707QAction *QMenu::addMenu(QMenu *menu)-
1708{-
1709 QAction *action = menu->menuAction();-
1710 addAction(action);-
1711 return action;
never executed: return action;
0
1712}-
1713-
1714/*!-
1715 Appends a new QMenu with \a title to the menu. The menu-
1716 takes ownership of the menu. Returns the new menu.-
1717-
1718 \sa QWidget::addAction(), QMenu::menuAction()-
1719*/-
1720QMenu *QMenu::addMenu(const QString &title)-
1721{-
1722 QMenu *menu = new QMenu(title, this);-
1723 addAction(menu->menuAction());-
1724 return menu;
never executed: return menu;
0
1725}-
1726-
1727/*!-
1728 Appends a new QMenu with \a icon and \a title to the menu. The menu-
1729 takes ownership of the menu. Returns the new menu.-
1730-
1731 \sa QWidget::addAction(), QMenu::menuAction()-
1732*/-
1733QMenu *QMenu::addMenu(const QIcon &icon, const QString &title)-
1734{-
1735 QMenu *menu = new QMenu(title, this);-
1736 menu->setIcon(icon);-
1737 addAction(menu->menuAction());-
1738 return menu;
never executed: return menu;
0
1739}-
1740-
1741/*!-
1742 This convenience function creates a new separator action, i.e. an-
1743 action with QAction::isSeparator() returning true, and adds the new-
1744 action to this menu's list of actions. It returns the newly-
1745 created action.-
1746-
1747 QMenu takes ownership of the returned QAction.-
1748-
1749 \sa QWidget::addAction()-
1750*/-
1751QAction *QMenu::addSeparator()-
1752{-
1753 QAction *action = new QAction(this);-
1754 action->setSeparator(true);-
1755 addAction(action);-
1756 return action;
never executed: return action;
0
1757}-
1758-
1759/*!-
1760 \since 5.1-
1761-
1762 This convenience function creates a new section action, i.e. an-
1763 action with QAction::isSeparator() returning true but also-
1764 having \a text hint, and adds the new action to this menu's list-
1765 of actions. It returns the newly created action.-
1766-
1767 The rendering of the hint is style and platform dependent. Widget-
1768 styles can use the text information in the rendering for sections,-
1769 or can choose to ignore it and render sections like simple separators.-
1770-
1771 QMenu takes ownership of the returned QAction.-
1772-
1773 \sa QWidget::addAction()-
1774*/-
1775QAction *QMenu::addSection(const QString &text)-
1776{-
1777 QAction *action = new QAction(text, this);-
1778 action->setSeparator(true);-
1779 addAction(action);-
1780 return action;
never executed: return action;
0
1781}-
1782-
1783/*!-
1784 \since 5.1-
1785-
1786 This convenience function creates a new section action, i.e. an-
1787 action with QAction::isSeparator() returning true but also-
1788 having \a text and \a icon hints, and adds the new action to this menu's-
1789 list of actions. It returns the newly created action.-
1790-
1791 The rendering of the hints is style and platform dependent. Widget-
1792 styles can use the text and icon information in the rendering for sections,-
1793 or can choose to ignore them and render sections like simple separators.-
1794-
1795 QMenu takes ownership of the returned QAction.-
1796-
1797 \sa QWidget::addAction()-
1798*/-
1799QAction *QMenu::addSection(const QIcon &icon, const QString &text)-
1800{-
1801 QAction *action = new QAction(icon, text, this);-
1802 action->setSeparator(true);-
1803 addAction(action);-
1804 return action;
never executed: return action;
0
1805}-
1806-
1807/*!-
1808 This convenience function inserts \a menu before action \a before-
1809 and returns the menus menuAction().-
1810-
1811 \sa QWidget::insertAction(), addMenu()-
1812*/-
1813QAction *QMenu::insertMenu(QAction *before, QMenu *menu)-
1814{-
1815 QAction *action = menu->menuAction();-
1816 insertAction(before, action);-
1817 return action;
never executed: return action;
0
1818}-
1819-
1820/*!-
1821 This convenience function creates a new separator action, i.e. an-
1822 action with QAction::isSeparator() returning true. The function inserts-
1823 the newly created action into this menu's list of actions before-
1824 action \a before and returns it.-
1825-
1826 QMenu takes ownership of the returned QAction.-
1827-
1828 \sa QWidget::insertAction(), addSeparator()-
1829*/-
1830QAction *QMenu::insertSeparator(QAction *before)-
1831{-
1832 QAction *action = new QAction(this);-
1833 action->setSeparator(true);-
1834 insertAction(before, action);-
1835 return action;
never executed: return action;
0
1836}-
1837-
1838/*!-
1839 \since 5.1-
1840-
1841 This convenience function creates a new title action, i.e. an-
1842 action with QAction::isSeparator() returning true but also having-
1843 \a text hint. The function inserts the newly created action-
1844 into this menu's list of actions before action \a before and-
1845 returns it.-
1846-
1847 The rendering of the hint is style and platform dependent. Widget-
1848 styles can use the text information in the rendering for sections,-
1849 or can choose to ignore it and render sections like simple separators.-
1850-
1851 QMenu takes ownership of the returned QAction.-
1852-
1853 \sa QWidget::insertAction(), addSection()-
1854*/-
1855QAction *QMenu::insertSection(QAction *before, const QString &text)-
1856{-
1857 QAction *action = new QAction(text, this);-
1858 action->setSeparator(true);-
1859 insertAction(before, action);-
1860 return action;
never executed: return action;
0
1861}-
1862-
1863/*!-
1864 \since 5.1-
1865-
1866 This convenience function creates a new title action, i.e. an-
1867 action with QAction::isSeparator() returning true but also having-
1868 \a text and \a icon hints. The function inserts the newly created action-
1869 into this menu's list of actions before action \a before and returns it.-
1870-
1871 The rendering of the hints is style and platform dependent. Widget-
1872 styles can use the text and icon information in the rendering for sections,-
1873 or can choose to ignore them and render sections like simple separators.-
1874-
1875 QMenu takes ownership of the returned QAction.-
1876-
1877 \sa QWidget::insertAction(), addSection()-
1878*/-
1879QAction *QMenu::insertSection(QAction *before, const QIcon &icon, const QString &text)-
1880{-
1881 QAction *action = new QAction(icon, text, this);-
1882 action->setSeparator(true);-
1883 insertAction(before, action);-
1884 return action;
never executed: return action;
0
1885}-
1886-
1887/*!-
1888 This sets the default action to \a act. The default action may have-
1889 a visual cue, depending on the current QStyle. A default action-
1890 usually indicates what will happen by default when a drop occurs.-
1891-
1892 \sa defaultAction()-
1893*/-
1894void QMenu::setDefaultAction(QAction *act)-
1895{-
1896 d_func()->defaultAction = act;-
1897}
never executed: end of block
0
1898-
1899/*!-
1900 Returns the current default action.-
1901-
1902 \sa setDefaultAction()-
1903*/-
1904QAction *QMenu::defaultAction() const-
1905{-
1906 return d_func()->defaultAction;
never executed: return d_func()->defaultAction;
0
1907}-
1908-
1909/*!-
1910 \property QMenu::tearOffEnabled-
1911 \brief whether the menu supports being torn off-
1912-
1913 When true, the menu contains a special tear-off item (often shown as a dashed-
1914 line at the top of the menu) that creates a copy of the menu when it is-
1915 triggered.-
1916-
1917 This "torn-off" copy lives in a separate window. It contains the same menu-
1918 items as the original menu, with the exception of the tear-off handle.-
1919-
1920 By default, this property is \c false.-
1921*/-
1922void QMenu::setTearOffEnabled(bool b)-
1923{-
1924 Q_D(QMenu);-
1925 if (d->tearoff == b)
d->tearoff == bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1926 return;
never executed: return;
0
1927 if (!b)
!bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1928 hideTearOffMenu();
never executed: hideTearOffMenu();
0
1929 d->tearoff = b;-
1930-
1931 d->itemsDirty = true;-
1932 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1933 resize(sizeHint());
never executed: resize(sizeHint());
0
1934}
never executed: end of block
0
1935-
1936bool QMenu::isTearOffEnabled() const-
1937{-
1938 return d_func()->tearoff;
never executed: return d_func()->tearoff;
0
1939}-
1940-
1941/*!-
1942 When a menu is torn off a second menu is shown to display the menu-
1943 contents in a new window. When the menu is in this mode and the menu-
1944 is visible returns \c true; otherwise false.-
1945-
1946 \sa hideTearOffMenu(), isTearOffEnabled()-
1947*/-
1948bool QMenu::isTearOffMenuVisible() const-
1949{-
1950 if (d_func()->tornPopup)
d_func()->tornPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1951 return d_func()->tornPopup->isVisible();
never executed: return d_func()->tornPopup->isVisible();
0
1952 return false;
never executed: return false;
0
1953}-
1954-
1955/*!-
1956 This function will forcibly hide the torn off menu making it-
1957 disappear from the users desktop.-
1958-
1959 \sa isTearOffMenuVisible(), isTearOffEnabled()-
1960*/-
1961void QMenu::hideTearOffMenu()-
1962{-
1963 if (QWidget *w = d_func()->tornPopup)
QWidget *w = d...c()->tornPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1964 w->close();
never executed: w->close();
0
1965}
never executed: end of block
0
1966-
1967-
1968/*!-
1969 Sets the currently highlighted action to \a act.-
1970*/-
1971void QMenu::setActiveAction(QAction *act)-
1972{-
1973 Q_D(QMenu);-
1974 d->setCurrentAction(act, 0);-
1975 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1976 d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
never executed: d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
0
1977}
never executed: end of block
0
1978-
1979-
1980/*!-
1981 Returns the currently highlighted action, or 0 if no-
1982 action is currently highlighted.-
1983*/-
1984QAction *QMenu::activeAction() const-
1985{-
1986 return d_func()->currentAction;
never executed: return d_func()->currentAction;
0
1987}-
1988-
1989/*!-
1990 \since 4.2-
1991-
1992 Returns \c true if there are no visible actions inserted into the menu, false-
1993 otherwise.-
1994-
1995 \sa QWidget::actions()-
1996*/-
1997-
1998bool QMenu::isEmpty() const-
1999{-
2000 bool ret = true;-
2001 for(int i = 0; ret && i < actions().count(); ++i) {
retDescription
TRUEnever evaluated
FALSEnever evaluated
i < actions().count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2002 const QAction *action = actions().at(i);-
2003 if (!action->isSeparator() && action->isVisible()) {
!action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2004 ret = false;-
2005 }
never executed: end of block
0
2006 }
never executed: end of block
0
2007 return ret;
never executed: return ret;
0
2008}-
2009-
2010/*!-
2011 Removes all the menu's actions. Actions owned by the menu and not-
2012 shown in any other widget are deleted.-
2013-
2014 \sa removeAction()-
2015*/-
2016void QMenu::clear()-
2017{-
2018 QList<QAction*> acts = actions();-
2019-
2020 for(int i = 0; i < acts.size(); i++) {
i < acts.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2021 removeAction(acts[i]);-
2022 if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
acts[i]->parent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
acts[i]->d_fun...gets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2023 delete acts[i];
never executed: delete acts[i];
0
2024 }
never executed: end of block
0
2025}
never executed: end of block
0
2026-
2027/*!-
2028 If a menu does not fit on the screen it lays itself out so that it-
2029 does fit. It is style dependent what layout means (for example, on-
2030 Windows it will use multiple columns).-
2031-
2032 This functions returns the number of columns necessary.-
2033*/-
2034int QMenu::columnCount() const-
2035{-
2036 return d_func()->ncols;
never executed: return d_func()->ncols;
0
2037}-
2038-
2039/*!-
2040 Returns the item at \a pt; returns 0 if there is no item there.-
2041*/-
2042QAction *QMenu::actionAt(const QPoint &pt) const-
2043{-
2044 if (QAction *ret = d_func()->actionAt(pt))
QAction *ret =...->actionAt(pt)Description
TRUEnever evaluated
FALSEnever evaluated
0
2045 return ret;
never executed: return ret;
0
2046 return 0;
never executed: return 0;
0
2047}-
2048-
2049/*!-
2050 Returns the geometry of action \a act.-
2051*/-
2052QRect QMenu::actionGeometry(QAction *act) const-
2053{-
2054 return d_func()->actionRect(act);
never executed: return d_func()->actionRect(act);
0
2055}-
2056-
2057/*!-
2058 \reimp-
2059*/-
2060QSize QMenu::sizeHint() const-
2061{-
2062 Q_D(const QMenu);-
2063 d->updateActionRects();-
2064-
2065 QSize s;-
2066 for (int i = 0; i < d->actionRects.count(); ++i) {
i < d->actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2067 const QRect &rect = d->actionRects.at(i);-
2068 if (rect.isNull())
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2069 continue;
never executed: continue;
0
2070 if (rect.bottom() >= s.height())
rect.bottom() >= s.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2071 s.setHeight(rect.y() + rect.height());
never executed: s.setHeight(rect.y() + rect.height());
0
2072 if (rect.right() >= s.width())
rect.right() >= s.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2073 s.setWidth(rect.x() + rect.width());
never executed: s.setWidth(rect.x() + rect.width());
0
2074 }
never executed: end of block
0
2075 // Note that the action rects calculated above already include-
2076 // the top and left margins, so we only need to add margins for-
2077 // the bottom and right.-
2078 QStyleOption opt(0);-
2079 opt.init(this);-
2080 const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this);-
2081 s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin;-
2082 s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin;-
2083-
2084 return style()->sizeFromContents(QStyle::CT_Menu, &opt,
never executed: return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this);
0
2085 s.expandedTo(QApplication::globalStrut()), this);
never executed: return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this);
0
2086}-
2087-
2088/*!-
2089 Displays the menu so that the action \a atAction will be at the-
2090 specified \e global position \a p. To translate a widget's local-
2091 coordinates into global coordinates, use QWidget::mapToGlobal().-
2092-
2093 When positioning a menu with exec() or popup(), bear in mind that-
2094 you cannot rely on the menu's current size(). For performance-
2095 reasons, the menu adapts its size only when necessary, so in many-
2096 cases, the size before and after the show is different. Instead,-
2097 use sizeHint() which calculates the proper size depending on the-
2098 menu's current contents.-
2099-
2100 \sa QWidget::mapToGlobal(), exec()-
2101*/-
2102void QMenu::popup(const QPoint &p, QAction *atAction)-
2103{-
2104 Q_D(QMenu);-
2105 if (d->scroll) { // reset scroll state from last popup
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2106 if (d->scroll->scrollOffset)
d->scroll->scrollOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2107 d->itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll
never executed: d->itemsDirty = 1;
0
2108 d->scroll->scrollOffset = 0;-
2109 d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;-
2110 }
never executed: end of block
0
2111 d->tearoffHighlighted = 0;-
2112 d->motions = 0;-
2113 d->doChildEffects = true;-
2114 d->updateLayoutDirection();-
2115-
2116#ifndef QT_NO_MENUBAR-
2117 // if this menu is part of a chain attached to a QMenuBar, set the-
2118 // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type-
2119 setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0);-
2120#endif-
2121-
2122 ensurePolished(); // Get the right font-
2123 emit aboutToShow();-
2124 const bool actionListChanged = d->itemsDirty;-
2125 d->updateActionRects();-
2126 QPoint pos;-
2127 QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);-
2128 if (actionListChanged && causedButton)
actionListChangedDescription
TRUEnever evaluated
FALSEnever evaluated
causedButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2129 pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
never executed: pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
0
2130 else-
2131 pos = p;
never executed: pos = p;
0
2132-
2133 QSize size = sizeHint();-
2134 QRect screen;-
2135#ifndef QT_NO_GRAPHICSVIEW-
2136 bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
!bypassGraphic...xyWidget(this)Description
TRUEnever evaluated
FALSEnever evaluated
d->nearestGrap...xyWidget(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2137 if (isEmbedded)
isEmbeddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2138 screen = d->popupGeometry(this);
never executed: screen = d->popupGeometry(this);
0
2139 else-
2140#endif-
2141 screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
never executed: screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
0
2142 const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this);-
2143 bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);-
2144-
2145 // if the screens have very different geometries and the menu is too big, we have to recalculate-
2146 if (size.height() > screen.height() || size.width() > screen.width()) {
size.height() ...creen.height()Description
TRUEnever evaluated
FALSEnever evaluated
size.width() > screen.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2147 size = d->adjustMenuSizeForScreen(screen);-
2148 adjustToDesktop = true;-
2149 }
never executed: end of block
0
2150 // Layout is not right, we might be able to save horizontal space-
2151 if (d->ncols >1 && size.height() < screen.height()) {
d->ncols >1Description
TRUEnever evaluated
FALSEnever evaluated
size.height() ...creen.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2152 size = d->adjustMenuSizeForScreen(screen);-
2153 adjustToDesktop = true;-
2154 }
never executed: end of block
0
2155-
2156#ifdef QT_KEYPAD_NAVIGATION-
2157 if (!atAction && QApplication::keypadNavigationEnabled()) {-
2158 // Try to have one item activated-
2159 if (d->defaultAction && d->defaultAction->isEnabled()) {-
2160 atAction = d->defaultAction;-
2161 // TODO: This works for first level menus, not yet sub menus-
2162 } else {-
2163 foreach (QAction *action, d->actions)-
2164 if (action->isEnabled()) {-
2165 atAction = action;-
2166 break;-
2167 }-
2168 }-
2169 d->currentAction = atAction;-
2170 }-
2171#endif-
2172 if (d->ncols > 1) {
d->ncols > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2173 pos.setY(screen.top() + desktopFrame);-
2174 } else if (atAction) {
never executed: end of block
atActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2175 for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2176 QAction *action = d->actions.at(i);-
2177 if (action == atAction) {
action == atActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2178 int newY = pos.y() - above_height;-
2179 if (d->scroll && newY < desktopFrame) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
newY < desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2180 d->scroll->scrollFlags = d->scroll->scrollFlags-
2181 | QMenuPrivate::QMenuScroller::ScrollUp;-
2182 d->scroll->scrollOffset = newY;-
2183 newY = desktopFrame;-
2184 }
never executed: end of block
0
2185 pos.setY(newY);-
2186-
2187 if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
d->scroll->scr...er::ScrollNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2188 && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
!style()->styl...roll, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2189 int below_height = above_height + d->scroll->scrollOffset;-
2190 for (int i2 = i; i2 < d->actionRects.count(); i2++)
i2 < d->actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2191 below_height += d->actionRects.at(i2).height();
never executed: below_height += d->actionRects.at(i2).height();
0
2192 size.setHeight(below_height);-
2193 }
never executed: end of block
0
2194 break;
never executed: break;
0
2195 } else {-
2196 above_height += d->actionRects.at(i).height();-
2197 }
never executed: end of block
0
2198 }-
2199 }
never executed: end of block
0
2200-
2201 QPoint mouse = QCursor::pos();-
2202 d->mousePopupPos = mouse;-
2203 const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
!d->causedPopup.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
(QRect(p.x() -...ntains(mouse))Description
TRUEnever evaluated
FALSEnever evaluated
0
2204-
2205 const QSize menuSize(sizeHint());-
2206 if (adjustToDesktop) {
adjustToDesktopDescription
TRUEnever evaluated
FALSEnever evaluated
0
2207 // handle popup falling "off screen"-
2208 if (isRightToLeft()) {
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2209 if (snapToMouse) // position flowing left from the mouse
snapToMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2210 pos.setX(mouse.x() - size.width());
never executed: pos.setX(mouse.x() - size.width());
0
2211-
2212#ifndef QT_NO_MENUBAR-
2213 // if the menu is in a menubar or is a submenu, it should be right-aligned-
2214 if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget))
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2215 pos.rx() -= size.width();
never executed: pos.rx() -= size.width();
0
2216#endif //QT_NO_MENUBAR-
2217-
2218 if (pos.x() < screen.left() + desktopFrame)
pos.x() < scre...+ desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2219 pos.setX(qMax(p.x(), screen.left() + desktopFrame));
never executed: pos.setX(qMax(p.x(), screen.left() + desktopFrame));
0
2220 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
pos.x() + size...- desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2221 pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
never executed: pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
0
2222 } else {
never executed: end of block
0
2223 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
pos.x() + size...- desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2224 pos.setX(screen.right() - desktopFrame - size.width() + 1);
never executed: pos.setX(screen.right() - desktopFrame - size.width() + 1);
0
2225 if (pos.x() < screen.left() + desktopFrame)
pos.x() < scre...+ desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2226 pos.setX(screen.left() + desktopFrame);
never executed: pos.setX(screen.left() + desktopFrame);
0
2227 }
never executed: end of block
0
2228 if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
pos.y() + size...- desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2229 if(snapToMouse)
snapToMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2230 pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
never executed: pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
0
2231 else-
2232 pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
never executed: pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
0
2233 } else if (pos.y() < screen.top() + desktopFrame) {
pos.y() < scre...+ desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2234 pos.setY(screen.top() + desktopFrame);-
2235 }
never executed: end of block
0
2236-
2237 if (pos.y() < screen.top() + desktopFrame)
pos.y() < scre...+ desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2238 pos.setY(screen.top() + desktopFrame);
never executed: pos.setY(screen.top() + desktopFrame);
0
2239 if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame) {
pos.y() + menu...- desktopFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2240 if (d->scroll) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2241 d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);-
2242 int y = qMax(screen.y(),pos.y());-
2243 size.setHeight(screen.bottom() - (desktopFrame * 2) - y);-
2244 } else {
never executed: end of block
0
2245 // Too big for screen, bias to see bottom of menu (for some reason)-
2246 pos.setY(screen.bottom() - size.height() + 1);-
2247 }
never executed: end of block
0
2248 }-
2249 }
never executed: end of block
0
2250 const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);-
2251 QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget);-
2252 if (caused && caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()) {
causedDescription
TRUEnever evaluated
FALSEnever evaluated
caused->geomet...screen.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2253 QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction));-
2254 const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft());-
2255 parentActionRect.moveTopLeft(actionTopLeft);-
2256 if (isRightToLeft()) {
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2257 if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
(pos.x() + men...subMenuOffset)Description
TRUEnever evaluated
FALSEnever evaluated
0
2258 && (pos.x() < parentActionRect.right()))
(pos.x() < par...nRect.right())Description
TRUEnever evaluated
FALSEnever evaluated
0
2259 {-
2260 pos.rx() = parentActionRect.left() - menuSize.width();-
2261 if (pos.x() < screen.x())
pos.x() < screen.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
2262 pos.rx() = parentActionRect.right();
never executed: pos.rx() = parentActionRect.right();
0
2263 if (pos.x() + menuSize.width() > screen.x() + screen.width())
pos.x() + menu...screen.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2264 pos.rx() = screen.x();
never executed: pos.rx() = screen.x();
0
2265 }
never executed: end of block
0
2266 } else {
never executed: end of block
0
2267 if ((pos.x() < parentActionRect.right() + subMenuOffset)
(pos.x() < par...subMenuOffset)Description
TRUEnever evaluated
FALSEnever evaluated
0
2268 && (pos.x() + menuSize.width() > parentActionRect.left()))
(pos.x() + men...onRect.left())Description
TRUEnever evaluated
FALSEnever evaluated
0
2269 {-
2270 pos.rx() = parentActionRect.right();-
2271 if (pos.x() + menuSize.width() > screen.x() + screen.width())
pos.x() + menu...screen.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2272 pos.rx() = parentActionRect.left() - menuSize.width();
never executed: pos.rx() = parentActionRect.left() - menuSize.width();
0
2273 if (pos.x() < screen.x())
pos.x() < screen.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
2274 pos.rx() = screen.x() + screen.width() - menuSize.width();
never executed: pos.rx() = screen.x() + screen.width() - menuSize.width();
0
2275 }
never executed: end of block
0
2276 }
never executed: end of block
0
2277 }-
2278 setGeometry(QRect(pos, size));-
2279#ifndef QT_NO_EFFECTS-
2280 int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2281 int vGuess = QEffects::DownScroll;-
2282 if (isRightToLeft()) {
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2283 if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
snapToMouseDescription
TRUEnever evaluated
FALSEnever evaluated
(pos.x() + siz...2 > mouse.x())Description
TRUEnever evaluated
FALSEnever evaluated
0
2284 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
pos.x() + size...up.widget->x()Description
TRUEnever evaluated
FALSEnever evaluated
0
2285 hGuess = QEffects::RightScroll;
never executed: hGuess = QEffects::RightScroll;
0
2286 } else {
never executed: end of block
0
2287 if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
snapToMouseDescription
TRUEnever evaluated
FALSEnever evaluated
(pos.x() + siz...2 < mouse.x())Description
TRUEnever evaluated
FALSEnever evaluated
0
2288 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
pos.x() + size...up.widget->x()Description
TRUEnever evaluated
FALSEnever evaluated
0
2289 hGuess = QEffects::LeftScroll;
never executed: hGuess = QEffects::LeftScroll;
0
2290 }
never executed: end of block
0
2291-
2292#ifndef QT_NO_MENUBAR-
2293 if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
snapToMouseDescription
TRUEnever evaluated
FALSEnever evaluated
(pos.y() + siz...2 < mouse.y())Description
TRUEnever evaluated
FALSEnever evaluated
0
2294 (qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2295 pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
pos.y() + size...et->pos()).y()Description
TRUEnever evaluated
FALSEnever evaluated
0
2296 vGuess = QEffects::UpScroll;
never executed: vGuess = QEffects::UpScroll;
0
2297#endif-
2298 if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {
QApplication::...I_AnimateMenu)Description
TRUEnever evaluated
FALSEnever evaluated
0
2299 bool doChildEffects = true;-
2300#ifndef QT_NO_MENUBAR-
2301 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
QMenuBar *mb =...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2302 doChildEffects = mb->d_func()->doChildEffects;-
2303 mb->d_func()->doChildEffects = false;-
2304 } else
never executed: end of block
0
2305#endif-
2306 if (QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)) {
QMenu *m = qob...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2307 doChildEffects = m->d_func()->doChildEffects;-
2308 m->d_func()->doChildEffects = false;-
2309 }
never executed: end of block
0
2310-
2311 if (doChildEffects) {
doChildEffectsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2312 if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
QApplication::...::UI_FadeMenu)Description
TRUEnever evaluated
FALSEnever evaluated
0
2313 qFadeEffect(this);
never executed: qFadeEffect(this);
0
2314 else if (d->causedPopup.widget)
d->causedPopup.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2315 qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
never executed: qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
0
2316 else-
2317 qScrollEffect(this, hGuess | vGuess);
never executed: qScrollEffect(this, hGuess | vGuess);
0
2318 } else {-
2319 // kill any running effect-
2320 qFadeEffect(0);-
2321 qScrollEffect(0);-
2322-
2323 show();-
2324 }
never executed: end of block
0
2325 } else-
2326#endif-
2327 {-
2328 show();-
2329 }
never executed: end of block
0
2330-
2331#ifndef QT_NO_ACCESSIBILITY-
2332 QAccessibleEvent event(this, QAccessible::PopupMenuStart);-
2333 QAccessible::updateAccessibility(&event);-
2334#endif-
2335}
never executed: end of block
0
2336-
2337/*!-
2338 Executes this menu synchronously.-
2339-
2340 This is equivalent to \c{exec(pos())}.-
2341-
2342 This returns the triggered QAction in either the popup menu or one-
2343 of its submenus, or 0 if no item was triggered (normally because-
2344 the user pressed Esc).-
2345-
2346 In most situations you'll want to specify the position yourself,-
2347 for example, the current mouse position:-
2348 \snippet code/src_gui_widgets_qmenu.cpp 0-
2349 or aligned to a widget:-
2350 \snippet code/src_gui_widgets_qmenu.cpp 1-
2351 or in reaction to a QMouseEvent *e:-
2352 \snippet code/src_gui_widgets_qmenu.cpp 2-
2353*/-
2354QAction *QMenu::exec()-
2355{-
2356 return exec(pos());
never executed: return exec(pos());
0
2357}-
2358-
2359-
2360/*!-
2361 \overload-
2362-
2363 Executes this menu synchronously.-
2364-
2365 Pops up the menu so that the action \a action will be at the-
2366 specified \e global position \a p. To translate a widget's local-
2367 coordinates into global coordinates, use QWidget::mapToGlobal().-
2368-
2369 This returns the triggered QAction in either the popup menu or one-
2370 of its submenus, or 0 if no item was triggered (normally because-
2371 the user pressed Esc).-
2372-
2373 Note that all signals are emitted as usual. If you connect a-
2374 QAction to a slot and call the menu's exec(), you get the result-
2375 both via the signal-slot connection and in the return value of-
2376 exec().-
2377-
2378 Common usage is to position the menu at the current mouse-
2379 position:-
2380 \snippet code/src_gui_widgets_qmenu.cpp 3-
2381 or aligned to a widget:-
2382 \snippet code/src_gui_widgets_qmenu.cpp 4-
2383 or in reaction to a QMouseEvent *e:-
2384 \snippet code/src_gui_widgets_qmenu.cpp 5-
2385-
2386 When positioning a menu with exec() or popup(), bear in mind that-
2387 you cannot rely on the menu's current size(). For performance-
2388 reasons, the menu adapts its size only when necessary. So in many-
2389 cases, the size before and after the show is different. Instead,-
2390 use sizeHint() which calculates the proper size depending on the-
2391 menu's current contents.-
2392-
2393 \sa popup(), QWidget::mapToGlobal()-
2394*/-
2395QAction *QMenu::exec(const QPoint &p, QAction *action)-
2396{-
2397 Q_D(QMenu);-
2398 ensurePolished();-
2399 createWinId();-
2400 QEventLoop eventLoop;-
2401 d->eventLoop = &eventLoop;-
2402 popup(p, action);-
2403-
2404 QPointer<QObject> guard = this;-
2405 (void) eventLoop.exec();-
2406 if (guard.isNull())
guard.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2407 return 0;
never executed: return 0;
0
2408-
2409 action = d->syncAction;-
2410 d->syncAction = 0;-
2411 d->eventLoop = 0;-
2412 return action;
never executed: return action;
0
2413}-
2414-
2415/*!-
2416 \overload-
2417-
2418 Executes a menu synchronously.-
2419-
2420 The menu's actions are specified by the list of \a actions. The menu will-
2421 pop up so that the specified action, \a at, appears at global position \a-
2422 pos. If \a at is not specified then the menu appears at position \a-
2423 pos. \a parent is the menu's parent widget; specifying the parent will-
2424 provide context when \a pos alone is not enough to decide where the menu-
2425 should go (e.g., with multiple desktops or when the parent is embedded in-
2426 QGraphicsView).-
2427-
2428 The function returns the triggered QAction in either the popup-
2429 menu or one of its submenus, or 0 if no item was triggered-
2430 (normally because the user pressed Esc).-
2431-
2432 This is equivalent to:-
2433 \snippet code/src_gui_widgets_qmenu.cpp 6-
2434-
2435 \sa popup(), QWidget::mapToGlobal()-
2436*/-
2437#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)-
2438QAction *QMenu::exec(const QList<QAction *> &actions, const QPoint &pos, QAction *at, QWidget *parent)-
2439#else-
2440QAction *QMenu::exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent)-
2441#endif-
2442{-
2443 QMenu menu(parent);-
2444 menu.addActions(actions);-
2445 return menu.exec(pos, at);
never executed: return menu.exec(pos, at);
0
2446}-
2447-
2448/*!-
2449 \reimp-
2450*/-
2451void QMenu::hideEvent(QHideEvent *)-
2452{-
2453 Q_D(QMenu);-
2454 emit aboutToHide();-
2455 if (d->eventLoop)
d->eventLoopDescription
TRUEnever evaluated
FALSEnever evaluated
0
2456 d->eventLoop->exit();
never executed: d->eventLoop->exit();
0
2457 d->setCurrentAction(0);-
2458#ifndef QT_NO_ACCESSIBILITY-
2459 QAccessibleEvent event(this, QAccessible::PopupMenuEnd);-
2460 QAccessible::updateAccessibility(&event);-
2461#endif-
2462#ifndef QT_NO_MENUBAR-
2463 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
QMenuBar *mb =...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2464 mb->d_func()->setCurrentAction(0);
never executed: mb->d_func()->setCurrentAction(0);
0
2465#endif-
2466 d->mouseDown = 0;-
2467 d->hasHadMouse = false;-
2468 if (d->activeMenu)
d->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
2469 d->hideMenu(d->activeMenu);
never executed: d->hideMenu(d->activeMenu);
0
2470 d->causedPopup.widget = 0;-
2471 d->causedPopup.action = 0;-
2472 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2473 d->scroll->scrollTimer.stop(); //make sure the timer stops
never executed: d->scroll->scrollTimer.stop();
0
2474}
never executed: end of block
0
2475-
2476/*!-
2477 \reimp-
2478*/-
2479void QMenu::paintEvent(QPaintEvent *e)-
2480{-
2481 Q_D(QMenu);-
2482 d->updateActionRects();-
2483 QPainter p(this);-
2484 QRegion emptyArea = QRegion(rect());-
2485-
2486 QStyleOptionMenuItem menuOpt;-
2487 menuOpt.initFrom(this);-
2488 menuOpt.state = QStyle::State_None;-
2489 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;-
2490 menuOpt.maxIconWidth = 0;-
2491 menuOpt.tabWidth = 0;-
2492 style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this);-
2493-
2494 //draw the items that need updating..-
2495 for (int i = 0; i < d->actions.count(); ++i) {
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2496 QAction *action = d->actions.at(i);-
2497 QRect adjustedActionRect = d->actionRects.at(i);-
2498 if (!e->rect().intersects(adjustedActionRect)
!e->rect().int...tedActionRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
2499 || d->widgetItems.value(action))
d->widgetItems.value(action)Description
TRUEnever evaluated
FALSEnever evaluated
0
2500 continue;
never executed: continue;
0
2501 //set the clip region to be extra safe (and adjust for the scrollers)-
2502 QRegion adjustedActionReg(adjustedActionRect);-
2503 emptyArea -= adjustedActionReg;-
2504 p.setClipRegion(adjustedActionReg);-
2505-
2506 QStyleOptionMenuItem opt;-
2507 initStyleOption(&opt, action);-
2508 opt.rect = adjustedActionRect;-
2509 style()->drawControl(QStyle::CE_MenuItem, &opt, &p, this);-
2510 }
never executed: end of block
0
2511-
2512 const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);-
2513 //draw the scroller regions..-
2514 if (d->scroll) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2515 menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;-
2516 menuOpt.state |= QStyle::State_Enabled;-
2517 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) {
d->scroll->scr...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2518 menuOpt.rect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight());-
2519 emptyArea -= QRegion(menuOpt.rect);-
2520 p.setClipRect(menuOpt.rect);-
2521 style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this);-
2522 }
never executed: end of block
0
2523 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) {
d->scroll->scr...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
2524 menuOpt.rect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2),-
2525 d->scrollerHeight());-
2526 emptyArea -= QRegion(menuOpt.rect);-
2527 menuOpt.state |= QStyle::State_DownArrow;-
2528 p.setClipRect(menuOpt.rect);-
2529 style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this);-
2530 }
never executed: end of block
0
2531 }
never executed: end of block
0
2532 //paint the tear off..-
2533 if (d->tearoff) {
d->tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2534 menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;-
2535 menuOpt.rect.setRect(fw, fw, width() - (fw * 2),-
2536 style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this));-
2537 if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
d->scroll->scr...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2538 menuOpt.rect.translate(0, d->scrollerHeight());
never executed: menuOpt.rect.translate(0, d->scrollerHeight());
0
2539 emptyArea -= QRegion(menuOpt.rect);-
2540 p.setClipRect(menuOpt.rect);-
2541 menuOpt.state = QStyle::State_None;-
2542 if (d->tearoffHighlighted)
d->tearoffHighlightedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2543 menuOpt.state |= QStyle::State_Selected;
never executed: menuOpt.state |= QStyle::State_Selected;
0
2544 style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, &p, this);-
2545 }
never executed: end of block
0
2546 //draw border-
2547 if (fw) {
fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
2548 QRegion borderReg;-
2549 borderReg += QRect(0, 0, fw, height()); //left-
2550 borderReg += QRect(width()-fw, 0, fw, height()); //right-
2551 borderReg += QRect(0, 0, width(), fw); //top-
2552 borderReg += QRect(0, height()-fw, width(), fw); //bottom-
2553 p.setClipRegion(borderReg);-
2554 emptyArea -= borderReg;-
2555 QStyleOptionFrame frame;-
2556 frame.rect = rect();-
2557 frame.palette = palette();-
2558 frame.state = QStyle::State_None;-
2559 frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth);-
2560 frame.midLineWidth = 0;-
2561 style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this);-
2562 }
never executed: end of block
0
2563-
2564 //finally the rest of the space-
2565 p.setClipRegion(emptyArea);-
2566 menuOpt.state = QStyle::State_None;-
2567 menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea;-
2568 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;-
2569 menuOpt.rect = rect();-
2570 menuOpt.menuRect = rect();-
2571 style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this);-
2572}
never executed: end of block
0
2573-
2574#ifndef QT_NO_WHEELEVENT-
2575/*!-
2576 \reimp-
2577*/-
2578void QMenu::wheelEvent(QWheelEvent *e)-
2579{-
2580 Q_D(QMenu);-
2581 if (d->scroll && rect().contains(e->pos()))
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
rect().contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2582 d->scrollMenu(e->delta() > 0 ?
never executed: d->scrollMenu(e->delta() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
0
2583 QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
never executed: d->scrollMenu(e->delta() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
0
2584}
never executed: end of block
0
2585#endif-
2586-
2587/*!-
2588 \reimp-
2589*/-
2590void QMenu::mousePressEvent(QMouseEvent *e)-
2591{-
2592 Q_D(QMenu);-
2593 if (d->aboutToHide || d->mouseEventTaken(e))
d->aboutToHideDescription
TRUEnever evaluated
FALSEnever evaluated
d->mouseEventTaken(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
2594 return;
never executed: return;
0
2595 // Workaround for XCB on multiple screens which doesn't have offset. If the menu is open on one screen-
2596 // and mouse clicks on second screen, e->pos() is QPoint(0,0) and the menu doesn't hide. This trick makes-
2597 // possible to hide the menu when mouse clicks on another screen (e->screenPos() returns correct value).-
2598 // Only when mouse clicks in QPoint(0,0) on second screen, the menu doesn't hide.-
2599 if ((e->pos().isNull() && !e->screenPos().isNull()) || !rect().contains(e->pos())) {
e->pos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!e->screenPos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!rect().contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2600 if (d->noReplayFor
d->noReplayForDescription
TRUEnever evaluated
FALSEnever evaluated
0
2601 && QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos()))
QRect(d->noRep...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2602 setAttribute(Qt::WA_NoMouseReplay);
never executed: setAttribute(Qt::WA_NoMouseReplay);
0
2603 if (d->eventLoop) // synchronous operation
d->eventLoopDescription
TRUEnever evaluated
FALSEnever evaluated
0
2604 d->syncAction = 0;
never executed: d->syncAction = 0;
0
2605 d->hideUpToMenuBar();-
2606 return;
never executed: return;
0
2607 }-
2608 d->mouseDown = this;-
2609-
2610 QAction *action = d->actionAt(e->pos());-
2611 d->setCurrentAction(action, 20);-
2612 update();-
2613}
never executed: end of block
0
2614-
2615/*!-
2616 \reimp-
2617*/-
2618void QMenu::mouseReleaseEvent(QMouseEvent *e)-
2619{-
2620 Q_D(QMenu);-
2621 if (d->aboutToHide || d->mouseEventTaken(e))
d->aboutToHideDescription
TRUEnever evaluated
FALSEnever evaluated
d->mouseEventTaken(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
2622 return;
never executed: return;
0
2623 if(d->mouseDown != this) {
d->mouseDown != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2624 d->mouseDown = 0;-
2625 return;
never executed: return;
0
2626 }-
2627-
2628 d->mouseDown = 0;-
2629 d->setSyncAction();-
2630 QAction *action = d->actionAt(e->pos());-
2631-
2632 if (action && action == d->currentAction) {
actionDescription
TRUEnever evaluated
FALSEnever evaluated
action == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2633 if (!action->menu()){
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
2634#if defined(Q_OS_WIN)-
2635 //On Windows only context menus can be activated with the right button-
2636 if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0)-
2637#endif-
2638 d->activateAction(action, QAction::Trigger);-
2639 }
never executed: end of block
0
2640 } else if ((!action || action->isEnabled()) && d->hasMouseMoved(e->globalPos())) {
never executed: end of block
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
d->hasMouseMov...->globalPos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2641 d->hideUpToMenuBar();-
2642 }
never executed: end of block
0
2643}
never executed: end of block
0
2644-
2645/*!-
2646 \reimp-
2647*/-
2648void QMenu::changeEvent(QEvent *e)-
2649{-
2650 Q_D(QMenu);-
2651 if (e->type() == QEvent::StyleChange || e->type() == QEvent::FontChange ||
e->type() == Q...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
e->type() == Q...nt::FontChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2652 e->type() == QEvent::LayoutDirectionChange) {
e->type() == Q...irectionChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2653 d->itemsDirty = 1;-
2654 setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, this));-
2655 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2656 resize(sizeHint());
never executed: resize(sizeHint());
0
2657 if (!style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)) {
!style()->styl...able, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2658 delete d->scroll;-
2659 d->scroll = 0;-
2660 } else if (!d->scroll) {
never executed: end of block
!d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2661 d->scroll = new QMenuPrivate::QMenuScroller;-
2662 d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;-
2663 }
never executed: end of block
0
2664 } else if (e->type() == QEvent::EnabledChange) {
never executed: end of block
e->type() == Q...:EnabledChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2665 if (d->tornPopup) // torn-off menu
d->tornPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2666 d->tornPopup->setEnabled(isEnabled());
never executed: d->tornPopup->setEnabled(isEnabled());
0
2667 d->menuAction->setEnabled(isEnabled());-
2668 if (!d->platformMenu.isNull())
!d->platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2669 d->platformMenu->setEnabled(isEnabled());
never executed: d->platformMenu->setEnabled(isEnabled());
0
2670 }
never executed: end of block
0
2671 QWidget::changeEvent(e);-
2672}
never executed: end of block
0
2673-
2674-
2675/*!-
2676 \reimp-
2677*/-
2678bool-
2679QMenu::event(QEvent *e)-
2680{-
2681 Q_D(QMenu);-
2682 switch (e->type()) {-
2683 case QEvent::Polish:
never executed: case QEvent::Polish:
0
2684 d->updateLayoutDirection();-
2685 break;
never executed: break;
0
2686 case QEvent::ShortcutOverride: {
never executed: case QEvent::ShortcutOverride:
0
2687 QKeyEvent *kev = static_cast<QKeyEvent*>(e);-
2688 if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down
kev->key() == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
kev->key() == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
0
2689 || kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right
kev->key() == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
kev->key() == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2690 || kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return
kev->key() == Qt::Key_EnterDescription
TRUEnever evaluated
FALSEnever evaluated
kev->key() == Qt::Key_ReturnDescription
TRUEnever evaluated
FALSEnever evaluated
0
2691 || kev->matches(QKeySequence::Cancel)) {
kev->matches(Q...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
0
2692 e->accept();-
2693 return true;
never executed: return true;
0
2694 }-
2695 }-
2696 break;
never executed: break;
0
2697 case QEvent::KeyPress: {
never executed: case QEvent::KeyPress:
0
2698 QKeyEvent *ke = (QKeyEvent*)e;-
2699 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
ke->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
ke->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2700 keyPressEvent(ke);-
2701 return true;
never executed: return true;
0
2702 }-
2703 } break;
never executed: break;
0
2704 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
2705 case QEvent::ContextMenu: {
never executed: case QEvent::ContextMenu:
0
2706 bool canPopup = true;-
2707 if (e->type() == QEvent::MouseButtonPress)
e->type() == Q...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
2708 canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton);
never executed: canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton);
0
2709 if (canPopup && d->delayState.timer.isActive()) {
canPopupDescription
TRUEnever evaluated
FALSEnever evaluated
d->delayState.timer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2710 d->delayState.stop();-
2711 internalDelayedPopup();-
2712 }
never executed: end of block
0
2713 }-
2714 break;
never executed: break;
0
2715 case QEvent::Resize: {
never executed: case QEvent::Resize:
0
2716 QStyleHintReturnMask menuMask;-
2717 QStyleOption option;-
2718 option.initFrom(this);-
2719 if (style()->styleHint(QStyle::SH_Menu_Mask, &option, this, &menuMask)) {
style()->style...is, &menuMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
2720 setMask(menuMask.region);-
2721 }
never executed: end of block
0
2722 d->itemsDirty = 1;-
2723 d->updateActionRects();-
2724 break; }
never executed: break;
0
2725 case QEvent::Show:
never executed: case QEvent::Show:
0
2726 d->mouseDown = 0;-
2727 d->updateActionRects();-
2728 d->sloppyState.reset();-
2729 if (d->currentAction)
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2730 d->popupAction(d->currentAction, 0, false);
never executed: d->popupAction(d->currentAction, 0, false);
0
2731 break;
never executed: break;
0
2732#ifndef QT_NO_TOOLTIP-
2733 case QEvent::ToolTip:
never executed: case QEvent::ToolTip:
0
2734 if (d->toolTipsVisible) {
d->toolTipsVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2735 const QHelpEvent *ev = static_cast<const QHelpEvent*>(e);-
2736 if (const QAction *action = actionAt(ev->pos())) {
const QAction ...nAt(ev->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2737 const QString toolTip = action->d_func()->tooltip;-
2738 if (!toolTip.isEmpty())
!toolTip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2739 QToolTip::showText(ev->globalPos(), toolTip, this);
never executed: QToolTip::showText(ev->globalPos(), toolTip, this);
0
2740 return true;
never executed: return true;
0
2741 }-
2742 }
never executed: end of block
0
2743 break;
never executed: break;
0
2744#endif // QT_NO_TOOLTIP-
2745#ifndef QT_NO_WHATSTHIS-
2746 case QEvent::QueryWhatsThis:
never executed: case QEvent::QueryWhatsThis:
0
2747 e->setAccepted(d->whatsThis.size());-
2748 if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
QAction *actio...t*>(e)->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2749 if (action->whatsThis().size() || action->menu())
action->whatsThis().size()Description
TRUEnever evaluated
FALSEnever evaluated
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
2750 e->accept();
never executed: e->accept();
0
2751 }
never executed: end of block
0
2752 return true;
never executed: return true;
0
2753#endif-
2754 default:
never executed: default:
0
2755 break;
never executed: break;
0
2756 }-
2757 return QWidget::event(e);
never executed: return QWidget::event(e);
0
2758}-
2759-
2760/*!-
2761 \reimp-
2762*/-
2763bool QMenu::focusNextPrevChild(bool next)-
2764{-
2765 setFocus();-
2766 QKeyEvent ev(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier);-
2767 keyPressEvent(&ev);-
2768 return true;
never executed: return true;
0
2769}-
2770-
2771/*!-
2772 \reimp-
2773*/-
2774void QMenu::keyPressEvent(QKeyEvent *e)-
2775{-
2776 Q_D(QMenu);-
2777 d->updateActionRects();-
2778 int key = e->key();-
2779 if (isRightToLeft()) { // in reverse mode open/close key for submenues are reversed
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2780 if (key == Qt::Key_Left)
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2781 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
2782 else if (key == Qt::Key_Right)
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2783 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
2784 }
never executed: end of block
0
2785#ifndef Q_OS_MAC-
2786 if (key == Qt::Key_Tab) //means down
key == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2787 key = Qt::Key_Down;
never executed: key = Qt::Key_Down;
0
2788 if (key == Qt::Key_Backtab) //means up
key == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2789 key = Qt::Key_Up;
never executed: key = Qt::Key_Up;
0
2790#endif-
2791-
2792 bool key_consumed = false;-
2793 switch(key) {-
2794 case Qt::Key_Home:
never executed: case Qt::Key_Home:
0
2795 key_consumed = true;-
2796 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2797 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
0
2798 break;
never executed: break;
0
2799 case Qt::Key_End:
never executed: case Qt::Key_End:
0
2800 key_consumed = true;-
2801 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2802 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
0
2803 break;
never executed: break;
0
2804 case Qt::Key_PageUp:
never executed: case Qt::Key_PageUp:
0
2805 key_consumed = true;-
2806 if (d->currentAction && d->scroll) {
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2807 if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
d->scroll->scr...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2808 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true);
0
2809 else-
2810 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
0
2811 }-
2812 break;
never executed: break;
0
2813 case Qt::Key_PageDown:
never executed: case Qt::Key_PageDown:
0
2814 key_consumed = true;-
2815 if (d->currentAction && d->scroll) {
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2816 if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
d->scroll->scr...er::ScrollDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
2817 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true);
0
2818 else-
2819 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
0
2820 }-
2821 break;
never executed: break;
0
2822 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
2823 case Qt::Key_Down: {
never executed: case Qt::Key_Down:
0
2824 key_consumed = true;-
2825 QAction *nextAction = 0;-
2826 QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay;-
2827 if (!d->currentAction) {
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2828 if(key == Qt::Key_Down) {
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
0
2829 for(int i = 0; i < d->actions.count(); ++i) {
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2830 QAction *act = d->actions.at(i);-
2831 if (d->actionRects.at(i).isNull())
d->actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2832 continue;
never executed: continue;
0
2833 if (!act->isSeparator() &&
!act->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
2834 (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
style()->style...bled, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2835 || act->isEnabled())) {
act->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2836 nextAction = act;-
2837 break;
never executed: break;
0
2838 }-
2839 }
never executed: end of block
0
2840 } else {
never executed: end of block
0
2841 for(int i = d->actions.count()-1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2842 QAction *act = d->actions.at(i);-
2843 if (d->actionRects.at(i).isNull())
d->actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2844 continue;
never executed: continue;
0
2845 if (!act->isSeparator() &&
!act->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
2846 (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
style()->style...bled, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2847 || act->isEnabled())) {
act->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2848 nextAction = act;-
2849 break;
never executed: break;
0
2850 }-
2851 }
never executed: end of block
0
2852 }
never executed: end of block
0
2853 } else {-
2854 for(int i = 0, y = 0; !nextAction && i < d->actions.count(); i++) {
!nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2855 QAction *act = d->actions.at(i);-
2856 if (act == d->currentAction) {
act == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2857 if (key == Qt::Key_Up) {
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2858 for(int next_i = i-1; true; next_i--) {
trueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2859 if (next_i == -1) {
next_i == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2860 if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
!style()->styl...Wrap, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2861 break;
never executed: break;
0
2862 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2863 scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
0
2864 next_i = d->actionRects.count()-1;-
2865 }
never executed: end of block
0
2866 QAction *next = d->actions.at(next_i);-
2867 if (next == d->currentAction)
next == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2868 break;
never executed: break;
0
2869 if (d->actionRects.at(next_i).isNull())
d->actionRects...xt_i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2870 continue;
never executed: continue;
0
2871 if (next->isSeparator() ||
next->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
2872 (!next->isEnabled() &&
!next->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2873 !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
!style()->styl...bled, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2874 continue;
never executed: continue;
0
2875 nextAction = next;-
2876 if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
(d->scroll->sc...ler::ScrollUp)Description
TRUEnever evaluated
FALSEnever evaluated
0
2877 int topVisible = d->scrollerHeight();-
2878 if (d->tearoff)
d->tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2879 topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
never executed: topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
0
2880 if (((y + d->scroll->scrollOffset) - topVisible) <= d->actionRects.at(next_i).height())
((y + d->scrol...xt_i).height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2881 scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
0
2882 }
never executed: end of block
0
2883 break;
never executed: break;
0
2884 }-
2885 if (!nextAction && d->tearoff)
!nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2886 d->tearoffHighlighted = 1;
never executed: d->tearoffHighlighted = 1;
0
2887 } else {
never executed: end of block
0
2888 y += d->actionRects.at(i).height();-
2889 for(int next_i = i+1; true; next_i++) {
trueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2890 if (next_i == d->actionRects.count()) {
next_i == d->a...nRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2891 if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
!style()->styl...Wrap, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2892 break;
never executed: break;
0
2893 if (d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2894 scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
0
2895 next_i = 0;-
2896 }
never executed: end of block
0
2897 QAction *next = d->actions.at(next_i);-
2898 if (next == d->currentAction)
next == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2899 break;
never executed: break;
0
2900 if (d->actionRects.at(next_i).isNull())
d->actionRects...xt_i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2901 continue;
never executed: continue;
0
2902 if (next->isSeparator() ||
next->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
0
2903 (!next->isEnabled() &&
!next->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2904 !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
!style()->styl...bled, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2905 continue;
never executed: continue;
0
2906 nextAction = next;-
2907 if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
(d->scroll->sc...r::ScrollDown)Description
TRUEnever evaluated
FALSEnever evaluated
0
2908 int bottomVisible = height() - d->scrollerHeight();-
2909 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
d->scroll->scr...ller::ScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2910 bottomVisible -= d->scrollerHeight();
never executed: bottomVisible -= d->scrollerHeight();
0
2911 if (d->tearoff)
d->tearoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2912 bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
never executed: bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
0
2913 if ((y + d->scroll->scrollOffset + d->actionRects.at(next_i).height()) > bottomVisible)
(y + d->scroll... bottomVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2914 scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
0
2915 }
never executed: end of block
0
2916 break;
never executed: break;
0
2917 }-
2918 }
never executed: end of block
0
2919 break;
never executed: break;
0
2920 }-
2921 y += d->actionRects.at(i).height();-
2922 }
never executed: end of block
0
2923 }
never executed: end of block
0
2924 if (nextAction) {
nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2925 if (d->scroll && scroll_loc != QMenuPrivate::QMenuScroller::ScrollStay) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
scroll_loc != ...er::ScrollStayDescription
TRUEnever evaluated
FALSEnever evaluated
0
2926 d->scroll->scrollTimer.stop();-
2927 d->scrollMenu(nextAction, scroll_loc);-
2928 }
never executed: end of block
0
2929 d->setCurrentAction(nextAction, /*popup*/-1, QMenuPrivate::SelectedFromKeyboard);-
2930 }
never executed: end of block
0
2931 break; }
never executed: break;
0
2932-
2933 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
2934 if (d->currentAction && d->currentAction->isEnabled() && d->currentAction->menu()) {
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->currentAction->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
2935 d->popupAction(d->currentAction, 0, true);-
2936 key_consumed = true;-
2937 break;
never executed: break;
0
2938 }-
2939 //FALL THROUGH-
2940 case Qt::Key_Left: {
code before this statement never executed: case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
2941 if (d->currentAction && !d->scroll) {
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
!d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
2942 QAction *nextAction = 0;-
2943 if (key == Qt::Key_Left) {
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2944 QRect actionR = d->actionRect(d->currentAction);-
2945 for(int x = actionR.left()-1; !nextAction && x >= 0; x--)
!nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
x >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2946 nextAction = d->actionAt(QPoint(x, actionR.center().y()));
never executed: nextAction = d->actionAt(QPoint(x, actionR.center().y()));
0
2947 } else {
never executed: end of block
0
2948 QRect actionR = d->actionRect(d->currentAction);-
2949 for(int x = actionR.right()+1; !nextAction && x < width(); x++)
!nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
x < width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2950 nextAction = d->actionAt(QPoint(x, actionR.center().y()));
never executed: nextAction = d->actionAt(QPoint(x, actionR.center().y()));
0
2951 }
never executed: end of block
0
2952 if (nextAction) {
nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2953 d->setCurrentAction(nextAction, /*popup*/-1, QMenuPrivate::SelectedFromKeyboard);-
2954 key_consumed = true;-
2955 }
never executed: end of block
0
2956 }
never executed: end of block
0
2957 if (!key_consumed && key == Qt::Key_Left && qobject_cast<QMenu*>(d->causedPopup.widget)) {
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...dPopup.widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2958 QPointer<QWidget> caused = d->causedPopup.widget;-
2959 d->hideMenu(this);-
2960 if (caused)
causedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2961 caused->setFocus();
never executed: caused->setFocus();
0
2962 key_consumed = true;-
2963 }
never executed: end of block
0
2964 break; }
never executed: break;
0
2965-
2966 case Qt::Key_Alt:
never executed: case Qt::Key_Alt:
0
2967 if (d->tornoff)
d->tornoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
2968 break;
never executed: break;
0
2969-
2970 key_consumed = true;-
2971 if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this))
style()->style...tion, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2972 {-
2973 d->hideMenu(this);-
2974#ifndef QT_NO_MENUBAR-
2975 if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())) {
QMenuBar *mb =...focusWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
2976 mb->d_func()->setKeyboardMode(false);-
2977 }
never executed: end of block
0
2978#endif-
2979 }
never executed: end of block
0
2980 break;
never executed: break;
0
2981-
2982 case Qt::Key_Space:
never executed: case Qt::Key_Space:
0
2983 if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this))
!style()->styl...Item, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2984 break;
never executed: break;
0
2985 // for motif, fall through-
2986#ifdef QT_KEYPAD_NAVIGATION-
2987 case Qt::Key_Select:-
2988#endif-
2989 case Qt::Key_Return:
code before this statement never executed: case Qt::Key_Return:
never executed: case Qt::Key_Return:
0
2990 case Qt::Key_Enter: {
never executed: case Qt::Key_Enter:
0
2991 if (!d->currentAction) {
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2992 d->setFirstActionActive();-
2993 key_consumed = true;-
2994 break;
never executed: break;
0
2995 }-
2996-
2997 d->setSyncAction();-
2998-
2999 if (d->currentAction->menu())
d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3000 d->popupAction(d->currentAction, 0, true);
never executed: d->popupAction(d->currentAction, 0, true);
0
3001 else-
3002 d->activateAction(d->currentAction, QAction::Trigger);
never executed: d->activateAction(d->currentAction, QAction::Trigger);
0
3003 key_consumed = true;-
3004 break; }
never executed: break;
0
3005-
3006#ifndef QT_NO_WHATSTHIS-
3007 case Qt::Key_F1:
never executed: case Qt::Key_F1:
0
3008 if (!d->currentAction || d->currentAction->whatsThis().isNull())
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
d->currentActi...his().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3009 break;
never executed: break;
0
3010 QWhatsThis::enterWhatsThisMode();-
3011 d->activateAction(d->currentAction, QAction::Trigger);-
3012 return;
never executed: return;
0
3013#endif-
3014 default:
never executed: default:
0
3015 key_consumed = false;-
3016 }
never executed: end of block
0
3017-
3018 if (!key_consumed && (e->matches(QKeySequence::Cancel)
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
(e->matches(QK...nce::Cancel) )Description
TRUEnever evaluated
FALSEnever evaluated
0
3019#ifdef QT_KEYPAD_NAVIGATION
(e->matches(QK...nce::Cancel) )Description
TRUEnever evaluated
FALSEnever evaluated
0
3020 || e->key() == Qt::Key_Back
(e->matches(QK...nce::Cancel) )Description
TRUEnever evaluated
FALSEnever evaluated
0
3021#endif
(e->matches(QK...nce::Cancel) )Description
TRUEnever evaluated
FALSEnever evaluated
0
3022 )) {
(e->matches(QK...nce::Cancel) )Description
TRUEnever evaluated
FALSEnever evaluated
0
3023 key_consumed = true;-
3024 if (d->tornoff) {
d->tornoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
3025 close();-
3026 return;
never executed: return;
0
3027 }-
3028 {-
3029 QPointer<QWidget> caused = d->causedPopup.widget;-
3030 d->hideMenu(this); // hide after getting causedPopup-
3031#ifndef QT_NO_MENUBAR-
3032 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
QMenuBar *mb =...uBar*>(caused)Description
TRUEnever evaluated
FALSEnever evaluated
0
3033 mb->d_func()->setCurrentAction(d->menuAction);-
3034 mb->d_func()->setKeyboardMode(true);-
3035 }
never executed: end of block
0
3036#endif-
3037 }-
3038 }
never executed: end of block
0
3039-
3040 if (!key_consumed) { // send to menu bar
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3041 if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) &&
!e->modifiers()Description
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()...t::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3042 e->text().length()==1) {
e->text().length()==1Description
TRUEnever evaluated
FALSEnever evaluated
0
3043 bool activateAction = false;-
3044 QAction *nextAction = 0;-
3045 if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this) && !e->modifiers()) {
style()->style...arch, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
!e->modifiers()Description
TRUEnever evaluated
FALSEnever evaluated
0
3046 int best_match_count = 0;-
3047 d->searchBufferTimer.start(2000, this);-
3048 d->searchBuffer += e->text();-
3049 for(int i = 0; i < d->actions.size(); ++i) {
i < d->actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3050 int match_count = 0;-
3051 if (d->actionRects.at(i).isNull())
d->actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3052 continue;
never executed: continue;
0
3053 QAction *act = d->actions.at(i);-
3054 const QString act_text = act->text();-
3055 for(int c = 0; c < d->searchBuffer.size(); ++c) {
c < d->searchBuffer.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3056 if(act_text.indexOf(d->searchBuffer.at(c), 0, Qt::CaseInsensitive) != -1)
act_text.index...nsitive) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
3057 ++match_count;
never executed: ++match_count;
0
3058 }
never executed: end of block
0
3059 if(match_count > best_match_count) {
match_count > best_match_countDescription
TRUEnever evaluated
FALSEnever evaluated
0
3060 best_match_count = match_count;-
3061 nextAction = act;-
3062 }
never executed: end of block
0
3063 }
never executed: end of block
0
3064 }
never executed: end of block
0
3065#ifndef QT_NO_SHORTCUT-
3066 else {-
3067 int clashCount = 0;-
3068 QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;-
3069 QChar c = e->text().at(0).toUpper();-
3070 for(int i = 0; i < d->actions.size(); ++i) {
i < d->actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3071 if (d->actionRects.at(i).isNull())
d->actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3072 continue;
never executed: continue;
0
3073 QAction *act = d->actions.at(i);-
3074 QKeySequence sequence = QKeySequence::mnemonic(act->text());-
3075 int key = sequence[0] & 0xffff;-
3076 if (key == c.unicode()) {
key == c.unicode()Description
TRUEnever evaluated
FALSEnever evaluated
0
3077 clashCount++;-
3078 if (!first)
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
3079 first = act;
never executed: first = act;
0
3080 if (act == d->currentAction)
act == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3081 currentSelected = act;
never executed: currentSelected = act;
0
3082 else if (!firstAfterCurrent && currentSelected)
!firstAfterCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
currentSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3083 firstAfterCurrent = act;
never executed: firstAfterCurrent = act;
0
3084 }
never executed: end of block
0
3085 }
never executed: end of block
0
3086 if (clashCount == 1)
clashCount == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3087 activateAction = true;
never executed: activateAction = true;
0
3088 if (clashCount >= 1) {
clashCount >= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3089 if (clashCount == 1 || !currentSelected || !firstAfterCurrent)
clashCount == 1Description
TRUEnever evaluated
FALSEnever evaluated
!currentSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
!firstAfterCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3090 nextAction = first;
never executed: nextAction = first;
0
3091 else-
3092 nextAction = firstAfterCurrent;
never executed: nextAction = firstAfterCurrent;
0
3093 }-
3094 }
never executed: end of block
0
3095#endif-
3096 if (nextAction) {
nextActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3097 key_consumed = true;-
3098 if(d->scroll)
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
3099 d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false);
never executed: d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false);
0
3100 d->setCurrentAction(nextAction, 0, QMenuPrivate::SelectedFromElsewhere, true);-
3101 if (!nextAction->menu() && activateAction) {
!nextAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
activateActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3102 d->setSyncAction();-
3103 d->activateAction(nextAction, QAction::Trigger);-
3104 }
never executed: end of block
0
3105 }
never executed: end of block
0
3106 }
never executed: end of block
0
3107 if (!key_consumed) {
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3108#ifndef QT_NO_MENUBAR-
3109 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) {
QMenuBar *mb =...ausedWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
3110 QAction *oldAct = mb->d_func()->currentAction;-
3111 QApplication::sendEvent(mb, e);-
3112 if (mb->d_func()->currentAction != oldAct)
mb->d_func()->...tion != oldActDescription
TRUEnever evaluated
FALSEnever evaluated
0
3113 key_consumed = true;
never executed: key_consumed = true;
0
3114 }
never executed: end of block
0
3115#endif-
3116 }
never executed: end of block
0
3117-
3118#ifdef Q_OS_WIN32-
3119 if (key_consumed && (e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift || e->key() == Qt::Key_Meta))-
3120 QApplication::beep();-
3121#endif // Q_OS_WIN32-
3122 }
never executed: end of block
0
3123 if (key_consumed)
key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3124 e->accept();
never executed: e->accept();
0
3125 else-
3126 e->ignore();
never executed: e->ignore();
0
3127}-
3128-
3129/*!-
3130 \reimp-
3131*/-
3132void QMenu::mouseMoveEvent(QMouseEvent *e)-
3133{-
3134 Q_D(QMenu);-
3135 if (!isVisible() || d->aboutToHide || d->mouseEventTaken(e))
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
d->aboutToHideDescription
TRUEnever evaluated
FALSEnever evaluated
d->mouseEventTaken(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
3136 return;
never executed: return;
0
3137-
3138 d->motions++;-
3139 if (d->motions == 0)
d->motions == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3140 return;
never executed: return;
0
3141-
3142 d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos());
d->hasHadMouseDescription
TRUEnever evaluated
FALSEnever evaluated
rect().contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
3143-
3144 QAction *action = d->actionAt(e->pos());-
3145 if ((!action || action->isSeparator()) && !d->sloppyState.enabled()) {
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
!d->sloppyState.enabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
3146 if (d->hasHadMouse
d->hasHadMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
3147 || (!d->currentAction || !d->currentAction->menu() || !d->currentAction->menu()->isVisible())) {
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
!d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
!d->currentAct...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3148 d->setCurrentAction(action);-
3149 }
never executed: end of block
0
3150 return;
never executed: return;
0
3151 }-
3152-
3153 if (e->buttons())
e->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
3154 d->mouseDown = this;
never executed: d->mouseDown = this;
0
3155-
3156 if (d->activeMenu)
d->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
3157 d->activeMenu->d_func()->setCurrentAction(0);
never executed: d->activeMenu->d_func()->setCurrentAction(0);
0
3158-
3159 QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction);-
3160 if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) {
sloppyEventRes...ldBePropagatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3161 d->setCurrentAction(action, d->mousePopupDelay);-
3162 } else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) {
never executed: end of block
sloppyEventRes...rdsSloppyStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3163 d->sloppyState.reset();-
3164 d->hideMenu(d->activeMenu);-
3165 }
never executed: end of block
0
3166}
never executed: end of block
0
3167-
3168/*!-
3169 \reimp-
3170*/-
3171void QMenu::enterEvent(QEvent *)-
3172{-
3173 Q_D(QMenu);-
3174 d->hasReceievedEnter = true;-
3175 d->sloppyState.enter();-
3176 d->motions = -1; // force us to ignore the generate mouse move in mouseMoveEvent()-
3177}
never executed: end of block
0
3178-
3179/*!-
3180 \reimp-
3181*/-
3182void QMenu::leaveEvent(QEvent *)-
3183{-
3184 Q_D(QMenu);-
3185 d->hasReceievedEnter = false;-
3186 if (!d->activeMenu && d->currentAction)
!d->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3187 setActiveAction(0);
never executed: setActiveAction(0);
0
3188}
never executed: end of block
0
3189-
3190/*!-
3191 \reimp-
3192*/-
3193void-
3194QMenu::timerEvent(QTimerEvent *e)-
3195{-
3196 Q_D(QMenu);-
3197 if (d->scroll && d->scroll->scrollTimer.timerId() == e->timerId()) {
d->scrollDescription
TRUEnever evaluated
FALSEnever evaluated
d->scroll->scr...= e->timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
3198 d->scrollMenu((QMenuPrivate::QMenuScroller::ScrollDirection)d->scroll->scrollDirection);-
3199 if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone)
d->scroll->scr...er::ScrollNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3200 d->scroll->scrollTimer.stop();
never executed: d->scroll->scrollTimer.stop();
0
3201 } else if (d->delayState.timer.timerId() == e->timerId()) {
never executed: end of block
d->delayState....= e->timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
3202 if (d->currentAction && !d->currentAction->menu())
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
!d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3203 return;
never executed: return;
0
3204 d->delayState.stop();-
3205 d->sloppyState.stopTimer();-
3206 internalDelayedPopup();-
3207 } else if (d->sloppyState.isTimerId(e->timerId())) {
never executed: end of block
d->sloppyState...(e->timerId())Description
TRUEnever evaluated
FALSEnever evaluated
0
3208 d->sloppyState.timeout();-
3209 } else if(d->searchBufferTimer.timerId() == e->timerId()) {
never executed: end of block
d->searchBuffe...= e->timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
3210 d->searchBuffer.clear();-
3211 }
never executed: end of block
0
3212}
never executed: end of block
0
3213-
3214static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu)-
3215{-
3216 item->setText(action->text());-
3217 item->setIsSeparator(action->isSeparator());-
3218 if (action->isIconVisibleInMenu()) {
action->isIconVisibleInMenu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3219 item->setIcon(action->icon());-
3220 if (QWidget *w = action->parentWidget()) {
QWidget *w = a...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
3221 QStyleOption opt;-
3222 opt.init(w);-
3223 item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));-
3224 } else {
never executed: end of block
0
3225 QStyleOption opt;-
3226 item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));-
3227 }
never executed: end of block
0
3228 } else {-
3229 item->setIcon(QIcon());-
3230 }
never executed: end of block
0
3231 item->setVisible(action->isVisible());-
3232 item->setShortcut(action->shortcut());-
3233 item->setCheckable(action->isCheckable());-
3234 item->setChecked(action->isChecked());-
3235 item->setFont(action->font());-
3236 item->setRole((QPlatformMenuItem::MenuRole) action->menuRole());-
3237 item->setEnabled(action->isEnabled());-
3238-
3239 if (action->menu()) {
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3240 if (!action->menu()->platformMenu())
!action->menu(...platformMenu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3241 action->menu()->setPlatformMenu(itemsMenu->createSubMenu());
never executed: action->menu()->setPlatformMenu(itemsMenu->createSubMenu());
0
3242 item->setMenu(action->menu()->platformMenu());-
3243 } else {
never executed: end of block
0
3244 item->setMenu(0);-
3245 }
never executed: end of block
0
3246}-
3247-
3248/*!-
3249 \reimp-
3250*/-
3251void QMenu::actionEvent(QActionEvent *e)-
3252{-
3253 Q_D(QMenu);-
3254 d->itemsDirty = 1;-
3255 setAttribute(Qt::WA_Resized, false);-
3256 if (d->tornPopup)
d->tornPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
3257 d->tornPopup->syncWithMenu(this, e);
never executed: d->tornPopup->syncWithMenu(this, e);
0
3258 if (e->type() == QEvent::ActionAdded) {
e->type() == Q...t::ActionAddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3259 if(!d->tornoff) {
!d->tornoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
3260 connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));-
3261 connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()));-
3262 }
never executed: end of block
0
3263 if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
QWidgetAction ...>(e->action())Description
TRUEnever evaluated
FALSEnever evaluated
0
3264 QWidget *widget = wa->requestWidget(this);-
3265 if (widget)
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3266 d->widgetItems.insert(wa, widget);
never executed: d->widgetItems.insert(wa, widget);
0
3267 }
never executed: end of block
0
3268 } else if (e->type() == QEvent::ActionRemoved) {
never executed: end of block
e->type() == Q...:ActionRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3269 e->action()->disconnect(this);-
3270 if (e->action() == d->currentAction)
e->action() ==...>currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3271 d->currentAction = 0;
never executed: d->currentAction = 0;
0
3272 if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
QWidgetAction ...>(e->action())Description
TRUEnever evaluated
FALSEnever evaluated
0
3273 if (QWidget *widget = d->widgetItems.value(wa)) {
QWidget *widge...tems.value(wa)Description
TRUEnever evaluated
FALSEnever evaluated
0
3274#ifdef Q_OS_OSX-
3275 QWidget *p = widget->parentWidget();-
3276 if (p != this && qobject_cast<QMacNativeWidget *>(p)) {-
3277 // This widget was reparented into a native Mac view-
3278 // (see QMenuPrivate::moveWidgetToPlatformItem).-
3279 // Reset the parent and delete the native widget.-
3280 widget->setParent(this);-
3281 p->deleteLater();-
3282 }-
3283#endif-
3284 wa->releaseWidget(widget);-
3285 }
never executed: end of block
0
3286 }
never executed: end of block
0
3287 d->widgetItems.remove(e->action());-
3288 }
never executed: end of block
0
3289-
3290 if (!d->platformMenu.isNull()) {
!d->platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3291 if (e->type() == QEvent::ActionAdded) {
e->type() == Q...t::ActionAddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3292 QPlatformMenuItem *menuItem = d->platformMenu->createMenuItem();-
3293 menuItem->setTag(reinterpret_cast<quintptr>(e->action()));-
3294 QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger()));-
3295 QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered()));-
3296 copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);-
3297 QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()));-
3298 d->platformMenu->insertMenuItem(menuItem, beforeItem);-
3299 } else if (e->type() == QEvent::ActionRemoved) {
never executed: end of block
e->type() == Q...:ActionRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3300 QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));-
3301 d->platformMenu->removeMenuItem(menuItem);-
3302 delete menuItem;-
3303 } else if (e->type() == QEvent::ActionChanged) {
never executed: end of block
e->type() == Q...:ActionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3304 QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));-
3305 if (menuItem) {
menuItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3306 copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);-
3307 d->platformMenu->syncMenuItem(menuItem);-
3308 }
never executed: end of block
0
3309 }
never executed: end of block
0
3310-
3311 d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators);-
3312 }
never executed: end of block
0
3313-
3314#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)-
3315 if (!d->wce_menu)-
3316 d->wce_menu = new QMenuPrivate::QWceMenuPrivate;-
3317 if (e->type() == QEvent::ActionAdded)-
3318 d->wce_menu->addAction(e->action(), d->wce_menu->findAction(e->before()));-
3319 else if (e->type() == QEvent::ActionRemoved)-
3320 d->wce_menu->removeAction(e->action());-
3321 else if (e->type() == QEvent::ActionChanged)-
3322 d->wce_menu->syncAction(e->action());-
3323#endif-
3324-
3325 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3326 d->updateActionRects();-
3327 resize(sizeHint());-
3328 update();-
3329 }
never executed: end of block
0
3330}
never executed: end of block
0
3331-
3332/*!-
3333 \internal-
3334*/-
3335void QMenu::internalDelayedPopup()-
3336{-
3337 Q_D(QMenu);-
3338 //hide the current item-
3339 if (QMenu *menu = d->activeMenu) {
QMenu *menu = d->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
0
3340 if (d->activeMenu->menuAction() != d->currentAction)
d->activeMenu-...>currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3341 d->hideMenu(menu);
never executed: d->hideMenu(menu);
0
3342 }
never executed: end of block
0
3343-
3344 if (!d->currentAction || !d->currentAction->isEnabled() || !d->currentAction->menu() ||
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
!d->currentAction->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
3345 !d->currentAction->menu()->isEnabled() || d->currentAction->menu()->isVisible())
!d->currentAct...)->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
d->currentActi...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3346 return;
never executed: return;
0
3347-
3348 //setup-
3349 d->activeMenu = d->currentAction->menu();-
3350 d->activeMenu->d_func()->causedPopup.widget = this;-
3351 d->activeMenu->d_func()->causedPopup.action = d->currentAction;-
3352-
3353 int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);-
3354 const QRect actionRect(d->actionRect(d->currentAction));-
3355 const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));-
3356-
3357 d->activeMenu->popup(rightPos);-
3358 d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu);-
3359-
3360#if !defined(Q_OS_DARWIN)-
3361 // Send the leave event to the current menu - only active popup menu gets-
3362 // mouse enter/leave events. Currently Cocoa is an exception, so disable-
3363 // it there to avoid event duplication.-
3364 if (underMouse()) {
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
3365 QEvent leaveEvent(QEvent::Leave);-
3366 QCoreApplication::sendEvent(this, &leaveEvent);-
3367 }
never executed: end of block
0
3368#endif-
3369}
never executed: end of block
0
3370-
3371/*!-
3372 \fn void QMenu::aboutToHide()-
3373 \since 4.2-
3374-
3375 This signal is emitted just before the menu is hidden from the user.-
3376-
3377 \sa aboutToShow(), hide()-
3378*/-
3379-
3380/*!-
3381 \fn void QMenu::aboutToShow()-
3382-
3383 This signal is emitted just before the menu is shown to the user.-
3384-
3385 \sa aboutToHide(), show()-
3386*/-
3387-
3388/*!-
3389 \fn void QMenu::triggered(QAction *action)-
3390-
3391 This signal is emitted when an action in this menu is triggered.-
3392-
3393 \a action is the action that caused the signal to be emitted.-
3394-
3395 Normally, you connect each menu action's \l{QAction::}{triggered()} signal-
3396 to its own custom slot, but sometimes you will want to connect several-
3397 actions to a single slot, for example, when you have a group of closely-
3398 related actions, such as "left justify", "center", "right justify".-
3399-
3400 \note This signal is emitted for the main parent menu in a hierarchy.-
3401 Hence, only the parent menu needs to be connected to a slot; sub-menus need-
3402 not be connected.-
3403-
3404 \sa hovered(), QAction::triggered()-
3405*/-
3406-
3407/*!-
3408 \fn void QMenu::hovered(QAction *action)-
3409-
3410 This signal is emitted when a menu action is highlighted; \a action-
3411 is the action that caused the signal to be emitted.-
3412-
3413 Often this is used to update status information.-
3414-
3415 \sa triggered(), QAction::hovered()-
3416*/-
3417-
3418-
3419/*!\internal-
3420*/-
3421void QMenu::setNoReplayFor(QWidget *noReplayFor)-
3422{-
3423 d_func()->noReplayFor = noReplayFor;-
3424}
never executed: end of block
0
3425-
3426/*!\internal-
3427*/-
3428QPlatformMenu *QMenu::platformMenu()-
3429{-
3430-
3431 return d_func()->platformMenu;
never executed: return d_func()->platformMenu;
0
3432}-
3433-
3434/*!\internal-
3435*/-
3436void QMenu::setPlatformMenu(QPlatformMenu *platformMenu)-
3437{-
3438 d_func()->setPlatformMenu(platformMenu);-
3439 d_func()->syncPlatformMenu();-
3440}
never executed: end of block
0
3441-
3442/*!-
3443 \property QMenu::separatorsCollapsible-
3444 \since 4.2-
3445-
3446 \brief whether consecutive separators should be collapsed-
3447-
3448 This property specifies whether consecutive separators in the menu-
3449 should be visually collapsed to a single one. Separators at the-
3450 beginning or the end of the menu are also hidden.-
3451-
3452 By default, this property is \c true.-
3453*/-
3454bool QMenu::separatorsCollapsible() const-
3455{-
3456 Q_D(const QMenu);-
3457 return d->collapsibleSeparators;
never executed: return d->collapsibleSeparators;
0
3458}-
3459-
3460void QMenu::setSeparatorsCollapsible(bool collapse)-
3461{-
3462 Q_D(QMenu);-
3463 if (d->collapsibleSeparators == collapse)
d->collapsible...rs == collapseDescription
TRUEnever evaluated
FALSEnever evaluated
0
3464 return;
never executed: return;
0
3465-
3466 d->collapsibleSeparators = collapse;-
3467 d->itemsDirty = 1;-
3468 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3469 d->updateActionRects();-
3470 update();-
3471 }
never executed: end of block
0
3472 if (!d->platformMenu.isNull())
!d->platformMenu.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3473 d->platformMenu->syncSeparatorsCollapsible(collapse);
never executed: d->platformMenu->syncSeparatorsCollapsible(collapse);
0
3474}
never executed: end of block
0
3475-
3476/*!-
3477 \property QMenu::toolTipsVisible-
3478 \since 5.1-
3479-
3480 \brief whether tooltips of menu actions should be visible-
3481-
3482 This property specifies whether action menu entries show-
3483 their tooltip.-
3484-
3485 By default, this property is \c false.-
3486*/-
3487bool QMenu::toolTipsVisible() const-
3488{-
3489 Q_D(const QMenu);-
3490 return d->toolTipsVisible;
never executed: return d->toolTipsVisible;
0
3491}-
3492-
3493void QMenu::setToolTipsVisible(bool visible)-
3494{-
3495 Q_D(QMenu);-
3496 if (d->toolTipsVisible == visible)
d->toolTipsVisible == visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3497 return;
never executed: return;
0
3498-
3499 d->toolTipsVisible = visible;-
3500}
never executed: end of block
0
3501-
3502QT_END_NAMESPACE-
3503-
3504// for private slots-
3505#include "moc_qmenu.cpp"-
3506#include "qmenu.moc"-
3507-
3508#endif // QT_NO_MENU-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9