OpenCoverage

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

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