qmenubar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmenubar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15class QMenuBarExtension : public QToolButton-
16{-
17public:-
18 explicit QMenuBarExtension(QWidget *parent);-
19-
20 QSize sizeHint() const override;-
21 void paintEvent(QPaintEvent *) override;-
22};-
23-
24QMenuBarExtension::QMenuBarExtension(QWidget *parent)-
25 : QToolButton(parent)-
26{-
27 setObjectName(QLatin1String("qt_menubar_ext_button"));-
28 setAutoRaise(true);-
29-
30 setPopupMode(QToolButton::InstantPopup);-
31-
32 setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget()));-
33}
never executed: end of block
0
34-
35void QMenuBarExtension::paintEvent(QPaintEvent *)-
36{-
37 QStylePainter p(this);-
38 QStyleOptionToolButton opt;-
39 initStyleOption(&opt);-
40-
41 opt.features &= ~QStyleOptionToolButton::HasMenu;-
42 p.drawComplexControl(QStyle::CC_ToolButton, opt);-
43}
never executed: end of block
0
44-
45-
46QSize QMenuBarExtension::sizeHint() const-
47{-
48 int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget());-
49 return
never executed: return QSize(ext, ext);
QSize(ext, ext);
never executed: return QSize(ext, ext);
0
50}-
51-
52-
53-
54-
55-
56QAction *QMenuBarPrivate::actionAt(QPoint p) const-
57{-
58 for(int i = 0; i < actions.size()
i < actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
59 if(actionRect(actions.at(i)).contains(p)
actionRect(act...)).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
60 return
never executed: return actions.at(i);
actions.at(i);
never executed: return actions.at(i);
0
61 }
never executed: end of block
0
62 return
never executed: return 0;
0;
never executed: return 0;
0
63}-
64-
65QRect QMenuBarPrivate::menuRect(bool extVisible) const-
66{-
67 const QMenuBar * const q = q_func();-
68-
69 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);-
70 QRect result = q->rect();-
71 result.adjust(hmargin, 0, -hmargin, 0);-
72-
73 if (extVisible
extVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
74 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
75 result.setLeft(result.left() + extension->sizeHint().width());
never executed: result.setLeft(result.left() + extension->sizeHint().width());
0
76 else-
77 result.setWidth(result.width() - extension->sizeHint().width());
never executed: result.setWidth(result.width() - extension->sizeHint().width());
0
78 }-
79-
80 if (leftWidget
leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& leftWidget->isVisible()
leftWidget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
81 QSize sz = leftWidget->sizeHint();-
82 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
83 result.setRight(result.right() - sz.width());
never executed: result.setRight(result.right() - sz.width());
0
84 else-
85 result.setLeft(result.left() + sz.width());
never executed: result.setLeft(result.left() + sz.width());
0
86 }-
87-
88 if (rightWidget
rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& rightWidget->isVisible()
rightWidget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
89 QSize sz = rightWidget->sizeHint();-
90 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
91 result.setLeft(result.left() + sz.width());
never executed: result.setLeft(result.left() + sz.width());
0
92 else-
93 result.setRight(result.right() - sz.width());
never executed: result.setRight(result.right() - sz.width());
0
94 }-
95-
96 return
never executed: return result;
result;
never executed: return result;
0
97}-
98-
99bool QMenuBarPrivate::isVisible(QAction *action)-
100{-
101 return
never executed: return !hiddenActions.contains(action);
!hiddenActions.contains(action);
never executed: return !hiddenActions.contains(action);
0
102}-
103-
104void QMenuBarPrivate::updateGeometries()-
105{-
106 QMenuBar * const q = q_func();-
107 if(!itemsDirty
!itemsDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
108 return;
never executed: return;
0
109 int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);-
110 int q_start = -1;-
111 if(leftWidget
leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
|| rightWidget
rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)-
113 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);-
114 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)-
115 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);-
116 if (leftWidget
leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& leftWidget->isVisible()
leftWidget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
117 QSize sz = leftWidget->sizeHint();-
118 q_width -= sz.width();-
119 q_start = sz.width();-
120 QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2);-
121 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));-
122 leftWidget->setGeometry(vRect);-
123 }
never executed: end of block
0
124 if (rightWidget
rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& rightWidget->isVisible()
rightWidget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
125 QSize sz = rightWidget->sizeHint();-
126 q_width -= sz.width();-
127 QPoint pos(q->width() - sz.width() - hmargin, vmargin);-
128 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));-
129 rightWidget->setGeometry(vRect);-
130 }
never executed: end of block
0
131 }
never executed: end of block
0
132-
133-
134-
135-
136-
137-
138-
139 calcActionRects(q_width, q_start);-
140 currentAction = 0;-
141-
142 if(itemsDirty
itemsDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
143 for(int j = 0; j < shortcutIndexMap.size()
j < shortcutIndexMap.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j)
0
144 q->releaseShortcut(shortcutIndexMap.value(j));
never executed: q->releaseShortcut(shortcutIndexMap.value(j));
0
145 shortcutIndexMap.resize(0);-
146 const int actionsCount = actions.count();-
147 shortcutIndexMap.reserve(actionsCount);-
148 for (int i = 0; i < actionsCount
i < actionsCountDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
149 shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
never executed: shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
0
150 }
never executed: end of block
0
151-
152 itemsDirty = false;-
153-
154 hiddenActions.clear();-
155-
156 QRect menuRect = this->menuRect(false);-
157-
158-
159 bool hasHiddenActions = false;-
160 for (int i = 0; i < actions.count()
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
161 const QRect &rect = actionRects.at(i);-
162 if (rect.isValid()
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& !menuRect.contains(rect)
!menuRect.contains(rect)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
163 hasHiddenActions = true;-
164 break;
never executed: break;
0
165 }-
166 }
never executed: end of block
0
167-
168-
169 if (hasHiddenActions
hasHiddenActionsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
170 menuRect = this->menuRect(true);-
171 for (int i = 0; i < actions.count()
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
172 const QRect &rect = actionRects.at(i);-
173 if (rect.isValid()
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& !menuRect.contains(rect)
!menuRect.contains(rect)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 hiddenActions.append(actions.at(i));-
175 }
never executed: end of block
0
176 }
never executed: end of block
0
177 }
never executed: end of block
0
178-
179 if (hiddenActions.count() > 0
hiddenActions.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
180 QMenu *pop = extension->menu();-
181 if (!pop
!popDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
182 pop = new QMenu(q);-
183 extension->setMenu(pop);-
184 }
never executed: end of block
0
185 pop->clear();-
186 pop->addActions(hiddenActions);-
187-
188 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);-
189 int x = q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
190 ? menuRect.left() - extension->sizeHint().width() + 1-
191 : menuRect.right();-
192 extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);-
193 extension->show();-
194 }
never executed: end of block
else {
0
195 extension->hide();-
196 }
never executed: end of block
0
197 q->updateGeometry();-
198}
never executed: end of block
0
199-
200QRect QMenuBarPrivate::actionRect(QAction *act) const-
201{-
202 const int index = actions.indexOf(act);-
203-
204-
205 const_cast<QMenuBarPrivate*>(this)->updateGeometries();-
206-
207 if (index < 0
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| index >= actionRects.count()
index >= actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
208 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
209-
210 return
never executed: return actionRects.at(index);
actionRects.at(index);
never executed: return actionRects.at(index);
0
211}-
212-
213void QMenuBarPrivate::focusFirstAction()-
214{-
215 if(!currentAction
!currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
216 updateGeometries();-
217 int index = 0;-
218 while (index < actions.count()
index < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
&& actionRects.at(index).isNull()
actionRects.at(index).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) ++
never executed: ++index;
index;
never executed: ++index;
0
219 if (index < actions.count()
index < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
220 setCurrentAction(actions.at(index));
never executed: setCurrentAction(actions.at(index));
0
221 }
never executed: end of block
0
222}
never executed: end of block
0
223-
224void QMenuBarPrivate::setKeyboardMode(bool b)-
225{-
226 QMenuBar * const q = q_func();-
227 if (b
bDescription
TRUEnever evaluated
FALSEnever evaluated
&& !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)
!q->style()->s...igation, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
228 setCurrentAction(0);-
229 return;
never executed: return;
0
230 }-
231 keyboardState = b;-
232 if(b
bDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
233 QWidget *fw = QApplication::focusWidget();-
234 if (fw != q
fw != qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
235 keyboardFocusWidget = fw;
never executed: keyboardFocusWidget = fw;
0
236 focusFirstAction();-
237 q->setFocus(Qt::MenuBarFocusReason);-
238 }
never executed: end of block
else {
0
239 if(!popupState
!popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
240 setCurrentAction(0);
never executed: setCurrentAction(0);
0
241 if(keyboardFocusWidget
keyboardFocusWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
242 if (QApplication::focusWidget() == q
QApplication::...sWidget() == qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
243 keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
never executed: keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
0
244 keyboardFocusWidget = 0;-
245 }
never executed: end of block
0
246 }
never executed: end of block
0
247 q->update();-
248}
never executed: end of block
0
249-
250void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)-
251{-
252 QMenuBar * const q = q_func();-
253 if(!action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !action->menu()
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
|| closePopupMode
closePopupModeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
254 return;
never executed: return;
0
255 popupState = true;-
256 if (action->isEnabled()
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
&& action->menu()->isEnabled()
action->menu()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
257 closePopupMode = 0;-
258 activeMenu = action->menu();-
259 activeMenu->d_func()->causedPopup.widget = q;-
260 activeMenu->d_func()->causedPopup.action = action;-
261-
262 QRect adjustedActionRect = actionRect(action);-
263 QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));-
264 QSize popup_size = activeMenu->sizeHint();-
265-
266-
267 QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));-
268 pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));-
269-
270 const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());-
271 const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom());-
272 const bool rtl = q->isRightToLeft();-
273 const int actionWidth = adjustedActionRect.width();-
274-
275 if (!fitUp
!fitUpDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fitDown
!fitDownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
276 bool shouldShiftToRight = !rtl;-
277 if (rtl
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
&& popup_size.width() > pos.x()
popup_size.width() > pos.x()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
278 shouldShiftToRight = true;
never executed: shouldShiftToRight = true;
0
279 else if (actionWidth + popup_size.width() + pos.x() > screenRect.right()
actionWidth + ...enRect.right()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 shouldShiftToRight = false;
never executed: shouldShiftToRight = false;
0
281-
282 if (shouldShiftToRight
shouldShiftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
283 pos.rx() += actionWidth + (rtl
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
? popup_size.width() : 0);
0
284 }
never executed: end of block
else {
0
285-
286 if (!rtl
!rtlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
287 pos.rx() -= popup_size.width();
never executed: pos.rx() -= popup_size.width();
0
288 }
never executed: end of block
0
289 } else if (rtl
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
290 pos.rx() += actionWidth;-
291 }
never executed: end of block
0
292-
293 if(!defaultPopDown
!defaultPopDownDescription
TRUEnever evaluated
FALSEnever evaluated
|| (fitUp
fitUpDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fitDown
!fitDownDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
294 pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
never executed: pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
0
295 activeMenu->popup(pos);-
296 if(activateFirst
activateFirstDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
297 activeMenu->d_func()->setFirstActionActive();
never executed: activeMenu->d_func()->setFirstActionActive();
0
298 }
never executed: end of block
0
299 q->update(actionRect(action));-
300}
never executed: end of block
0
301-
302void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst)-
303{-
304 if(currentAction == action
currentAction == actionDescription
TRUEnever evaluated
FALSEnever evaluated
&& popup == popupState
popup == popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
305 return;
never executed: return;
0
306-
307 autoReleaseTimer.stop();-
308-
309 doChildEffects = (popup
popupDescription
TRUEnever evaluated
FALSEnever evaluated
&& !activeMenu
!activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
310 QMenuBar * const q = q_func();-
311 QWidget *fw = 0;-
312 if(QMenu *menu = activeMenu
QMenu *menu = activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
313 activeMenu = 0;-
314 if (popup
popupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
315 fw = q->window()->focusWidget();-
316 q->setFocus(Qt::NoFocusReason);-
317 }
never executed: end of block
0
318 menu->hide();-
319 }
never executed: end of block
0
320-
321 if(currentAction
currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
322 q->update(actionRect(currentAction));
never executed: q->update(actionRect(currentAction));
0
323-
324 popupState = popup;-
325-
326 QAction *previousAction = currentAction;-
327-
328 currentAction = action;-
329 if (action
actionDescription
TRUEnever evaluated
FALSEnever evaluated
&& action->isEnabled()
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
330 activateAction(action, QAction::Hover);-
331 if(popup
popupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
332 popupAction(action, activateFirst);
never executed: popupAction(action, activateFirst);
0
333 q->update(actionRect(action));-
334-
335 }
never executed: end of block
else if (previousAction
previousActionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
336 QString empty;-
337 QStatusTipEvent tip(empty);-
338 QApplication::sendEvent(q, &tip);-
339-
340 }
never executed: end of block
0
341 if (fw
fwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
342 fw->setFocus(Qt::NoFocusReason);
never executed: fw->setFocus(Qt::NoFocusReason);
0
343}
never executed: end of block
0
344-
345void QMenuBarPrivate::calcActionRects(int max_width, int start) const-
346{-
347 const QMenuBar * const q = q_func();-
348-
349 if(!itemsDirty
!itemsDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
350 return;
never executed: return;
0
351-
352-
353 actionRects.resize(actions.count());-
354 actionRects.fill(QRect());-
355-
356 const QStyle *style = q->style();-
357-
358 const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);-
359 int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;-
360-
361-
362 const QFontMetrics fm = q->fontMetrics();-
363 const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),-
364 vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),-
365 icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);-
366 for(int i = 0; i < actions.count()
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
367 QAction *action = actions.at(i);-
368 if(!action->isVisible()
!action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
369 continue;
never executed: continue;
0
370-
371 QSize sz;-
372-
373-
374 if(action->isSeparator()
action->isSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
375 if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q)
style->styleHi...parator, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
376 separator = i;
never executed: separator = i;
0
377 continue;
never executed: continue;
0
378 } else {-
379 const QString s = action->text();-
380 QIcon is = action->icon();-
381-
382 if (!is.isNull()
!is.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
383 sz = sz.expandedTo(QSize(icone, icone));
never executed: sz = sz.expandedTo(QSize(icone, icone));
0
384 else if (!s.isEmpty()
!s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
385 sz = fm.size(Qt::TextShowMnemonic, s);
never executed: sz = fm.size(Qt::TextShowMnemonic, s);
0
386 }
never executed: end of block
0
387-
388-
389 QStyleOptionMenuItem opt;-
390 q->initStyleOption(&opt, action);-
391 sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);-
392-
393 if(!sz.isEmpty()
!sz.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
394 {-
395 int iWidth = sz.width() + itemSpacing;-
396 if(separator == -1
separator == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
397 separator_start += iWidth;
never executed: separator_start += iWidth;
0
398 else-
399 separator_len += iWidth;
never executed: separator_len += iWidth;
0
400 }-
401-
402 max_item_height = qMax(max_item_height, sz.height());-
403-
404 actionRects[i] = QRect(0, 0, sz.width(), sz.height());-
405 }
never executed: end of block
0
406 }
never executed: end of block
0
407-
408-
409 const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);-
410 int x = fw + ((
(start == -1)Description
TRUEnever evaluated
FALSEnever evaluated
start == -1)
(start == -1)Description
TRUEnever evaluated
FALSEnever evaluated
? hmargin : start) + itemSpacing;
0
411 int y = fw + vmargin;-
412 for(int i = 0; i < actions.count()
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
413 QRect &rect = actionRects[i];-
414 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
415 continue;
never executed: continue;
0
416-
417-
418 rect.setHeight(max_item_height);-
419-
420-
421 if(separator != -1
separator != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& i >= separator
i >= separatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
422 int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);-
423 if(left < separator_start
left < separator_startDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 separator_start = x = hmargin;-
425 y += max_item_height;-
426 }
never executed: end of block
0
427 rect.moveLeft(left);-
428 }
never executed: end of block
else {
0
429 rect.moveLeft(x);-
430 }
never executed: end of block
0
431 rect.moveTop(y);-
432-
433-
434 x += rect.width() + itemSpacing;-
435-
436-
437 rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);-
438 }
never executed: end of block
0
439}
never executed: end of block
0
440-
441void QMenuBarPrivate::activateAction(QAction *action, QAction::ActionEvent action_e)-
442{-
443 QMenuBar * const q = q_func();-
444 if (!action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !action->isEnabled()
!action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
445 return;
never executed: return;
0
446 action->activate(action_e);-
447 if (action_e == QAction::Hover
action_e == QAction::HoverDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
448 action->showStatusText(q);
never executed: action->showStatusText(q);
0
449-
450-
451-
452-
453-
454}
never executed: end of block
0
455-
456-
457void QMenuBarPrivate::_q_actionTriggered()-
458{-
459 QMenuBar * const q = q_func();-
460 if (QAction *action = qobject_cast<QAction *>(q->sender())
QAction *actio...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
461 q->triggered(action);-
462 }
never executed: end of block
0
463}
never executed: end of block
0
464-
465void QMenuBarPrivate::_q_actionHovered()-
466{-
467 QMenuBar * const q = q_func();-
468 if (QAction *action = qobject_cast<QAction *>(q->sender())
QAction *actio...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
469 q->hovered(action);-
470-
471 if (QAccessible::isActive()
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
472 int actionIndex = actions.indexOf(action);-
473 QAccessibleEvent focusEvent(q, QAccessible::Focus);-
474 focusEvent.setChild(actionIndex);-
475 QAccessible::updateAccessibility(&focusEvent);-
476 }
never executed: end of block
0
477-
478 }
never executed: end of block
0
479}
never executed: end of block
0
480void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const-
481{-
482 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
483 return;
never executed: return;
0
484 const QMenuBarPrivate * const d = d_func();-
485 option->palette = palette();-
486 option->state = QStyle::State_None;-
487 if (isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
&& action->isEnabled()
action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
488 option->state |= QStyle::State_Enabled;
never executed: option->state |= QStyle::State_Enabled;
0
489 else-
490 option->palette.setCurrentColorGroup(QPalette::Disabled);
never executed: option->palette.setCurrentColorGroup(QPalette::Disabled);
0
491 option->fontMetrics = fontMetrics();-
492 if (d->currentAction
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->currentAction == action
d->currentAction == actionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
493 option->state |= QStyle::State_Selected;-
494 if (d->popupState
d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->closePopupMode
!d->closePopupModeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
495 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
496 }
never executed: end of block
0
497 if (hasFocus()
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->currentAction
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
498 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
499 option->menuRect = rect();-
500 option->menuItemType = QStyleOptionMenuItem::Normal;-
501 option->checkType = QStyleOptionMenuItem::NotCheckable;-
502 option->text = action->text();-
503 option->icon = action->icon();-
504}
never executed: end of block
0
505void QMenuBarPrivate::init()-
506{-
507 QMenuBar * const q = q_func();-
508 q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);-
509 q->setAttribute(Qt::WA_CustomWhatsThis);-
510-
511 if (!QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar)
!QApplication:...NativeMenuBar)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
512 platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
never executed: platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
0
513-
514 if (platformMenuBar
platformMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
515 q->hide();
never executed: q->hide();
0
516 q->setBackgroundRole(QPalette::Button);-
517 handleReparent();-
518 q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));-
519-
520 extension = new QMenuBarExtension(q);-
521 extension->setFocusPolicy(Qt::NoFocus);-
522 extension->hide();-
523}
never executed: end of block
0
524-
525-
526QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) const-
527{-
528 const QMenuBar * const q = q_func();-
529 const_cast<QMenuBarPrivate*>(this)->updateGeometries();-
530 bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q);-
531 const int start = (_start == -1
_start == -1Description
TRUEnever evaluated
FALSEnever evaluated
&& increment == -1
increment == -1Description
TRUEnever evaluated
FALSEnever evaluated
) ? actions.count() : _start;
0
532 const int end = increment == -1
increment == -1Description
TRUEnever evaluated
FALSEnever evaluated
? 0 : actions.count() - 1;
0
533-
534 for (int i = start; i != end
i != endDescription
TRUEnever evaluated
FALSEnever evaluated
;) {
0
535 i += increment;-
536 QAction *current = actions.at(i);-
537 if (!actionRects.at(i).isNull()
!actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& (allowActiveAndDisabled
allowActiveAndDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| current->isEnabled()
current->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
538 return
never executed: return current;
current;
never executed: return current;
0
539 }
never executed: end of block
0
540-
541 if (_start != -1
_start != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
542 return
never executed: return getNextAction(-1, increment);
getNextAction(-1, increment);
never executed: return getNextAction(-1, increment);
0
543-
544 return
never executed: return 0;
0;
never executed: return 0;
0
545}-
546-
547-
548-
549-
550QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0)-
551{-
552 QMenuBarPrivate * const d = d_func();-
553 d->init();-
554}
never executed: end of block
0
555-
556-
557-
558-
559-
560QMenuBar::~QMenuBar()-
561{-
562 QMenuBarPrivate * const d = d_func();-
563 delete d->platformMenuBar;-
564 d->platformMenuBar = 0;-
565-
566-
567-
568-
569-
570}
never executed: end of block
0
571QAction *QMenuBar::addAction(const QString &text)-
572{-
573 QAction *ret = new QAction(text, this);-
574 addAction(ret);-
575 return
never executed: return ret;
ret;
never executed: return ret;
0
576}-
577QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member)-
578{-
579 QAction *ret = new QAction(text, this);-
580 QObject::connect(ret, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "793"), receiver, member);-
581 addAction(ret);-
582 return
never executed: return ret;
ret;
never executed: return ret;
0
583}-
584-
585-
586-
587-
588-
589-
590-
591QMenu *QMenuBar::addMenu(const QString &title)-
592{-
593 QMenu *menu = new QMenu(title, this);-
594 addAction(menu->menuAction());-
595 return
never executed: return menu;
menu;
never executed: return menu;
0
596}-
597-
598-
599-
600-
601-
602-
603-
604QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title)-
605{-
606 QMenu *menu = new QMenu(title, this);-
607 menu->setIcon(icon);-
608 addAction(menu->menuAction());-
609 return
never executed: return menu;
menu;
never executed: return menu;
0
610}-
611QAction *QMenuBar::addMenu(QMenu *menu)-
612{-
613 QAction *action = menu->menuAction();-
614 addAction(action);-
615 return
never executed: return action;
action;
never executed: return action;
0
616}-
617-
618-
619-
620-
621QAction *QMenuBar::addSeparator()-
622{-
623 QAction *ret = new QAction(this);-
624 ret->setSeparator(true);-
625 addAction(ret);-
626 return
never executed: return ret;
ret;
never executed: return ret;
0
627}-
628QAction *QMenuBar::insertSeparator(QAction *before)-
629{-
630 QAction *action = new QAction(this);-
631 action->setSeparator(true);-
632 insertAction(before, action);-
633 return
never executed: return action;
action;
never executed: return action;
0
634}-
635-
636-
637-
638-
639-
640-
641-
642QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu)-
643{-
644 QAction *action = menu->menuAction();-
645 insertAction(before, action);-
646 return
never executed: return action;
action;
never executed: return action;
0
647}-
648-
649-
650-
651-
652-
653QAction *QMenuBar::activeAction() const-
654{-
655 const QMenuBarPrivate * const d = d_func();-
656 return
never executed: return d->currentAction;
d->currentAction;
never executed: return d->currentAction;
0
657}-
658-
659-
660-
661-
662-
663-
664void QMenuBar::setActiveAction(QAction *act)-
665{-
666 QMenuBarPrivate * const d = d_func();-
667 d->setCurrentAction(act, true, false);-
668}
never executed: end of block
0
669void QMenuBar::clear()-
670{-
671 QList<QAction*> acts = actions();-
672 for(int i = 0; i < acts.size()
i < acts.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
673 removeAction(acts[i]);
never executed: removeAction(acts[i]);
0
674}
never executed: end of block
0
675void QMenuBar::setDefaultUp(bool b)-
676{-
677 QMenuBarPrivate * const d = d_func();-
678 d->defaultPopDown = !b;-
679}
never executed: end of block
0
680-
681bool QMenuBar::isDefaultUp() const-
682{-
683 const QMenuBarPrivate * const d = d_func();-
684 return
never executed: return !d->defaultPopDown;
!d->defaultPopDown;
never executed: return !d->defaultPopDown;
0
685}-
686-
687-
688-
689-
690void QMenuBar::resizeEvent(QResizeEvent *)-
691{-
692 QMenuBarPrivate * const d = d_func();-
693 d->itemsDirty = true;-
694 d->updateGeometries();-
695}
never executed: end of block
0
696-
697-
698-
699-
700void QMenuBar::paintEvent(QPaintEvent *e)-
701{-
702 QMenuBarPrivate * const d = d_func();-
703 QPainter p(this);-
704 QRegion emptyArea(rect());-
705-
706-
707 for (int i = 0; i < d->actions.count()
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
708 QAction *action = d->actions.at(i);-
709 QRect adjustedActionRect = d->actionRect(action);-
710 if (adjustedActionRect.isEmpty()
adjustedActionRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| !d->isVisible(action)
!d->isVisible(action)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
711 continue;
never executed: continue;
0
712 if(!e->rect().intersects(adjustedActionRect)
!e->rect().int...tedActionRect)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
713 continue;
never executed: continue;
0
714-
715 emptyArea -= adjustedActionRect;-
716 QStyleOptionMenuItem opt;-
717 initStyleOption(&opt, action);-
718 opt.rect = adjustedActionRect;-
719 p.setClipRect(adjustedActionRect);-
720 style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this);-
721 }
never executed: end of block
0
722-
723 if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)
int fw = style...idth, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
724 QRegion borderReg;-
725 borderReg += QRect(0, 0, fw, height());-
726 borderReg += QRect(width()-fw, 0, fw, height());-
727 borderReg += QRect(0, 0, width(), fw);-
728 borderReg += QRect(0, height()-fw, width(), fw);-
729 p.setClipRegion(borderReg);-
730 emptyArea -= borderReg;-
731 QStyleOptionFrame frame;-
732 frame.rect = rect();-
733 frame.palette = palette();-
734 frame.state = QStyle::State_None;-
735 frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth);-
736 frame.midLineWidth = 0;-
737 style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);-
738 }
never executed: end of block
0
739 p.setClipRegion(emptyArea);-
740 QStyleOptionMenuItem menuOpt;-
741 menuOpt.palette = palette();-
742 menuOpt.state = QStyle::State_None;-
743 menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea;-
744 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;-
745 menuOpt.rect = rect();-
746 menuOpt.menuRect = rect();-
747 style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this);-
748}
never executed: end of block
0
749-
750-
751-
752-
753void QMenuBar::setVisible(bool visible)-
754{-
755 if (isNativeMenuBar()
isNativeMenuBar()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
756 if (!visible
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
757 QWidget::setVisible(false);
never executed: QWidget::setVisible(false);
0
758 return;
never executed: return;
0
759 }-
760 QWidget::setVisible(visible);-
761}
never executed: end of block
0
762-
763-
764-
765-
766void QMenuBar::mousePressEvent(QMouseEvent *e)-
767{-
768 QMenuBarPrivate * const d = d_func();-
769 if(e->button() != Qt::LeftButton
e->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
770 return;
never executed: return;
0
771-
772 d->mouseDown = true;-
773-
774 QAction *action = d->actionAt(e->pos());-
775 if (!action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->isVisible(action)
!d->isVisible(action)Description
TRUEnever evaluated
FALSEnever evaluated
|| !action->isEnabled()
!action->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
776 d->setCurrentAction(0);-
777-
778 if (QWhatsThis::inWhatsThisMode()
QWhatsThis::inWhatsThisMode()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
779 QWhatsThis::showText(e->globalPos(), d->whatsThis, this);
never executed: QWhatsThis::showText(e->globalPos(), d->whatsThis, this);
0
780-
781 return;
never executed: return;
0
782 }-
783-
784 if(d->currentAction == action
d->currentAction == actionDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->popupState
d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
785 if(QMenu *menu = d->activeMenu
QMenu *menu = d->activeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
786 d->activeMenu = 0;-
787 menu->setAttribute(Qt::WA_NoMouseReplay);-
788 menu->hide();-
789 }
never executed: end of block
0
790 }
never executed: end of block
else {
0
791 d->setCurrentAction(action, true);-
792 }
never executed: end of block
0
793}-
794-
795-
796-
797-
798void QMenuBar::mouseReleaseEvent(QMouseEvent *e)-
799{-
800 QMenuBarPrivate * const d = d_func();-
801 if(e->button() != Qt::LeftButton
e->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->mouseDown
!d->mouseDownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
802 return;
never executed: return;
0
803-
804 d->mouseDown = false;-
805 QAction *action = d->actionAt(e->pos());-
806 if((d->closePopupMode
d->closePopupModeDescription
TRUEnever evaluated
FALSEnever evaluated
&& action == d->currentAction
action == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
) || !action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !action->menu()
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
807-
808-
809 d->setCurrentAction(action, false);-
810 if(action
actionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
811 d->activateAction(action, QAction::Trigger);
never executed: d->activateAction(action, QAction::Trigger);
0
812 }
never executed: end of block
0
813 d->closePopupMode = 0;-
814}
never executed: end of block
0
815-
816-
817-
818-
819void QMenuBar::keyPressEvent(QKeyEvent *e)-
820{-
821 QMenuBarPrivate * const d = d_func();-
822 d->updateGeometries();-
823 int key = e->key();-
824 if(isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
825 if(key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
826 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
827 else if(key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
828 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
829 }
never executed: end of block
0
830 if(key == Qt::Key_Tab
key == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
831 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
832 else if(key == Qt::Key_Backtab
key == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
833 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
834-
835 bool key_consumed = false;-
836 switch(key) {-
837 case
never executed: case Qt::Key_Up:
Qt::Key_Up:
never executed: case Qt::Key_Up:
0
838 case
never executed: case Qt::Key_Down:
Qt::Key_Down:
never executed: case Qt::Key_Down:
0
839 case
never executed: case Qt::Key_Enter:
Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
840 case
never executed: case Qt::Key_Space:
Qt::Key_Space:
never executed: case Qt::Key_Space:
0
841 case
never executed: case Qt::Key_Return:
Qt::Key_Return:
never executed: case Qt::Key_Return:
{
0
842 if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
!style()->styl...tion, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
|| !d->currentAction
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
843 break;
never executed: break;
0
844 if(d->currentAction->menu()
d->currentAction->menu()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
845 d->popupAction(d->currentAction, true);-
846 }
never executed: end of block
else if(key == Qt::Key_Enter
key == Qt::Key_EnterDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Return
key == Qt::Key_ReturnDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Space
key == Qt::Key_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
847 d->activateAction(d->currentAction, QAction::Trigger);-
848 d->setCurrentAction(d->currentAction, false);-
849 d->setKeyboardMode(false);-
850 }
never executed: end of block
0
851 key_consumed = true;-
852 break;
never executed: break;
}
0
853-
854 case
never executed: case Qt::Key_Right:
Qt::Key_Right:
never executed: case Qt::Key_Right:
0
855 case
never executed: case Qt::Key_Left:
Qt::Key_Left:
never executed: case Qt::Key_Left:
{
0
856 if(d->currentAction
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
857 int index = d->actions.indexOf(d->currentAction);-
858 if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)
QAction *nextA...eft ? -1 : +1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
859 d->setCurrentAction(nextAction, d->popupState, true);-
860 key_consumed = true;-
861 }
never executed: end of block
0
862 }
never executed: end of block
0
863 break;
never executed: break;
}
0
864-
865 default
never executed: default:
:
never executed: default:
0
866 key_consumed = false;-
867 }
never executed: end of block
0
868-
869 if (!key_consumed
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
&& e->matches(QKeySequence::Cancel)
e->matches(QKe...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
870 d->setCurrentAction(0);-
871 d->setKeyboardMode(false);-
872 key_consumed = true;-
873 }
never executed: end of block
0
874-
875 if(!key_consumed
!key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
876 (!e->modifiers()
!e->modifiers()Description
TRUEnever evaluated
FALSEnever evaluated
||
0
877 (
(e->modifiers(...:AltModifier))Description
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))
(e->modifiers(...:AltModifier))Description
TRUEnever evaluated
FALSEnever evaluated
) && e->text().length()==1
e->text().length()==1Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->popupState
!d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
878 int clashCount = 0;-
879 QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;-
880 {-
881 QChar c = e->text()[0].toUpper();-
882 for(int i = 0; i < d->actions.size()
i < d->actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
883 if (d->actionRects.at(i).isNull()
d->actionRects.at(i).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
884 continue;
never executed: continue;
0
885 QAction *act = d->actions.at(i);-
886 QString s = act->text();-
887 if(!s.isEmpty()
!s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
888 int ampersand = s.indexOf(QLatin1Char('&'));-
889 if(ampersand >= 0
ampersand >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
890 if(s[ampersand+1].toUpper() == c
s[ampersand+1].toUpper() == cDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
891 clashCount++;-
892 if(!first
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
893 first = act;
never executed: first = act;
0
894 if(act == d->currentAction
act == d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
895 currentSelected = act;
never executed: currentSelected = act;
0
896 else if (!firstAfterCurrent
!firstAfterCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
&& currentSelected
currentSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
897 firstAfterCurrent = act;
never executed: firstAfterCurrent = act;
0
898 }
never executed: end of block
0
899 }
never executed: end of block
0
900 }
never executed: end of block
0
901 }
never executed: end of block
0
902 }-
903 QAction *next_action = 0;-
904 if(clashCount >= 1
clashCount >= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
905 if(clashCount == 1
clashCount == 1Description
TRUEnever evaluated
FALSEnever evaluated
|| !d->currentAction
!d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
|| (currentSelected
currentSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !firstAfterCurrent
!firstAfterCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
906 next_action = first;
never executed: next_action = first;
0
907 else-
908 next_action = firstAfterCurrent;
never executed: next_action = firstAfterCurrent;
0
909 }-
910 if(next_action
next_actionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
911 key_consumed = true;-
912 d->setCurrentAction(next_action, true, true);-
913 }
never executed: end of block
0
914 }
never executed: end of block
0
915 if(key_consumed
key_consumedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
916 e->accept();
never executed: e->accept();
0
917 else-
918 e->ignore();
never executed: e->ignore();
0
919}-
920-
921-
922-
923-
924void QMenuBar::mouseMoveEvent(QMouseEvent *e)-
925{-
926 QMenuBarPrivate * const d = d_func();-
927 if (!(e->buttons() & Qt::LeftButton)
!(e->buttons()...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
928 d->mouseDown = false;
never executed: d->mouseDown = false;
0
929 bool popupState = d->popupState
d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->mouseDown
d->mouseDownDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
930 QAction *action = d->actionAt(e->pos());-
931 if ((action
actionDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->isVisible(action)
d->isVisible(action)Description
TRUEnever evaluated
FALSEnever evaluated
) || !popupState
!popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
932 d->setCurrentAction(action, popupState);
never executed: d->setCurrentAction(action, popupState);
0
933}
never executed: end of block
0
934-
935-
936-
937-
938void QMenuBar::leaveEvent(QEvent *)-
939{-
940 QMenuBarPrivate * const d = d_func();-
941 if((!hasFocus()
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->popupState
!d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
) ||
0
942 (d->currentAction
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->currentAction->menu() == 0
d->currentAction->menu() == 0Description
TRUEnever evaluated
FALSEnever evaluated
))
0
943 d->setCurrentAction(0);
never executed: d->setCurrentAction(0);
0
944}
never executed: end of block
0
945-
946QPlatformMenu *getPlatformMenu(QAction *action)-
947{-
948 if (!action
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
|| !action->menu()
!action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
949 return
never executed: return 0;
0;
never executed: return 0;
0
950-
951 return
never executed: return action->menu()->platformMenu();
action->menu()->platformMenu();
never executed: return action->menu()->platformMenu();
0
952}-
953-
954-
955-
956-
957void QMenuBar::actionEvent(QActionEvent *e)-
958{-
959 QMenuBarPrivate * const d = d_func();-
960 d->itemsDirty = true;-
961-
962 if (d->platformMenuBar
d->platformMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
963-
964 QPlatformMenuBar *nativeMenuBar = d->platformMenuBar;-
965-
966-
967-
968 if (!nativeMenuBar
!nativeMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
969 return;
never executed: return;
0
970-
971 if (e->type() == QEvent::ActionAdded
e->type() == Q...t::ActionAddedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
972 QPlatformMenu *menu = getPlatformMenu(e->action());-
973 if (menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
974 QPlatformMenu* beforeMenu = __null;-
975 for (int beforeIndex = d->indexOf(e->action()) + 1;-
976 !beforeMenu
!beforeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(beforeIndex <...ions().size())Description
TRUEnever evaluated
FALSEnever evaluated
beforeIndex < actions().size())
(beforeIndex <...ions().size())Description
TRUEnever evaluated
FALSEnever evaluated
;
0
977 ++beforeIndex)-
978 {-
979 beforeMenu = getPlatformMenu(actions().at(beforeIndex));-
980 }
never executed: end of block
0
981-
982 menu->setTag(reinterpret_cast<quintptr>(e->action()));-
983 menu->setText(e->action()->text());-
984 d->platformMenuBar->insertMenu(menu, beforeMenu);-
985 }
never executed: end of block
0
986 }
never executed: end of block
else if (e->type() == QEvent::ActionRemoved
e->type() == Q...:ActionRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
987 QPlatformMenu *menu = getPlatformMenu(e->action());-
988 if (menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
989 d->platformMenuBar->removeMenu(menu);
never executed: d->platformMenuBar->removeMenu(menu);
0
990 }
never executed: end of block
else if (e->type() == QEvent::ActionChanged
e->type() == Q...:ActionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
991 QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));-
992 QPlatformMenu *menu = getPlatformMenu(e->action());-
993-
994-
995-
996 if (menu != cur
menu != curDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
997 if (cur
curDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
998 d->platformMenuBar->removeMenu(cur);
never executed: d->platformMenuBar->removeMenu(cur);
0
999 if (menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1000 menu->setTag(reinterpret_cast<quintptr>(e->action()));-
1001-
1002 QPlatformMenu* beforeMenu = __null;-
1003 for (int beforeIndex = d->indexOf(e->action()) + 1;-
1004 !beforeMenu
!beforeMenuDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(beforeIndex <...ions().size())Description
TRUEnever evaluated
FALSEnever evaluated
beforeIndex < actions().size())
(beforeIndex <...ions().size())Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1005 ++beforeIndex)-
1006 {-
1007 beforeMenu = getPlatformMenu(actions().at(beforeIndex));-
1008 }
never executed: end of block
0
1009 d->platformMenuBar->insertMenu(menu, beforeMenu);-
1010 }
never executed: end of block
0
1011 }
never executed: end of block
else if (menu
menuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1012 menu->setText(e->action()->text());-
1013 menu->setVisible(e->action()->isVisible());-
1014 menu->setEnabled(e->action()->isEnabled());-
1015 d->platformMenuBar->syncMenu(menu);-
1016 }
never executed: end of block
0
1017 }
never executed: end of block
0
1018 }
never executed: end of block
0
1019-
1020 if(e->type() == QEvent::ActionAdded
e->type() == Q...t::ActionAddedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1021 connect(e->action(), qFlagLocation("2""triggered()" "\0" __FILE__ ":" "1279"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "1279"));-
1022 connect(e->action(), qFlagLocation("2""hovered()" "\0" __FILE__ ":" "1280"), this, qFlagLocation("1""_q_actionHovered()" "\0" __FILE__ ":" "1280"));-
1023 }
never executed: end of block
else if(e->type() == QEvent::ActionRemoved
e->type() == Q...:ActionRemovedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1024 e->action()->disconnect(this);-
1025 }
never executed: end of block
0
1026 if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1027 d->updateGeometries();-
1028 update();-
1029 }
never executed: end of block
0
1030}
never executed: end of block
0
1031-
1032-
1033-
1034-
1035void QMenuBar::focusInEvent(QFocusEvent *)-
1036{-
1037 QMenuBarPrivate * const d = d_func();-
1038 if(d->keyboardState
d->keyboardStateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1039 d->focusFirstAction();
never executed: d->focusFirstAction();
0
1040}
never executed: end of block
0
1041-
1042-
1043-
1044-
1045void QMenuBar::focusOutEvent(QFocusEvent *)-
1046{-
1047 QMenuBarPrivate * const d = d_func();-
1048 if(!d->popupState
!d->popupStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1049 d->setCurrentAction(0);-
1050 d->setKeyboardMode(false);-
1051 }
never executed: end of block
0
1052}
never executed: end of block
0
1053-
1054-
1055-
1056-
1057void QMenuBar::timerEvent (QTimerEvent *e)-
1058{-
1059 QMenuBarPrivate * const d = d_func();-
1060 if (e->timerId() == d->autoReleaseTimer.timerId()
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1061 d->autoReleaseTimer.stop();-
1062 d->setCurrentAction(0);-
1063 }
never executed: end of block
0
1064 QWidget::timerEvent(e);-
1065}
never executed: end of block
0
1066-
1067-
1068void QMenuBarPrivate::handleReparent()-
1069{-
1070 QMenuBar * const q = q_func();-
1071 QWidget *newParent = q->parentWidget();-
1072-
1073-
1074-
1075-
1076 QWidget *newWindow = newParent
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
? newParent->window() : nullptr;
0
1077-
1078 QVector<QPointer<QWidget> > newParents;-
1079-
1080-
1081 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(oldParents)>::type> _container_((oldParents)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QPointer<QWidget> &w = *_container_.i; _container_.control; _container_.control = 0) {-
1082 if (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1083 if (newParent == w
newParent == wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1084 newParents.append(w);-
1085 if (newParent != newWindow
newParent != newWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1086 newParent = newParent->parentWidget();
never executed: newParent = newParent->parentWidget();
0
1087 }
never executed: end of block
else {
0
1088 w->removeEventFilter(q);-
1089 }
never executed: end of block
0
1090 }-
1091 }
never executed: end of block
0
1092-
1093-
1094 while (newParent
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
&& newParent != newWindow
newParent != newWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1095-
1096 newParents.append(newParent);-
1097 newParent->installEventFilter(q);-
1098 newParent = newParent->parentWidget();-
1099 }
never executed: end of block
0
1100-
1101 if (newParent
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
&& newWindow
newWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1102-
1103 newParents.append(newParent);-
1104 newParent->installEventFilter(q);-
1105 }
never executed: end of block
0
1106 oldParents = newParents;-
1107-
1108 if (platformMenuBar
platformMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1109 if (newWindow
newWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1110-
1111-
1112-
1113 newWindow->createWinId();-
1114 platformMenuBar->handleReparent(newWindow->windowHandle());-
1115 }
never executed: end of block
else {
0
1116 platformMenuBar->handleReparent(0);-
1117 }
never executed: end of block
0
1118 }-
1119-
1120-
1121-
1122-
1123-
1124}
never executed: end of block
0
1125-
1126-
1127-
1128-
1129void QMenuBar::changeEvent(QEvent *e)-
1130{-
1131 QMenuBarPrivate * const d = d_func();-
1132 if(e->type() == QEvent::StyleChange
e->type() == Q...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1133 d->itemsDirty = true;-
1134 setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this));-
1135 if(parentWidget()
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1136 resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
never executed: resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
0
1137 d->updateGeometries();-
1138 }
never executed: end of block
else if (e->type() == QEvent::ParentChange
e->type() == Q...::ParentChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1139 d->handleReparent();-
1140 }
never executed: end of block
else if (e->type() == QEvent::FontChange
e->type() == Q...nt::FontChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1141 || e->type() == QEvent::ApplicationFontChange
e->type() == Q...tionFontChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1142 d->itemsDirty = true;-
1143 d->updateGeometries();-
1144 }
never executed: end of block
0
1145-
1146 QWidget::changeEvent(e);-
1147}
never executed: end of block
0
1148-
1149-
1150-
1151-
1152bool QMenuBar::event(QEvent *e)-
1153{-
1154 QMenuBarPrivate * const d = d_func();-
1155 switch (e->type()) {-
1156 case
never executed: case QEvent::KeyPress:
QEvent::KeyPress:
never executed: case QEvent::KeyPress:
{
0
1157 QKeyEvent *ke = (QKeyEvent*)e;-
1158-
1159-
1160-
1161-
1162-
1163-
1164 if(ke->key() == Qt::Key_Tab
ke->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
|| ke->key() == Qt::Key_Backtab
ke->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1165 keyPressEvent(ke);-
1166 return
never executed: return true;
true;
never executed: return true;
0
1167 }-
1168-
1169 } break;
never executed: break;
0
1170-
1171 case
never executed: case QEvent::Shortcut:
QEvent::Shortcut:
never executed: case QEvent::Shortcut:
{
0
1172 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);-
1173 int shortcutId = se->shortcutId();-
1174 for(int j = 0; j < d->shortcutIndexMap.size()
j < d->shortcutIndexMap.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1175 if (shortcutId == d->shortcutIndexMap.value(j)
shortcutId == ...exMap.value(j)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1176 d->_q_internalShortcutActivated(j);
never executed: d->_q_internalShortcutActivated(j);
0
1177 }
never executed: end of block
0
1178 } break;
never executed: break;
0
1179-
1180 case
never executed: case QEvent::Show:
QEvent::Show:
never executed: case QEvent::Show:
0
1181 d->_q_updateLayout();-
1182 break;
never executed: break;
0
1183 case
never executed: case QEvent::ShortcutOverride:
QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
{
0
1184 QKeyEvent *kev = static_cast<QKeyEvent*>(e);-
1185-
1186 if (kev->matches(QKeySequence::Cancel)
kev->matches(Q...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
&& d->currentAction
d->currentActionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1187 e->accept();-
1188 return
never executed: return true;
true;
never executed: return true;
0
1189 }-
1190 }-
1191 break;
never executed: break;
0
1192-
1193-
1194-
1195 case
never executed: case QEvent::QueryWhatsThis:
QEvent::QueryWhatsThis:
never executed: case QEvent::QueryWhatsThis:
0
1196 e->setAccepted(d->whatsThis.size());-
1197 if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())
QAction *actio...t*>(e)->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1198 if (action->whatsThis().size()
action->whatsThis().size()Description
TRUEnever evaluated
FALSEnever evaluated
|| action->menu()
action->menu()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1199 e->accept();
never executed: e->accept();
0
1200 }
never executed: end of block
0
1201 return
never executed: return true;
true;
never executed: return true;
0
1202-
1203 case
never executed: case QEvent::LayoutDirectionChange:
QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
1204 d->_q_updateLayout();-
1205 break;
never executed: break;
0
1206 default
never executed: default:
:
never executed: default:
0
1207 break;
never executed: break;
0
1208 }-
1209 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
1210}-
1211-
1212-
1213-
1214-
1215bool QMenuBar::eventFilter(QObject *object, QEvent *event)-
1216{-
1217 QMenuBarPrivate * const d = d_func();-
1218 if (object
objectDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(event->type()...:ParentChange)Description
TRUEnever evaluated
FALSEnever evaluated
event->type() == QEvent::ParentChange)
(event->type()...:ParentChange)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1219 d->handleReparent();
never executed: d->handleReparent();
0
1220-
1221 if (object == d->leftWidget
object == d->leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
|| object == d->rightWidget
object == d->rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1222 switch (event->type()) {-
1223 case
never executed: case QEvent::ShowToParent:
QEvent::ShowToParent:
never executed: case QEvent::ShowToParent:
0
1224 case
never executed: case QEvent::HideToParent:
QEvent::HideToParent:
never executed: case QEvent::HideToParent:
0
1225 d->_q_updateLayout();-
1226 break;
never executed: break;
0
1227 default
never executed: default:
:
never executed: default:
0
1228 break;
never executed: break;
0
1229 }-
1230 }-
1231-
1232 if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
style()->style...tion, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1233 if (d->altPressed
d->altPressedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1234 switch (event->type()) {-
1235 case
never executed: case QEvent::KeyPress:
QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
1236 case
never executed: case QEvent::KeyRelease:
QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
1237 {-
1238 QKeyEvent *kev = static_cast<QKeyEvent*>(event);-
1239 if (kev->key() == Qt::Key_Alt
kev->key() == Qt::Key_AltDescription
TRUEnever evaluated
FALSEnever evaluated
|| kev->key() == Qt::Key_Meta
kev->key() == Qt::Key_MetaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1240 if (event->type() == QEvent::KeyPress
event->type() ...vent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1241 break;
never executed: break;
0
1242 d->setKeyboardMode(!d->keyboardState);-
1243 }
never executed: end of block
0
1244 }-
1245-
1246 case
never executed: case QEvent::MouseButtonPress:
QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
code before this statement never executed: case QEvent::MouseButtonPress:
0
1247 case
never executed: case QEvent::MouseButtonRelease:
QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
1248 case
never executed: case QEvent::MouseMove:
QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
1249 case
never executed: case QEvent::FocusIn:
QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
1250 case
never executed: case QEvent::FocusOut:
QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
1251 case
never executed: case QEvent::ActivationChange:
QEvent::ActivationChange:
never executed: case QEvent::ActivationChange:
0
1252 d->altPressed = false;-
1253 (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this);-
1254 break;
never executed: break;
0
1255 default
never executed: default:
:
never executed: default:
0
1256 break;
never executed: break;
0
1257 }-
1258 } else if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1259 if (event->type() == QEvent::ShortcutOverride
event->type() ...ortcutOverrideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1260 QKeyEvent *kev = static_cast<QKeyEvent*>(event);-
1261 if ((kev->key() == Qt::Key_Alt
kev->key() == Qt::Key_AltDescription
TRUEnever evaluated
FALSEnever evaluated
|| kev->key() == Qt::Key_Meta
kev->key() == Qt::Key_MetaDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1262 && kev->modifiers() == Qt::AltModifier
kev->modifiers...t::AltModifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1263 d->altPressed = true;-
1264 (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this);-
1265 }
never executed: end of block
0
1266 }
never executed: end of block
0
1267 }
never executed: end of block
0
1268 }
never executed: end of block
0
1269-
1270 return
never executed: return false;
false;
never executed: return false;
0
1271}-
1272-
1273-
1274-
1275-
1276-
1277-
1278-
1279QAction *QMenuBar::actionAt(const QPoint &pt) const-
1280{-
1281 const QMenuBarPrivate * const d = d_func();-
1282 return
never executed: return d->actionAt(pt);
d->actionAt(pt);
never executed: return d->actionAt(pt);
0
1283}-
1284-
1285-
1286-
1287-
1288-
1289-
1290QRect QMenuBar::actionGeometry(QAction *act) const-
1291{-
1292 const QMenuBarPrivate * const d = d_func();-
1293 return
never executed: return d->actionRect(act);
d->actionRect(act);
never executed: return d->actionRect(act);
0
1294}-
1295-
1296-
1297-
1298-
1299QSize QMenuBar::minimumSizeHint() const-
1300{-
1301 const QMenuBarPrivate * const d = d_func();-
1302 const bool as_gui_menubar = !isNativeMenuBar();-
1303-
1304 ensurePolished();-
1305 QSize ret(0, 0);-
1306 const_cast<QMenuBarPrivate*>(d)->updateGeometries();-
1307 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);-
1308 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);-
1309 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);-
1310 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);-
1311 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1312 int w = parentWidget()
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
? parentWidget()->width() : QApplication::desktop()->width();
0
1313 d->calcActionRects(w - (2 * fw), 0);-
1314 for (int i = 0; ret.isNull()
ret.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& i < d->actions.count()
i < d->actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1315 ret = d->actionRects.at(i).size();
never executed: ret = d->actionRects.at(i).size();
0
1316 if (!d->extension->isHidden()
!d->extension->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1317 ret += QSize(d->extension->sizeHint().width(), 0);
never executed: ret += QSize(d->extension->sizeHint().width(), 0);
0
1318 ret += QSize(2*fw + hmargin, 2*fw + vmargin);-
1319 }
never executed: end of block
0
1320 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;-
1321 if(d->leftWidget
d->leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1322 QSize sz = d->leftWidget->minimumSizeHint();-
1323 ret.setWidth(ret.width() + sz.width());-
1324 if(sz.height() + margin > ret.height()
sz.height() + ...> ret.height()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1325 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1326 }
never executed: end of block
0
1327 if(d->rightWidget
d->rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1328 QSize sz = d->rightWidget->minimumSizeHint();-
1329 ret.setWidth(ret.width() + sz.width());-
1330 if(sz.height() + margin > ret.height()
sz.height() + ...> ret.height()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1331 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1332 }
never executed: end of block
0
1333 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1334 QStyleOptionMenuItem opt;-
1335 opt.rect = rect();-
1336 opt.menuRect = rect();-
1337 opt.state = QStyle::State_None;-
1338 opt.menuItemType = QStyleOptionMenuItem::Normal;-
1339 opt.checkType = QStyleOptionMenuItem::NotCheckable;-
1340 opt.palette = palette();-
1341 return
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
(style()->sizeFromContents(QStyle::CT_MenuBar, &opt,
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1342 ret.expandedTo(QApplication::globalStrut()),
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1343 this));
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1344 }-
1345 return
never executed: return ret;
ret;
never executed: return ret;
0
1346}-
1347-
1348-
1349-
1350-
1351QSize QMenuBar::sizeHint() const-
1352{-
1353 const QMenuBarPrivate * const d = d_func();-
1354 const bool as_gui_menubar = !isNativeMenuBar();-
1355-
1356 ensurePolished();-
1357 QSize ret(0, 0);-
1358 const_cast<QMenuBarPrivate*>(d)->updateGeometries();-
1359 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);-
1360 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);-
1361 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);-
1362 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);-
1363 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1364 const int w = parentWidget()
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
? parentWidget()->width() : QApplication::desktop()->width();
0
1365 d->calcActionRects(w - (2 * fw), 0);-
1366 for (int i = 0; i < d->actionRects.count()
i < d->actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1367 const QRect &actionRect = d->actionRects.at(i);-
1368 ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height()));-
1369 }
never executed: end of block
0
1370-
1371-
1372 ret += QSize(fw + hmargin, fw + vmargin);-
1373 }
never executed: end of block
0
1374 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;-
1375 if(d->leftWidget
d->leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1376 QSize sz = d->leftWidget->sizeHint();-
1377 sz.rheight() += margin;-
1378 ret = ret.expandedTo(sz);-
1379 }
never executed: end of block
0
1380 if(d->rightWidget
d->rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1381 QSize sz = d->rightWidget->sizeHint();-
1382 ret.setWidth(ret.width() + sz.width());-
1383 if(sz.height() + margin > ret.height()
sz.height() + ...> ret.height()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1384 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1385 }
never executed: end of block
0
1386 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1387 QStyleOptionMenuItem opt;-
1388 opt.rect = rect();-
1389 opt.menuRect = rect();-
1390 opt.state = QStyle::State_None;-
1391 opt.menuItemType = QStyleOptionMenuItem::Normal;-
1392 opt.checkType = QStyleOptionMenuItem::NotCheckable;-
1393 opt.palette = palette();-
1394 return
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
(style()->sizeFromContents(QStyle::CT_MenuBar, &opt,
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1395 ret.expandedTo(QApplication::globalStrut()),
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1396 this));
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1397 }-
1398 return
never executed: return ret;
ret;
never executed: return ret;
0
1399}-
1400-
1401-
1402-
1403-
1404int QMenuBar::heightForWidth(int) const-
1405{-
1406 const QMenuBarPrivate * const d = d_func();-
1407 const bool as_gui_menubar = !isNativeMenuBar();-
1408-
1409 const_cast<QMenuBarPrivate*>(d)->updateGeometries();-
1410 int height = 0;-
1411 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);-
1412 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);-
1413 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);-
1414 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1415 for (int i = 0; i < d->actionRects.count()
i < d->actionRects.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1416 height = qMax(height, d->actionRects.at(i).height());
never executed: height = qMax(height, d->actionRects.at(i).height());
0
1417 if (height
heightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1418 height += spaceBelowMenuBar;
never executed: height += spaceBelowMenuBar;
0
1419 height += 2*fw;-
1420 height += 2*vmargin;-
1421 }
never executed: end of block
0
1422 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;-
1423 if(d->leftWidget
d->leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1424 height = qMax(d->leftWidget->sizeHint().height() + margin, height);
never executed: height = qMax(d->leftWidget->sizeHint().height() + margin, height);
0
1425 if(d->rightWidget
d->rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1426 height = qMax(d->rightWidget->sizeHint().height() + margin, height);
never executed: height = qMax(d->rightWidget->sizeHint().height() + margin, height);
0
1427 if(as_gui_menubar
as_gui_menubarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1428 QStyleOptionMenuItem opt;-
1429 opt.init(this);-
1430 opt.menuRect = rect();-
1431 opt.state = QStyle::State_None;-
1432 opt.menuItemType = QStyleOptionMenuItem::Normal;-
1433 opt.checkType = QStyleOptionMenuItem::NotCheckable;-
1434 return
never executed: return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();
style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();
never executed: return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();
0
1435 }-
1436 return
never executed: return height;
height;
never executed: return height;
0
1437}-
1438-
1439-
1440-
1441-
1442void QMenuBarPrivate::_q_internalShortcutActivated(int id)-
1443{-
1444 QMenuBar * const q = q_func();-
1445 QAction *act = actions.at(id);-
1446 setCurrentAction(act, true, true);-
1447 if (act
actDescription
TRUEnever evaluated
FALSEnever evaluated
&& !act->menu()
!act->menu()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1448 activateAction(act, QAction::Trigger);-
1449-
1450 autoReleaseTimer.start(100, q);-
1451 }
never executed: end of block
else if (act
actDescription
TRUEnever evaluated
FALSEnever evaluated
&& q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)
q->style()->st...igation, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1452-
1453 setKeyboardMode(true);-
1454 }
never executed: end of block
0
1455}
never executed: end of block
0
1456-
1457void QMenuBarPrivate::_q_updateLayout()-
1458{-
1459 QMenuBar * const q = q_func();-
1460 itemsDirty = true;-
1461 if (q->isVisible()
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1462 updateGeometries();-
1463 q->update();-
1464 }
never executed: end of block
0
1465}
never executed: end of block
0
1466void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner)-
1467{-
1468 QMenuBarPrivate * const d = d_func();-
1469 switch (corner) {-
1470 case
never executed: case Qt::TopLeftCorner:
Qt::TopLeftCorner:
never executed: case Qt::TopLeftCorner:
0
1471 if (d->leftWidget
d->leftWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1472 d->leftWidget->removeEventFilter(this);
never executed: d->leftWidget->removeEventFilter(this);
0
1473 d->leftWidget = w;-
1474 break;
never executed: break;
0
1475 case
never executed: case Qt::TopRightCorner:
Qt::TopRightCorner:
never executed: case Qt::TopRightCorner:
0
1476 if (d->rightWidget
d->rightWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1477 d->rightWidget->removeEventFilter(this);
never executed: d->rightWidget->removeEventFilter(this);
0
1478 d->rightWidget = w;-
1479 break;
never executed: break;
0
1480 default
never executed: default:
:
never executed: default:
0
1481 QMessageLogger(__FILE__, 1753, __PRETTY_FUNCTION__).warning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported");-
1482 return;
never executed: return;
0
1483 }-
1484-
1485 if (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1486 w->setParent(this);-
1487 w->installEventFilter(this);-
1488 }
never executed: end of block
0
1489-
1490 d->_q_updateLayout();-
1491}
never executed: end of block
0
1492QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const-
1493{-
1494 const QMenuBarPrivate * const d = d_func();-
1495 QWidget *w = 0;-
1496 switch(corner) {-
1497 case
never executed: case Qt::TopLeftCorner:
Qt::TopLeftCorner:
never executed: case Qt::TopLeftCorner:
0
1498 w = d->leftWidget;-
1499 break;
never executed: break;
0
1500 case
never executed: case Qt::TopRightCorner:
Qt::TopRightCorner:
never executed: case Qt::TopRightCorner:
0
1501 w = d->rightWidget;-
1502 break;
never executed: break;
0
1503 default
never executed: default:
:
never executed: default:
0
1504 QMessageLogger(__FILE__, 1784, __PRETTY_FUNCTION__).warning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported");-
1505 break;
never executed: break;
0
1506 }-
1507-
1508 return
never executed: return w;
w;
never executed: return w;
0
1509}-
1510void QMenuBar::setNativeMenuBar(bool nativeMenuBar)-
1511{-
1512 QMenuBarPrivate * const d = d_func();-
1513 if (nativeMenuBar != bool(d->platformMenuBar)
nativeMenuBar ...atformMenuBar)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1514 if (!nativeMenuBar
!nativeMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1515 delete d->platformMenuBar;-
1516 d->platformMenuBar = 0;-
1517 }
never executed: end of block
else {
0
1518 if (!d->platformMenuBar
!d->platformMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1519 d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
never executed: d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
0
1520 }
never executed: end of block
0
1521-
1522 updateGeometry();-
1523 if (!nativeMenuBar
!nativeMenuBarDescription
TRUEnever evaluated
FALSEnever evaluated
&& parentWidget()
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1524 setVisible(true);
never executed: setVisible(true);
0
1525 }
never executed: end of block
0
1526}
never executed: end of block
0
1527-
1528bool QMenuBar::isNativeMenuBar() const-
1529{-
1530 const QMenuBarPrivate * const d = d_func();-
1531 return
never executed: return bool(d->platformMenuBar);
bool(d->platformMenuBar);
never executed: return bool(d->platformMenuBar);
0
1532}-
1533-
1534-
1535-
1536-
1537QPlatformMenuBar *QMenuBar::platformMenuBar()-
1538{-
1539 const QMenuBarPrivate * const d = d_func();-
1540 return
never executed: return d->platformMenuBar;
d->platformMenuBar;
never executed: return d->platformMenuBar;
0
1541}-
1542-
1543-
Switch to Source codePreprocessed file

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