qtoolbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbar.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qtoolbar.h"-
35-
36#ifndef QT_NO_TOOLBAR-
37-
38#include <qapplication.h>-
39#include <qcombobox.h>-
40#include <qevent.h>-
41#include <qlayout.h>-
42#include <qmainwindow.h>-
43#include <qmenu.h>-
44#include <qmenubar.h>-
45#include <qrubberband.h>-
46#include <qsignalmapper.h>-
47#include <qstylepainter.h>-
48#include <qtoolbutton.h>-
49#include <qwidgetaction.h>-
50#include <qtimer.h>-
51#include <private/qwidgetaction_p.h>-
52#include <private/qmainwindowlayout_p.h>-
53-
54#ifdef Q_OS_OSX-
55#include <qpa/qplatformnativeinterface.h>-
56#endif-
57-
58#include "qtoolbar_p.h"-
59#include "qtoolbarseparator_p.h"-
60#include "qtoolbarlayout_p.h"-
61-
62#include "qdebug.h"-
63-
64#define POPUP_TIMER_INTERVAL 500-
65-
66QT_BEGIN_NAMESPACE-
67-
68// qmainwindow.cpp-
69extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
70-
71/******************************************************************************-
72** QToolBarPrivate-
73*/-
74-
75void QToolBarPrivate::init()-
76{-
77 Q_Q(QToolBar);-
78 q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));-
79 q->setBackgroundRole(QPalette::Button);-
80 q->setAttribute(Qt::WA_Hover);-
81 q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);-
82 q->setProperty("_q_platform_MacUseNSWindow", QVariant(true));-
83-
84 QStyle *style = q->style();-
85 int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);-
86 iconSize = QSize(e, e);-
87-
88 layout = new QToolBarLayout(q);-
89 layout->updateMarginAndSpacing();-
90-
91 toggleViewAction = new QAction(q);-
92 toggleViewAction->setCheckable(true);-
93 q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q ));-
94 QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool)));-
95}
never executed: end of block
0
96-
97void QToolBarPrivate::_q_toggleView(bool b)-
98{-
99 Q_Q(QToolBar);-
100 if (b == q->isHidden()) {
b == q->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
0
101 if (b)
bDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 q->show();
never executed: q->show();
0
103 else-
104 q->close();
never executed: q->close();
0
105 }-
106}
never executed: end of block
0
107-
108void QToolBarPrivate::_q_updateIconSize(const QSize &sz)-
109{-
110 Q_Q(QToolBar);-
111 if (!explicitIconSize) {
!explicitIconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
112 // iconSize not explicitly set-
113 q->setIconSize(sz);-
114 explicitIconSize = false;-
115 }
never executed: end of block
0
116}
never executed: end of block
0
117-
118void QToolBarPrivate::_q_updateToolButtonStyle(Qt::ToolButtonStyle style)-
119{-
120 Q_Q(QToolBar);-
121 if (!explicitToolButtonStyle) {
!explicitToolButtonStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 q->setToolButtonStyle(style);-
123 explicitToolButtonStyle = false;-
124 }
never executed: end of block
0
125}
never executed: end of block
0
126-
127void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug)-
128{-
129 Q_Q(QToolBar);-
130 Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
floatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
131-
132 flags |= Qt::FramelessWindowHint;-
133-
134 if (unplug)
unplugDescription
TRUEnever evaluated
FALSEnever evaluated
0
135 flags |= Qt::X11BypassWindowManagerHint;
never executed: flags |= Qt::X11BypassWindowManagerHint;
0
136-
137 q->setWindowFlags(flags);-
138}
never executed: end of block
0
139-
140void QToolBarPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)-
141{-
142 Q_Q(QToolBar);-
143 bool visible = !q->isHidden();-
144 bool wasFloating = q->isFloating(); // ...is also currently using popup menus-
145-
146 q->hide();-
147-
148 updateWindowFlags(floating, unplug);-
149-
150 if (floating != wasFloating)
floating != wasFloatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 layout->checkUsePopupMenu();
never executed: layout->checkUsePopupMenu();
0
152-
153 if (!rect.isNull())
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
154 q->setGeometry(rect);
never executed: q->setGeometry(rect);
0
155-
156 if (visible)
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
157 q->show();
never executed: q->show();
0
158-
159 if (floating != wasFloating)
floating != wasFloatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
160 emit q->topLevelChanged(floating);
never executed: q->topLevelChanged(floating);
0
161}
never executed: end of block
0
162-
163void QToolBarPrivate::initDrag(const QPoint &pos)-
164{-
165 Q_Q(QToolBar);-
166-
167 if (state != 0)
state != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
168 return;
never executed: return;
0
169-
170 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
171 Q_ASSERT(win != 0);-
172 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
173 Q_ASSERT(layout != 0);-
174 if (layout->pluggingWidget != 0) // the main window is animating a docking operation
layout->pluggingWidget != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
175 return;
never executed: return;
0
176-
177 state = new DragState;-
178 state->pressPos = pos;-
179 state->dragging = false;-
180 state->moving = false;-
181 state->widgetItem = 0;-
182-
183 if (q->isRightToLeft())
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
184 state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y());
never executed: state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y());
0
185}
never executed: end of block
0
186-
187void QToolBarPrivate::startDrag(bool moving)-
188{-
189 Q_Q(QToolBar);-
190-
191 Q_ASSERT(state != 0);-
192-
193 if ((moving && state->moving) || state->dragging)
movingDescription
TRUEnever evaluated
FALSEnever evaluated
state->movingDescription
TRUEnever evaluated
FALSEnever evaluated
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
194 return;
never executed: return;
0
195-
196 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
197 Q_ASSERT(win != 0);-
198 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
199 Q_ASSERT(layout != 0);-
200-
201 if (!moving) {
!movingDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 state->widgetItem = layout->unplug(q);-
203 Q_ASSERT(state->widgetItem != 0);-
204 }
never executed: end of block
0
205 state->dragging = !moving;-
206 state->moving = moving;-
207}
never executed: end of block
0
208-
209void QToolBarPrivate::endDrag()-
210{-
211 Q_Q(QToolBar);-
212 Q_ASSERT(state != 0);-
213-
214 q->releaseMouse();-
215-
216 if (state->dragging) {
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
217 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));-
218 Q_ASSERT(layout != 0);-
219-
220 if (!layout->plug(state->widgetItem)) {
!layout->plug(...e->widgetItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
221 if (q->isFloatable()) {
q->isFloatable()Description
TRUEnever evaluated
FALSEnever evaluated
0
222 layout->restore();-
223 setWindowState(true); // gets rid of the X11BypassWindowManager window flag-
224 // and activates the resizer-
225 q->activateWindow();-
226 } else {
never executed: end of block
0
227 layout->revert(state->widgetItem);-
228 }
never executed: end of block
0
229 }-
230 }
never executed: end of block
0
231-
232 delete state;-
233 state = 0;-
234}
never executed: end of block
0
235-
236bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)-
237{-
238 Q_Q(QToolBar);-
239 QStyleOptionToolBar opt;-
240 q->initStyleOption(&opt);-
241 if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) {
q->style()->su...os()) == falseDescription
TRUEnever evaluated
FALSEnever evaluated
0
242#ifdef Q_OS_OSX-
243 // When using the unified toolbar on OS X, the user can click and-
244 // drag between toolbar contents to move the window. Make this work by-
245 // implementing the standard mouse-dragging code and then call-
246 // window->move() in mouseMoveEvent below.-
247 if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parent)) {-
248 if (mainWindow->toolBarArea(q) == Qt::TopToolBarArea-
249 && mainWindow->unifiedTitleAndToolBarOnMac()-
250 && q->childAt(event->pos()) == 0) {-
251 macWindowDragging = true;-
252 macWindowDragPressPosition = event->pos();-
253 return true;-
254 }-
255 }-
256#endif-
257 return false;
never executed: return false;
0
258 }-
259-
260 if (event->button() != Qt::LeftButton)
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
261 return true;
never executed: return true;
0
262-
263 if (!layout->movable())
!layout->movable()Description
TRUEnever evaluated
FALSEnever evaluated
0
264 return true;
never executed: return true;
0
265-
266 initDrag(event->pos());-
267 return true;
never executed: return true;
0
268}-
269-
270bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*)-
271{-
272 if (state != 0) {
state != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
273 endDrag();-
274 return true;
never executed: return true;
0
275 } else {-
276#ifdef Q_OS_OSX-
277 if (!macWindowDragging)-
278 return false;-
279 macWindowDragging = false;-
280 macWindowDragPressPosition = QPoint();-
281 return true;-
282#endif-
283 return false;
never executed: return false;
0
284 }-
285}-
286-
287bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)-
288{-
289 Q_Q(QToolBar);-
290-
291 if (!state) {
!stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
292#ifdef Q_OS_OSX-
293 if (!macWindowDragging)-
294 return false;-
295 QWidget *w = q->window();-
296 const QPoint delta = event->pos() - macWindowDragPressPosition;-
297 w->move(w->pos() + delta);-
298 return true;-
299#endif-
300 return false;
never executed: return false;
0
301 }-
302-
303 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
304 if (win == 0)
win == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
305 return true;
never executed: return true;
0
306-
307 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
308 Q_ASSERT(layout != 0);-
309-
310 if (layout->pluggingWidget == 0
layout->pluggingWidget == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
311 && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) {
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
0
312 const bool wasDragging = state->dragging;-
313 const bool moving = !q->isWindow() && (orientation == Qt::Vertical ?
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
!q->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
0
314 event->x() >= 0 && event->x() < q->width() :
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
event->x() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
event->x() < q->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
315 event->y() >= 0 && event->y() < q->height());
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
event->y() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
event->y() < q->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
316-
317 startDrag(moving);-
318 if (!moving && !wasDragging) {
!movingDescription
TRUEnever evaluated
FALSEnever evaluated
!wasDraggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
319#ifdef Q_DEAD_CODE_FROM_QT4_WIN-
320 grabMouseWhileInWindow();-
321#else-
322 q->grabMouse();-
323#endif-
324 }
never executed: end of block
0
325 }
never executed: end of block
0
326-
327 if (state->dragging) {
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
328 QPoint pos = event->globalPos();-
329 // if we are right-to-left, we move so as to keep the right edge the same distance-
330 // from the mouse-
331 if (q->isLeftToRight())
q->isLeftToRight()Description
TRUEnever evaluated
FALSEnever evaluated
0
332 pos -= state->pressPos;
never executed: pos -= state->pressPos;
0
333 else-
334 pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
never executed: pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
0
335-
336 q->move(pos);-
337 layout->hover(state->widgetItem, event->globalPos());-
338 } else if (state->moving) {
never executed: end of block
state->movingDescription
TRUEnever evaluated
FALSEnever evaluated
0
339-
340 const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL-
341 const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);-
342 int pos = 0;-
343-
344 QPoint delta = event->globalPos() - globalPressPos;-
345 if (orientation == Qt::Vertical) {
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
346 pos = q->y() + delta.y();-
347 } else {
never executed: end of block
0
348 if (q->isRightToLeft()) {
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
349 pos = win->width() - q->width() - q->x() - delta.x();-
350 } else {
never executed: end of block
0
351 pos = q->x() + delta.x();-
352 }
never executed: end of block
0
353 }-
354-
355 layout->moveToolBar(q, pos);-
356 }
never executed: end of block
0
357 return true;
never executed: return true;
0
358}-
359-
360void QToolBarPrivate::unplug(const QRect &_r)-
361{-
362 Q_Q(QToolBar);-
363 QRect r = _r;-
364 r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));-
365 setWindowState(true, true, r);-
366 layout->setExpanded(false);-
367}
never executed: end of block
0
368-
369void QToolBarPrivate::plug(const QRect &r)-
370{-
371 setWindowState(false, false, r);-
372}
never executed: end of block
0
373-
374/******************************************************************************-
375** QToolBar-
376*/-
377-
378/*!-
379 \class QToolBar-
380-
381 \brief The QToolBar class provides a movable panel that contains a-
382 set of controls.-
383-
384 \ingroup mainwindow-classes-
385 \inmodule QtWidgets-
386-
387 Toolbar buttons are added by adding \e actions, using addAction()-
388 or insertAction(). Groups of buttons can be separated using-
389 addSeparator() or insertSeparator(). If a toolbar button is not-
390 appropriate, a widget can be inserted instead using addWidget() or-
391 insertWidget(). Examples of suitable widgets are QSpinBox,-
392 QDoubleSpinBox, and QComboBox. When a toolbar button is pressed, it-
393 emits the actionTriggered() signal.-
394-
395 A toolbar can be fixed in place in a particular area (e.g., at the-
396 top of the window), or it can be movable between toolbar areas;-
397 see setMovable(), isMovable(), allowedAreas() and isAreaAllowed().-
398-
399 When a toolbar is resized in such a way that it is too small to-
400 show all the items it contains, an extension button will appear as-
401 the last item in the toolbar. Pressing the extension button will-
402 pop up a menu containing the items that do not currently fit in-
403 the toolbar.-
404-
405 When a QToolBar is not a child of a QMainWindow, it loses the ability-
406 to populate the extension pop up with widgets added to the toolbar using-
407 addWidget(). Please use widget actions created by inheriting QWidgetAction-
408 and implementing QWidgetAction::createWidget() instead.-
409-
410 \sa QToolButton, QMenu, QAction, {Application Example}-
411*/-
412-
413/*!-
414 \fn bool QToolBar::isAreaAllowed(Qt::ToolBarArea area) const-
415-
416 Returns \c true if this toolbar is dockable in the given \a area;-
417 otherwise returns \c false.-
418*/-
419-
420/*!-
421 \fn void QToolBar::actionTriggered(QAction *action)-
422-
423 This signal is emitted when an action in this toolbar is triggered.-
424 This happens when the action's tool button is pressed, or when the-
425 action is triggered in some other way outside the toolbar. The parameter-
426 holds the triggered \a action.-
427*/-
428-
429/*!-
430 \fn void QToolBar::allowedAreasChanged(Qt::ToolBarAreas allowedAreas)-
431-
432 This signal is emitted when the collection of allowed areas for the-
433 toolbar is changed. The new areas in which the toolbar can be positioned-
434 are specified by \a allowedAreas.-
435-
436 \sa allowedAreas-
437*/-
438-
439/*!-
440 \fn void QToolBar::iconSizeChanged(const QSize &iconSize)-
441-
442 This signal is emitted when the icon size is changed. The \a-
443 iconSize parameter holds the toolbar's new icon size.-
444-
445 \sa iconSize, QMainWindow::iconSize-
446*/-
447-
448/*!-
449 \fn void QToolBar::movableChanged(bool movable)-
450-
451 This signal is emitted when the toolbar becomes movable or fixed.-
452 If the toolbar can be moved, \a movable is true; otherwise it is-
453 false.-
454-
455 \sa movable-
456*/-
457-
458/*!-
459 \fn void QToolBar::orientationChanged(Qt::Orientation orientation)-
460-
461 This signal is emitted when the orientation of the toolbar changes.-
462 The \a orientation parameter holds the toolbar's new orientation.-
463-
464 \sa orientation-
465*/-
466-
467/*!-
468 \fn void QToolBar::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)-
469-
470 This signal is emitted when the tool button style is changed. The-
471 \a toolButtonStyle parameter holds the toolbar's new tool button-
472 style.-
473-
474 \sa toolButtonStyle, QMainWindow::toolButtonStyle-
475*/-
476-
477/*!-
478 \since 4.6-
479-
480 \fn void QToolBar::topLevelChanged(bool topLevel)-
481-
482 This signal is emitted when the \l floating property changes.-
483 The \a topLevel parameter is true if the toolbar is now floating;-
484 otherwise it is false.-
485-
486 \sa isWindow()-
487*/-
488-
489-
490/*!-
491 \fn void QToolBar::visibilityChanged(bool visible)-
492 \since 4.7-
493-
494 This signal is emitted when the toolbar becomes \a visible (or-
495 invisible). This happens when the widget is hidden or shown.-
496*/-
497-
498/*!-
499 Constructs a QToolBar with the given \a parent.-
500*/-
501QToolBar::QToolBar(QWidget *parent)-
502 : QWidget(*new QToolBarPrivate, parent, 0)-
503{-
504 Q_D(QToolBar);-
505 d->init();-
506}
never executed: end of block
0
507-
508/*!-
509 Constructs a QToolBar with the given \a parent.-
510-
511 The given window \a title identifies the toolbar and is shown in-
512 the context menu provided by QMainWindow.-
513-
514 \sa setWindowTitle()-
515*/-
516QToolBar::QToolBar(const QString &title, QWidget *parent)-
517 : QWidget(*new QToolBarPrivate, parent, 0)-
518{-
519 Q_D(QToolBar);-
520 d->init();-
521 setWindowTitle(title);-
522}
never executed: end of block
0
523-
524-
525/*!-
526 Destroys the toolbar.-
527*/-
528QToolBar::~QToolBar()-
529{-
530}-
531-
532/*! \property QToolBar::movable-
533 \brief whether the user can move the toolbar within the toolbar area,-
534 or between toolbar areas.-
535-
536 By default, this property is \c true.-
537-
538 This property only makes sense if the toolbar is in a-
539 QMainWindow.-
540-
541 \sa allowedAreas-
542*/-
543-
544void QToolBar::setMovable(bool movable)-
545{-
546 Q_D(QToolBar);-
547 if (!movable == !d->movable)
!movable == !d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
0
548 return;
never executed: return;
0
549 d->movable = movable;-
550 d->layout->invalidate();-
551 emit movableChanged(d->movable);-
552}
never executed: end of block
0
553-
554bool QToolBar::isMovable() const-
555{-
556 Q_D(const QToolBar);-
557 return d->movable;
never executed: return d->movable;
0
558}-
559-
560/*!-
561 \property QToolBar::floatable-
562 \brief whether the toolbar can be dragged and dropped as an independent window.-
563-
564 The default is true.-
565*/-
566bool QToolBar::isFloatable() const-
567{-
568 Q_D(const QToolBar);-
569 return d->floatable;
never executed: return d->floatable;
0
570}-
571-
572void QToolBar::setFloatable(bool floatable)-
573{-
574 Q_D(QToolBar);-
575 d->floatable = floatable;-
576}
never executed: end of block
0
577-
578/*!-
579 \property QToolBar::floating-
580 \brief whether the toolbar is an independent window.-
581-
582 By default, this property is \c true.-
583-
584 \sa QWidget::isWindow()-
585*/-
586bool QToolBar::isFloating() const-
587{-
588 return isWindow();
never executed: return isWindow();
0
589}-
590-
591/*!-
592 \property QToolBar::allowedAreas-
593 \brief areas where the toolbar may be placed-
594-
595 The default is Qt::AllToolBarAreas.-
596-
597 This property only makes sense if the toolbar is in a-
598 QMainWindow.-
599-
600 \sa movable-
601*/-
602-
603void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas)-
604{-
605 Q_D(QToolBar);-
606 areas &= Qt::ToolBarArea_Mask;-
607 if (areas == d->allowedAreas)
areas == d->allowedAreasDescription
TRUEnever evaluated
FALSEnever evaluated
0
608 return;
never executed: return;
0
609 d->allowedAreas = areas;-
610 emit allowedAreasChanged(d->allowedAreas);-
611}
never executed: end of block
0
612-
613Qt::ToolBarAreas QToolBar::allowedAreas() const-
614{-
615 Q_D(const QToolBar);-
616 return d->allowedAreas;
never executed: return d->allowedAreas;
0
617}-
618-
619/*! \property QToolBar::orientation-
620 \brief orientation of the toolbar-
621-
622 The default is Qt::Horizontal.-
623-
624 This function should not be used when the toolbar is managed-
625 by QMainWindow. You can use QMainWindow::addToolBar() or-
626 QMainWindow::insertToolBar() if you wish to move a toolbar that-
627 is already added to a main window to another Qt::ToolBarArea.-
628*/-
629-
630void QToolBar::setOrientation(Qt::Orientation orientation)-
631{-
632 Q_D(QToolBar);-
633 if (orientation == d->orientation)
orientation == d->orientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
634 return;
never executed: return;
0
635-
636 d->orientation = orientation;-
637-
638 if (orientation == Qt::Vertical)
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
never executed: setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
0
640 else-
641 setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
never executed: setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
0
642-
643 d->layout->invalidate();-
644 d->layout->activate();-
645-
646 emit orientationChanged(d->orientation);-
647}
never executed: end of block
0
648-
649Qt::Orientation QToolBar::orientation() const-
650{
never executed: return d->orientation;
Q_D(const QToolBar); return d->orientation; }
never executed: return d->orientation;
0
651-
652/*!-
653 \property QToolBar::iconSize-
654 \brief size of icons in the toolbar.-
655-
656 The default size is determined by the application's style and is-
657 derived from the QStyle::PM_ToolBarIconSize pixel metric. It is-
658 the maximum size an icon can have. Icons of smaller size will not-
659 be scaled up.-
660*/-
661-
662QSize QToolBar::iconSize() const-
663{
never executed: return d->iconSize;
Q_D(const QToolBar); return d->iconSize; }
never executed: return d->iconSize;
0
664-
665void QToolBar::setIconSize(const QSize &iconSize)-
666{-
667 Q_D(QToolBar);-
668 QSize sz = iconSize;-
669 if (!sz.isValid()) {
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
670 QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());-
671 if (mw && mw->layout()) {
mwDescription
TRUEnever evaluated
FALSEnever evaluated
mw->layout()Description
TRUEnever evaluated
FALSEnever evaluated
0
672 QLayout *layout = mw->layout();-
673 int i = 0;-
674 QLayoutItem *item = 0;-
675 do {-
676 item = layout->itemAt(i++);-
677 if (item && (item->widget() == this))
itemDescription
TRUEnever evaluated
FALSEnever evaluated
(item->widget() == this)Description
TRUEnever evaluated
FALSEnever evaluated
0
678 sz = mw->iconSize();
never executed: sz = mw->iconSize();
0
679 } while (!sz.isValid() && item != 0);
never executed: end of block
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
item != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
680 }
never executed: end of block
0
681 }
never executed: end of block
0
682 if (!sz.isValid()) {
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
683 const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);-
684 sz = QSize(metric, metric);-
685 }
never executed: end of block
0
686 if (d->iconSize != sz) {
d->iconSize != szDescription
TRUEnever evaluated
FALSEnever evaluated
0
687 d->iconSize = sz;-
688 setMinimumSize(0, 0);-
689 emit iconSizeChanged(d->iconSize);-
690 }
never executed: end of block
0
691 d->explicitIconSize = iconSize.isValid();-
692-
693 d->layout->invalidate();-
694}
never executed: end of block
0
695-
696/*!-
697 \property QToolBar::toolButtonStyle-
698 \brief the style of toolbar buttons-
699-
700 This property defines the style of all tool buttons that are added-
701 as \l{QAction}s. Note that if you add a QToolButton with the-
702 addWidget() method, it will not get this button style.-
703-
704 To have the style of toolbuttons follow the system settings, set this property to Qt::ToolButtonFollowStyle.-
705 On Unix, the user settings from the desktop environment will be used.-
706 On other platforms, Qt::ToolButtonFollowStyle means icon only.-
707-
708 The default is Qt::ToolButtonIconOnly.-
709*/-
710-
711Qt::ToolButtonStyle QToolBar::toolButtonStyle() const-
712{
never executed: return d->toolButtonStyle;
Q_D(const QToolBar); return d->toolButtonStyle; }
never executed: return d->toolButtonStyle;
0
713-
714void QToolBar::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)-
715{-
716 Q_D(QToolBar);-
717 d->explicitToolButtonStyle = true;-
718 if (d->toolButtonStyle == toolButtonStyle)
d->toolButtonS...oolButtonStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 return;
never executed: return;
0
720 d->toolButtonStyle = toolButtonStyle;-
721 setMinimumSize(0, 0);-
722 emit toolButtonStyleChanged(d->toolButtonStyle);-
723}
never executed: end of block
0
724-
725/*!-
726 Removes all actions from the toolbar.-
727-
728 \sa removeAction()-
729*/-
730void QToolBar::clear()-
731{-
732 QList<QAction *> actions = this->actions();-
733 for(int i = 0; i < actions.size(); i++)
i < actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
734 removeAction(actions.at(i));
never executed: removeAction(actions.at(i));
0
735}
never executed: end of block
0
736-
737/*!-
738 \overload-
739-
740 Creates a new action with the given \a text. This action is added to-
741 the end of the toolbar.-
742*/-
743QAction *QToolBar::addAction(const QString &text)-
744{-
745 QAction *action = new QAction(text, this);-
746 addAction(action);-
747 return action;
never executed: return action;
0
748}-
749-
750/*!-
751 \overload-
752-
753 Creates a new action with the given \a icon and \a text. This-
754 action is added to the end of the toolbar.-
755*/-
756QAction *QToolBar::addAction(const QIcon &icon, const QString &text)-
757{-
758 QAction *action = new QAction(icon, text, this);-
759 addAction(action);-
760 return action;
never executed: return action;
0
761}-
762-
763/*!-
764 \overload-
765-
766 Creates a new action with the given \a text. This action is added to-
767 the end of the toolbar. The action's \l{QAction::triggered()}{triggered()}-
768 signal is connected to \a member in \a receiver.-
769*/-
770QAction *QToolBar::addAction(const QString &text,-
771 const QObject *receiver, const char* member)-
772{-
773 QAction *action = new QAction(text, this);-
774 QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);-
775 addAction(action);-
776 return action;
never executed: return action;
0
777}-
778-
779/*!-
780 \overload-
781-
782 Creates a new action with the given \a icon and \a text. This-
783 action is added to the end of the toolbar. The action's-
784 \l{QAction::triggered()}{triggered()} signal is connected to \a-
785 member in \a receiver.-
786*/-
787QAction *QToolBar::addAction(const QIcon &icon, const QString &text,-
788 const QObject *receiver, const char* member)-
789{-
790 QAction *action = new QAction(icon, text, this);-
791 QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);-
792 addAction(action);-
793 return action;
never executed: return action;
0
794}-
795-
796/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)-
797-
798 \since 5.6-
799-
800 \overload-
801-
802 Creates a new action with the given \a text. This action is added to-
803 the end of the toolbar. The action's-
804 \l{QAction::triggered()}{triggered()} signal is connected to the-
805 \a method of the \a receiver.-
806*/-
807-
808/*!\fn QAction *QToolBar::addAction(const QString &text, Functor functor)-
809-
810 \since 5.6-
811-
812 \overload-
813-
814 Creates a new action with the given \a text. This action is added to-
815 the end of the toolbar. The action's-
816 \l{QAction::triggered()}{triggered()} signal is connected to the-
817 \a functor.-
818*/-
819-
820/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)-
821-
822 \since 5.6-
823-
824 \overload-
825-
826 Creates a new action with the given \a text. This action is added to-
827 the end of the toolbar. The action's-
828 \l{QAction::triggered()}{triggered()} signal is connected to the-
829 \a functor.-
830-
831 If \a context is destroyed, the functor will not be called.-
832*/-
833-
834/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)-
835-
836 \since 5.6-
837-
838 \overload-
839-
840 Creates a new action with the given \a icon and \a text. This-
841 action is added to the end of the toolbar. The action's-
842 \l{QAction::triggered()}{triggered()} signal is connected to the-
843 \a method of the \a receiver.-
844*/-
845-
846/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)-
847-
848 \since 5.6-
849-
850 \overload-
851-
852 Creates a new action with the given \a icon and \a text. This-
853 action is added to the end of the toolbar. The action's-
854 \l{QAction::triggered()}{triggered()} signal is connected to the-
855 \a functor.-
856*/-
857-
858/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)-
859-
860 \since 5.6-
861-
862 \overload-
863-
864 Creates a new action with the given \a icon and \a text. This-
865 action is added to the end of the toolbar. The action's-
866 \l{QAction::triggered()}{triggered()} signal is connected to the-
867 \a functor.-
868-
869 If \a context is destroyed, the functor will not be called.-
870*/-
871-
872/*!-
873 Adds a separator to the end of the toolbar.-
874-
875 \sa insertSeparator()-
876*/-
877QAction *QToolBar::addSeparator()-
878{-
879 QAction *action = new QAction(this);-
880 action->setSeparator(true);-
881 addAction(action);-
882 return action;
never executed: return action;
0
883}-
884-
885/*!-
886 Inserts a separator into the toolbar in front of the toolbar-
887 item associated with the \a before action.-
888-
889 \sa addSeparator()-
890*/-
891QAction *QToolBar::insertSeparator(QAction *before)-
892{-
893 QAction *action = new QAction(this);-
894 action->setSeparator(true);-
895 insertAction(before, action);-
896 return action;
never executed: return action;
0
897}-
898-
899/*!-
900 Adds the given \a widget to the toolbar as the toolbar's last-
901 item.-
902-
903 The toolbar takes ownership of \a widget.-
904-
905 If you add a QToolButton with this method, the toolbar's-
906 Qt::ToolButtonStyle will not be respected.-
907-
908 \note You should use QAction::setVisible() to change the-
909 visibility of the widget. Using QWidget::setVisible(),-
910 QWidget::show() and QWidget::hide() does not work.-
911-
912 \sa insertWidget()-
913*/-
914QAction *QToolBar::addWidget(QWidget *widget)-
915{-
916 QWidgetAction *action = new QWidgetAction(this);-
917 action->setDefaultWidget(widget);-
918 action->d_func()->autoCreated = true;-
919 addAction(action);-
920 return action;
never executed: return action;
0
921}-
922-
923/*!-
924 Inserts the given \a widget in front of the toolbar item-
925 associated with the \a before action.-
926-
927 Note: You should use QAction::setVisible() to change the-
928 visibility of the widget. Using QWidget::setVisible(),-
929 QWidget::show() and QWidget::hide() does not work.-
930-
931 \sa addWidget()-
932*/-
933QAction *QToolBar::insertWidget(QAction *before, QWidget *widget)-
934{-
935 QWidgetAction *action = new QWidgetAction(this);-
936 action->setDefaultWidget(widget);-
937 action->d_func()->autoCreated = true;-
938 insertAction(before, action);-
939 return action;
never executed: return action;
0
940}-
941-
942/*!-
943 \internal-
944-
945 Returns the geometry of the toolbar item associated with the given-
946 \a action, or an invalid QRect if no matching item is found.-
947*/-
948QRect QToolBar::actionGeometry(QAction *action) const-
949{-
950 Q_D(const QToolBar);-
951-
952 int index = d->layout->indexOf(action);-
953 if (index == -1)
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
954 return QRect();
never executed: return QRect();
0
955 return d->layout->itemAt(index)->widget()->geometry();
never executed: return d->layout->itemAt(index)->widget()->geometry();
0
956}-
957-
958/*!-
959 Returns the action at point \a p. This function returns zero if no-
960 action was found.-
961-
962 \sa QWidget::childAt()-
963*/-
964QAction *QToolBar::actionAt(const QPoint &p) const-
965{-
966 Q_D(const QToolBar);-
967 QWidget *widget = childAt(p);-
968 int index = d->layout->indexOf(widget);-
969 if (index == -1)
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
970 return 0;
never executed: return 0;
0
971 QLayoutItem *item = d->layout->itemAt(index);-
972 return static_cast<QToolBarItem*>(item)->action;
never executed: return static_cast<QToolBarItem*>(item)->action;
0
973}-
974-
975/*! \fn QAction *QToolBar::actionAt(int x, int y) const-
976 \overload-
977-
978 Returns the action at the point \a x, \a y. This function returns-
979 zero if no action was found.-
980*/-
981-
982/*! \reimp */-
983void QToolBar::actionEvent(QActionEvent *event)-
984{-
985 Q_D(QToolBar);-
986 QAction *action = event->action();-
987 QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);-
988-
989 switch (event->type()) {-
990 case QEvent::ActionAdded: {
never executed: case QEvent::ActionAdded:
0
991 Q_ASSERT_X(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1,-
992 "QToolBar", "widgets cannot be inserted multiple times");-
993-
994 // reparent the action to this toolbar if it has been created-
995 // using the addAction(text) etc. convenience functions, to-
996 // preserve Qt 4.1.x behavior. The widget is already-
997 // reparented to us due to the createWidget call inside-
998 // createItem()-
999 if (widgetAction != 0 && widgetAction->d_func()->autoCreated)
widgetAction != 0Description
TRUEnever evaluated
FALSEnever evaluated
widgetAction->...)->autoCreatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1000 widgetAction->setParent(this);
never executed: widgetAction->setParent(this);
0
1001-
1002 int index = d->layout->count();-
1003 if (event->before()) {
event->before()Description
TRUEnever evaluated
FALSEnever evaluated
0
1004 index = d->layout->indexOf(event->before());-
1005 Q_ASSERT_X(index != -1, "QToolBar::insertAction", "internal error");-
1006 }
never executed: end of block
0
1007 d->layout->insertAction(index, action);-
1008 break;
never executed: break;
0
1009 }-
1010-
1011 case QEvent::ActionChanged:
never executed: case QEvent::ActionChanged:
0
1012 d->layout->invalidate();-
1013 break;
never executed: break;
0
1014-
1015 case QEvent::ActionRemoved: {
never executed: case QEvent::ActionRemoved:
0
1016 int index = d->layout->indexOf(action);-
1017 if (index != -1) {
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1018 delete d->layout->takeAt(index);-
1019 }
never executed: end of block
0
1020 break;
never executed: break;
0
1021 }-
1022-
1023 default:
never executed: default:
0
1024 Q_ASSERT_X(false, "QToolBar::actionEvent", "internal error");-
1025 }
never executed: end of block
0
1026}-
1027-
1028/*! \reimp */-
1029void QToolBar::changeEvent(QEvent *event)-
1030{-
1031 Q_D(QToolBar);-
1032 switch (event->type()) {-
1033 case QEvent::WindowTitleChange:
never executed: case QEvent::WindowTitleChange:
0
1034 d->toggleViewAction->setText(windowTitle());-
1035 break;
never executed: break;
0
1036 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1037 d->layout->invalidate();-
1038 if (!d->explicitIconSize)
!d->explicitIconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1039 setIconSize(QSize());
never executed: setIconSize(QSize());
0
1040 d->layout->updateMarginAndSpacing();-
1041 break;
never executed: break;
0
1042 case QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
1043 d->layout->invalidate();-
1044 break;
never executed: break;
0
1045 default:
never executed: default:
0
1046 break;
never executed: break;
0
1047 }-
1048 QWidget::changeEvent(event);-
1049}
never executed: end of block
0
1050-
1051/*! \reimp */-
1052void QToolBar::paintEvent(QPaintEvent *)-
1053{-
1054 Q_D(QToolBar);-
1055-
1056 QPainter p(this);-
1057 QStyle *style = this->style();-
1058 QStyleOptionToolBar opt;-
1059 initStyleOption(&opt);-
1060-
1061 if (d->layout->expanded || d->layout->animating || isWindow()) {
d->layout->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
d->layout->animatingDescription
TRUEnever evaluated
FALSEnever evaluated
isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1062 //if the toolbar is expended, we need to fill the background with the window color-
1063 //because some styles may expects that.-
1064 p.fillRect(opt.rect, palette().background());-
1065 style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);-
1066 style->drawPrimitive(QStyle::PE_FrameMenu, &opt, &p, this);-
1067 } else {
never executed: end of block
0
1068 style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);-
1069 }
never executed: end of block
0
1070-
1071 opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this);-
1072 if (opt.rect.isValid())
opt.rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1073 style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
never executed: style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
0
1074}
never executed: end of block
0
1075-
1076/*-
1077 Checks if an expanded toolbar has to wait for this popup to close before-
1078 the toolbar collapses. This is true if-
1079 1) the popup has the toolbar in its parent chain,-
1080 2) the popup is a menu whose menuAction is somewhere in the toolbar.-
1081*/-
1082static bool waitForPopup(QToolBar *tb, QWidget *popup)-
1083{-
1084 if (popup == 0 || popup->isHidden())
popup == 0Description
TRUEnever evaluated
FALSEnever evaluated
popup->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
0
1085 return false;
never executed: return false;
0
1086-
1087 QWidget *w = popup;-
1088 while (w != 0) {
w != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1089 if (w == tb)
w == tbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1090 return true;
never executed: return true;
0
1091 w = w->parentWidget();-
1092 }
never executed: end of block
0
1093-
1094 QMenu *menu = qobject_cast<QMenu*>(popup);-
1095 if (menu == 0)
menu == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1096 return false;
never executed: return false;
0
1097-
1098 QAction *action = menu->menuAction();-
1099 QList<QWidget*> widgets = action->associatedWidgets();-
1100 for (int i = 0; i < widgets.count(); ++i) {
i < widgets.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1101 if (waitForPopup(tb, widgets.at(i)))
waitForPopup(t...widgets.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
1102 return true;
never executed: return true;
0
1103 }
never executed: end of block
0
1104-
1105 return false;
never executed: return false;
0
1106}-
1107-
1108#ifdef Q_OS_OSX-
1109static void enableMacToolBar(QToolBar *toolbar, bool enable)-
1110{-
1111 QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface();-
1112 QPlatformNativeInterface::NativeResourceForIntegrationFunction function =-
1113 nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled");-
1114 if (!function)-
1115 return; // Not Cocoa platform plugin.-
1116-
1117 typedef void (*SetContentBorderAreaEnabledFunction)(QWindow *window, void *identifier, bool enabled);-
1118 (reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(toolbar->window()->windowHandle(), toolbar, enable);-
1119}-
1120#endif-
1121-
1122-
1123/*! \reimp */-
1124bool QToolBar::event(QEvent *event)-
1125{-
1126 Q_D(QToolBar);-
1127-
1128 switch (event->type()) {-
1129 case QEvent::Timer:
never executed: case QEvent::Timer:
0
1130 if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
d->waitForPopu...nt)->timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
1131 QWidget *w = QApplication::activePopupWidget();-
1132 if (!waitForPopup(this, w)) {
!waitForPopup(this, w)Description
TRUEnever evaluated
FALSEnever evaluated
0
1133 d->waitForPopupTimer.stop();-
1134 if (!this->underMouse())
!this->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
1135 d->layout->setExpanded(false);
never executed: d->layout->setExpanded(false);
0
1136 }
never executed: end of block
0
1137 }
never executed: end of block
0
1138 break;
never executed: break;
0
1139 case QEvent::Hide:
never executed: case QEvent::Hide:
0
1140 if (!isHidden())
!isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
0
1141 break;
never executed: break;
0
1142 // fallthrough intended-
1143 case QEvent::Show:
code before this statement never executed: case QEvent::Show:
never executed: case QEvent::Show:
0
1144 d->toggleViewAction->setChecked(event->type() == QEvent::Show);-
1145#ifdef Q_OS_OSX-
1146 enableMacToolBar(this, event->type() == QEvent::Show);-
1147#endif-
1148 emit visibilityChanged(event->type() == QEvent::Show);-
1149 break;
never executed: break;
0
1150 case QEvent::ParentChange:
never executed: case QEvent::ParentChange:
0
1151 d->layout->checkUsePopupMenu();-
1152 break;
never executed: break;
0
1153-
1154 case QEvent::MouseButtonPress: {
never executed: case QEvent::MouseButtonPress:
0
1155 if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
d->mousePressE...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
0
1156 return true;
never executed: return true;
0
1157 break;
never executed: break;
0
1158 }-
1159 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
1160 if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
d->mouseReleas...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
0
1161 return true;
never executed: return true;
0
1162 break;
never executed: break;
0
1163 case QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
1164 case QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
1165 // there's nothing special to do here and we don't want to update the whole widget-
1166 return true;
never executed: return true;
0
1167 case QEvent::HoverMove: {
never executed: case QEvent::HoverMove:
0
1168#ifndef QT_NO_CURSOR-
1169 QHoverEvent *e = static_cast<QHoverEvent*>(event);-
1170 QStyleOptionToolBar opt;-
1171 initStyleOption(&opt);-
1172 if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
style()->subEl...ains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1173 setCursor(Qt::SizeAllCursor);
never executed: setCursor(Qt::SizeAllCursor);
0
1174 else-
1175 unsetCursor();
never executed: unsetCursor();
0
1176#endif-
1177 break;
never executed: break;
0
1178 }-
1179 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
1180 if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
d->mouseMoveEv...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
0
1181 return true;
never executed: return true;
0
1182 break;
never executed: break;
0
1183#ifdef Q_OS_WINCE-
1184 case QEvent::ContextMenu:-
1185 {-
1186 QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);-
1187 QWidget* child = childAt(contextMenuEvent->pos());-
1188 QAbstractButton* button = qobject_cast<QAbstractButton*>(child);-
1189 if (button)-
1190 button->setDown(false);-
1191 }-
1192 break;-
1193#endif-
1194 case QEvent::Leave:
never executed: case QEvent::Leave:
0
1195 if (d->state != 0 && d->state->dragging) {
d->state != 0Description
TRUEnever evaluated
FALSEnever evaluated
d->state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1196#ifdef Q_OS_WIN-
1197 // This is a workaround for loosing the mouse on Vista.-
1198 QPoint pos = QCursor::pos();-
1199 QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,-
1200 QApplication::mouseButtons(), QApplication::keyboardModifiers());-
1201 d->mouseMoveEvent(&fake);-
1202#endif-
1203 } else {
never executed: end of block
0
1204 if (!d->layout->expanded)
!d->layout->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1205 break;
never executed: break;
0
1206-
1207 QWidget *w = QApplication::activePopupWidget();-
1208 if (waitForPopup(this, w)) {
waitForPopup(this, w)Description
TRUEnever evaluated
FALSEnever evaluated
0
1209 d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);-
1210 break;
never executed: break;
0
1211 }-
1212-
1213 d->waitForPopupTimer.stop();-
1214 d->layout->setExpanded(false);-
1215 break;
never executed: break;
0
1216 }-
1217 default:
code before this statement never executed: default:
never executed: default:
0
1218 break;
never executed: break;
0
1219 }-
1220 return QWidget::event(event);
never executed: return QWidget::event(event);
0
1221}-
1222-
1223/*!-
1224 Returns a checkable action that can be used to show or hide this-
1225 toolbar.-
1226-
1227 The action's text is set to the toolbar's window title.-
1228-
1229 \sa QAction::text, QWidget::windowTitle-
1230*/-
1231QAction *QToolBar::toggleViewAction() const-
1232{
never executed: return d->toggleViewAction;
Q_D(const QToolBar); return d->toggleViewAction; }
never executed: return d->toggleViewAction;
0
1233-
1234/*!-
1235 \since 4.2-
1236-
1237 Returns the widget associated with the specified \a action.-
1238-
1239 \sa addWidget()-
1240*/-
1241QWidget *QToolBar::widgetForAction(QAction *action) const-
1242{-
1243 Q_D(const QToolBar);-
1244-
1245 int index = d->layout->indexOf(action);-
1246 if (index == -1)
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1247 return 0;
never executed: return 0;
0
1248-
1249 return d->layout->itemAt(index)->widget();
never executed: return d->layout->itemAt(index)->widget();
0
1250}-
1251-
1252extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
1253-
1254/*!-
1255 \internal-
1256*/-
1257void QToolBar::initStyleOption(QStyleOptionToolBar *option) const-
1258{-
1259 Q_D(const QToolBar);-
1260-
1261 if (!option)
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1262 return;
never executed: return;
0
1263-
1264 option->initFrom(this);-
1265 if (orientation() == Qt::Horizontal)
orientation() ...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1266 option->state |= QStyle::State_Horizontal;
never executed: option->state |= QStyle::State_Horizontal;
0
1267 option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);-
1268 option->features = d->layout->movable()
d->layout->movable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1269 ? QStyleOptionToolBar::Movable-
1270 : QStyleOptionToolBar::None;-
1271 // if the tool bar is not in a QMainWindow, this will make the painting right-
1272 option->toolBarArea = Qt::NoToolBarArea;-
1273-
1274 // Add more styleoptions if the toolbar has been added to a mainwindow.-
1275 QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());-
1276-
1277 if (!mainWindow)
!mainWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1278 return;
never executed: return;
0
1279-
1280 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);-
1281 Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()",-
1282 "QMainWindow->layout() != QMainWindowLayout");-
1283-
1284 layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this));-
1285}
never executed: end of block
0
1286-
1287QT_END_NAMESPACE-
1288-
1289#include "moc_qtoolbar.cpp"-
1290-
1291#endif // QT_NO_TOOLBAR-
Source codeSwitch to Preprocessed file

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