OpenCoverage

qmainwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmainwindow.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40//#define QT_EXPERIMENTAL_CLIENT_DECORATIONS-
41-
42#include "qmainwindow.h"-
43#include "qmainwindowlayout_p.h"-
44-
45#ifndef QT_NO_MAINWINDOW-
46-
47#include "qdockwidget.h"-
48#include "qtoolbar.h"-
49-
50#include <qapplication.h>-
51#include <qmenubar.h>-
52#include <qstatusbar.h>-
53#include <qevent.h>-
54#include <qstyle.h>-
55#include <qdebug.h>-
56#include <qpainter.h>-
57-
58#include <private/qwidget_p.h>-
59#include "qtoolbar_p.h"-
60#include "qwidgetanimator_p.h"-
61#ifdef Q_OS_OSX-
62#include <qpa/qplatformnativeinterface.h>-
63#endif-
64#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
65#include <private/qt_mac_p.h>-
66#include <private/qt_cocoa_helpers_mac_p.h>-
67QT_BEGIN_NAMESPACE-
68extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp-
69QT_END_NAMESPACE-
70#endif-
71-
72QT_BEGIN_NAMESPACE-
73-
74class QMainWindowPrivate : public QWidgetPrivate-
75{-
76 Q_DECLARE_PUBLIC(QMainWindow)-
77public:-
78 inline QMainWindowPrivate()-
79 : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)-
80#ifdef Q_OS_OSX-
81 , useUnifiedToolBar(false)-
82#endif-
83#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
84 , useHIToolBar(false)-
85 , activateUnifiedToolbarAfterFullScreen(false)-
86#endif-
87#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)-
88 , hasOldCursor(false) , cursorAdjusted(false)-
89#endif-
90 { }
never executed: end of block
0
91 QMainWindowLayout *layout;-
92 QSize iconSize;-
93 bool explicitIconSize;-
94 Qt::ToolButtonStyle toolButtonStyle;-
95#ifdef Q_OS_OSX-
96 bool useUnifiedToolBar;-
97#endif-
98#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
99 bool useHIToolBar;-
100 bool activateUnifiedToolbarAfterFullScreen;-
101#endif-
102 void init();-
103 QList<int> hoverSeparator;-
104 QPoint hoverPos;-
105-
106#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)-
107 QCursor separatorCursor(const QList<int> &path) const;-
108 void adjustCursor(const QPoint &pos);-
109 QCursor oldCursor;-
110 QCursor adjustedCursor;-
111 uint hasOldCursor : 1;-
112 uint cursorAdjusted : 1;-
113#endif-
114-
115 static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)-
116 {-
117 return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0);
never executed: return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0);
0
118 }-
119};-
120-
121QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow)-
122{-
123 return QMainWindowPrivate::mainWindowLayout(mainWindow);
never executed: return QMainWindowPrivate::mainWindowLayout(mainWindow);
0
124}-
125-
126#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS-
127Q_WIDGETS_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget)-
128{-
129 QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout());-
130 Q_ASSERT(topLayout);-
131-
132 int row = 0;-
133 int column = 0;-
134-
135 switch (area) {-
136 case Qt::LeftDockWidgetArea:-
137 row = 1;-
138 column = 0;-
139 break;-
140 case Qt::TopDockWidgetArea:-
141 row = 0;-
142 column = 1;-
143 break;-
144 case Qt::BottomDockWidgetArea:-
145 row = 2;-
146 column = 1;-
147 break;-
148 case Qt::RightDockWidgetArea:-
149 row = 1;-
150 column = 2;-
151 break;-
152 default:-
153 Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area");-
154 return;-
155 }-
156-
157 if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column))-
158 delete oldItem->widget();-
159 topLayout->addWidget(widget, row, column);-
160}-
161#endif-
162-
163void QMainWindowPrivate::init()-
164{-
165 Q_Q(QMainWindow);-
166-
167#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS-
168 QGridLayout *topLayout = new QGridLayout(q);-
169 topLayout->setContentsMargins(0, 0, 0, 0);-
170-
171 layout = new QMainWindowLayout(q, topLayout);-
172-
173 topLayout->addItem(layout, 1, 1);-
174#else-
175 layout = new QMainWindowLayout(q, 0);-
176#endif-
177-
178 const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);-
179 iconSize = QSize(metric, metric);-
180 q->setAttribute(Qt::WA_Hover);-
181}
never executed: end of block
0
182-
183/*-
184 The Main Window:-
185-
186 +----------------------------------------------------------+-
187 | Menu Bar |-
188 +----------------------------------------------------------+-
189 | Tool Bar Area |-
190 | +--------------------------------------------------+ |-
191 | | Dock Window Area | |-
192 | | +------------------------------------------+ | |-
193 | | | | | |-
194 | | | Central Widget | | |-
195 | | | | | |-
196 | | | | | |-
197 | | | | | |-
198 | | | | | |-
199 | | | | | |-
200 | | | | | |-
201 | | | | | |-
202 | | | | | |-
203 | | | | | |-
204 | | | | | |-
205 | | +------------------------------------------+ | |-
206 | | | |-
207 | +--------------------------------------------------+ |-
208 | |-
209 +----------------------------------------------------------+-
210 | Status Bar |-
211 +----------------------------------------------------------+-
212-
213*/-
214-
215/*!-
216 \class QMainWindow-
217 \brief The QMainWindow class provides a main application-
218 window.-
219 \ingroup mainwindow-classes-
220 \inmodule QtWidgets-
221-
222 \tableofcontents-
223-
224 \section1 Qt Main Window Framework-
225-
226 A main window provides a framework for building an-
227 application's user interface. Qt has QMainWindow and its \l{Main-
228 Window and Related Classes}{related classes} for main window-
229 management. QMainWindow has its own layout to which you can add-
230 \l{QToolBar}s, \l{QDockWidget}s, a-
231 QMenuBar, and a QStatusBar. The layout has a center area that can-
232 be occupied by any kind of widget. You can see an image of the-
233 layout below.-
234-
235 \image mainwindowlayout.png-
236-
237 \note Creating a main window without a central widget is not supported.-
238 You must have a central widget even if it is just a placeholder.-
239-
240 \section1 Creating Main Window Components-
241-
242 A central widget will typically be a standard Qt widget such-
243 as a QTextEdit or a QGraphicsView. Custom widgets can also be-
244 used for advanced applications. You set the central widget with \c-
245 setCentralWidget().-
246-
247 Main windows have either a single (SDI) or multiple (MDI)-
248 document interface. You create MDI applications in Qt by using a-
249 QMdiArea as the central widget.-
250-
251 We will now examine each of the other widgets that can be-
252 added to a main window. We give examples on how to create and add-
253 them.-
254-
255 \section2 Creating Menus-
256-
257 Qt implements menus in QMenu and QMainWindow keeps them in a-
258 QMenuBar. \l{QAction}{QAction}s are added to the menus, which-
259 display them as menu items.-
260-
261 You can add new menus to the main window's menu bar by calling-
262 \c menuBar(), which returns the QMenuBar for the window, and then-
263 add a menu with QMenuBar::addMenu().-
264-
265 QMainWindow comes with a default menu bar, but you can also-
266 set one yourself with \c setMenuBar(). If you wish to implement a-
267 custom menu bar (i.e., not use the QMenuBar widget), you can set it-
268 with \c setMenuWidget().-
269-
270 An example of how to create menus follows:-
271-
272 \code-
273 void MainWindow::createMenus()-
274 {-
275 fileMenu = menuBar()->addMenu(tr("&File"));-
276 fileMenu->addAction(newAct);-
277 fileMenu->addAction(openAct);-
278 fileMenu->addAction(saveAct);-
279 \endcode-
280-
281 The \c createPopupMenu() function creates popup menus when the-
282 main window receives context menu events. The default-
283 implementation generates a menu with the checkable actions from-
284 the dock widgets and toolbars. You can reimplement \c-
285 createPopupMenu() for a custom menu.-
286-
287 \section2 Creating Toolbars-
288-
289 Toolbars are implemented in the QToolBar class. You add a-
290 toolbar to a main window with \c addToolBar().-
291-
292 You control the initial position of toolbars by assigning them-
293 to a specific Qt::ToolBarArea. You can split an area by inserting-
294 a toolbar break - think of this as a line break in text editing --
295 with \c addToolBarBreak() or \c insertToolBarBreak(). You can also-
296 restrict placement by the user with QToolBar::setAllowedAreas()-
297 and QToolBar::setMovable().-
298-
299 The size of toolbar icons can be retrieved with \c iconSize().-
300 The sizes are platform dependent; you can set a fixed size with \c-
301 setIconSize(). You can alter the appearance of all tool buttons in-
302 the toolbars with \c setToolButtonStyle().-
303-
304 An example of toolbar creation follows:-
305-
306 \code-
307 void MainWindow::createToolBars()-
308 {-
309 fileToolBar = addToolBar(tr("File"));-
310 fileToolBar->addAction(newAct);-
311 \endcode-
312-
313 \section2 Creating Dock Widgets-
314-
315 Dock widgets are implemented in the QDockWidget class. A dock-
316 widget is a window that can be docked into the main window. You-
317 add dock widgets to a main window with \c addDockWidget().-
318-
319 There are four dock widget areas as given by the-
320 Qt::DockWidgetArea enum: left, right, top, and bottom. You can-
321 specify which dock widget area that should occupy the corners-
322 where the areas overlap with \c setCorner(). By default-
323 each area can only contain one row (vertical or horizontal) of-
324 dock widgets, but if you enable nesting with \c-
325 setDockNestingEnabled(), dock widgets can be added in either-
326 direction.-
327-
328 Two dock widgets may also be stacked on top of each other. A-
329 QTabBar is then used to select which of the widgets should be-
330 displayed.-
331-
332 We give an example of how to create and add dock widgets to a-
333 main window:-
334-
335 \snippet mainwindowsnippet.cpp 0-
336-
337 \section2 The Status Bar-
338-
339 You can set a status bar with \c setStatusBar(), but one is-
340 created the first time \c statusBar() (which returns the main-
341 window's status bar) is called. See QStatusBar for information on-
342 how to use it.-
343-
344 \section1 Storing State-
345-
346 QMainWindow can store the state of its layout with \c-
347 saveState(); it can later be retrieved with \c restoreState(). It-
348 is the position and size (relative to the size of the main window)-
349 of the toolbars and dock widgets that are stored.-
350-
351 \sa QMenuBar, QToolBar, QStatusBar, QDockWidget, {Application-
352 Example}, {Dock Widgets Example}, {MDI Example}, {SDI Example},-
353 {Menus Example}-
354*/-
355-
356/*!-
357 \fn void QMainWindow::iconSizeChanged(const QSize &iconSize)-
358-
359 This signal is emitted when the size of the icons used in the-
360 window is changed. The new icon size is passed in \a iconSize.-
361-
362 You can connect this signal to other components to help maintain-
363 a consistent appearance for your application.-
364-
365 \sa setIconSize()-
366*/-
367-
368/*!-
369 \fn void QMainWindow::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)-
370-
371 This signal is emitted when the style used for tool buttons in the-
372 window is changed. The new style is passed in \a toolButtonStyle.-
373-
374 You can connect this signal to other components to help maintain-
375 a consistent appearance for your application.-
376-
377 \sa setToolButtonStyle()-
378*/-
379-
380/*!-
381 Constructs a QMainWindow with the given \a parent and the specified-
382 widget \a flags.-
383-
384 QMainWindow sets the Qt::Window flag itself, and will hence-
385 always be created as a top-level widget.-
386 */-
387QMainWindow::QMainWindow(QWidget *parent, Qt::WindowFlags flags)-
388 : QWidget(*(new QMainWindowPrivate()), parent, flags | Qt::Window)-
389{-
390 d_func()->init();-
391}
never executed: end of block
0
392-
393-
394/*!-
395 Destroys the main window.-
396 */-
397QMainWindow::~QMainWindow()-
398{ }-
399-
400/*! \property QMainWindow::iconSize-
401 \brief size of toolbar icons in this mainwindow.-
402-
403 The default is the default tool bar icon size of the GUI style.-
404 Note that the icons used must be at least of this size as the-
405 icons are only scaled down.-
406*/-
407-
408/*!-
409 \property QMainWindow::dockOptions-
410 \brief the docking behavior of QMainWindow-
411 \since 4.3-
412-
413 The default value is AnimatedDocks | AllowTabbedDocks.-
414*/-
415-
416/*!-
417 \enum QMainWindow::DockOption-
418 \since 4.3-
419-
420 This enum contains flags that specify the docking behavior of QMainWindow.-
421-
422 \value AnimatedDocks Identical to the \l animated property.-
423-
424 \value AllowNestedDocks Identical to the \l dockNestingEnabled property.-
425-
426 \value AllowTabbedDocks The user can drop one dock widget "on top" of-
427 another. The two widgets are stacked and a tab-
428 bar appears for selecting which one is visible.-
429-
430 \value ForceTabbedDocks Each dock area contains a single stack of tabbed-
431 dock widgets. In other words, dock widgets cannot-
432 be placed next to each other in a dock area. If-
433 this option is set, AllowNestedDocks has no effect.-
434-
435 \value VerticalTabs The two vertical dock areas on the sides of the-
436 main window show their tabs vertically. If this-
437 option is not set, all dock areas show their tabs-
438 at the bottom. Implies AllowTabbedDocks. See also-
439 \l setTabPosition().-
440-
441 \value GroupedDragging When dragging the titlebar of a dock, all the tabs-
442 that are tabbed with it are going to be dragged.-
443 Implies AllowTabbedDocks. Does not work well if-
444 some QDockWidgets have restrictions in which area-
445 they are allowed. (This enum value was added in Qt-
446 5.6.)-
447-
448 These options only control how dock widgets may be dropped in a QMainWindow.-
449 They do not re-arrange the dock widgets to conform with the specified-
450 options. For this reason they should be set before any dock widgets-
451 are added to the main window. Exceptions to this are the AnimatedDocks and-
452 VerticalTabs options, which may be set at any time.-
453*/-
454-
455void QMainWindow::setDockOptions(DockOptions opt)-
456{-
457 Q_D(QMainWindow);-
458 d->layout->setDockOptions(opt);-
459}
never executed: end of block
0
460-
461QMainWindow::DockOptions QMainWindow::dockOptions() const-
462{-
463 Q_D(const QMainWindow);-
464 return d->layout->dockOptions;
never executed: return d->layout->dockOptions;
0
465}-
466-
467QSize QMainWindow::iconSize() const-
468{
never executed: return d_func()->iconSize;
return d_func()->iconSize; }
never executed: return d_func()->iconSize;
0
469-
470void QMainWindow::setIconSize(const QSize &iconSize)-
471{-
472 Q_D(QMainWindow);-
473 QSize sz = iconSize;-
474 if (!sz.isValid()) {
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
475 const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);-
476 sz = QSize(metric, metric);-
477 }
never executed: end of block
0
478 if (d->iconSize != sz) {
d->iconSize != szDescription
TRUEnever evaluated
FALSEnever evaluated
0
479 d->iconSize = sz;-
480 emit iconSizeChanged(d->iconSize);-
481 }
never executed: end of block
0
482 d->explicitIconSize = iconSize.isValid();-
483}
never executed: end of block
0
484-
485/*! \property QMainWindow::toolButtonStyle-
486 \brief style of toolbar buttons in this mainwindow.-
487-
488 To have the style of toolbuttons follow the system settings, set this property to Qt::ToolButtonFollowStyle.-
489 On Unix, the user settings from the desktop environment will be used.-
490 On other platforms, Qt::ToolButtonFollowStyle means icon only.-
491-
492 The default is Qt::ToolButtonIconOnly.-
493*/-
494-
495Qt::ToolButtonStyle QMainWindow::toolButtonStyle() const-
496{
never executed: return d_func()->toolButtonStyle;
return d_func()->toolButtonStyle; }
never executed: return d_func()->toolButtonStyle;
0
497-
498void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)-
499{-
500 Q_D(QMainWindow);-
501 if (d->toolButtonStyle == toolButtonStyle)
d->toolButtonS...oolButtonStyleDescription
TRUEnever evaluated
FALSEnever evaluated
0
502 return;
never executed: return;
0
503 d->toolButtonStyle = toolButtonStyle;-
504 emit toolButtonStyleChanged(d->toolButtonStyle);-
505}
never executed: end of block
0
506-
507#ifndef QT_NO_MENUBAR-
508/*!-
509 Returns the menu bar for the main window. This function creates-
510 and returns an empty menu bar if the menu bar does not exist.-
511-
512 If you want all windows in a Mac application to share one menu-
513 bar, don't use this function to create it, because the menu bar-
514 created here will have this QMainWindow as its parent. Instead,-
515 you must create a menu bar that does not have a parent, which you-
516 can then share among all the Mac windows. Create a parent-less-
517 menu bar this way:-
518-
519 \snippet code/src_gui_widgets_qmenubar.cpp 1-
520-
521 \sa setMenuBar()-
522*/-
523QMenuBar *QMainWindow::menuBar() const-
524{-
525 QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar());-
526 if (!menuBar) {
!menuBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
527 QMainWindow *self = const_cast<QMainWindow *>(this);-
528 menuBar = new QMenuBar(self);-
529 self->setMenuBar(menuBar);-
530 }
never executed: end of block
0
531 return menuBar;
never executed: return menuBar;
0
532}-
533-
534/*!-
535 Sets the menu bar for the main window to \a menuBar.-
536-
537 Note: QMainWindow takes ownership of the \a menuBar pointer and-
538 deletes it at the appropriate time.-
539-
540 \sa menuBar()-
541*/-
542void QMainWindow::setMenuBar(QMenuBar *menuBar)-
543{-
544 QLayout *topLayout = layout();-
545-
546 if (topLayout->menuBar() && topLayout->menuBar() != menuBar) {
topLayout->menuBar()Description
TRUEnever evaluated
FALSEnever evaluated
topLayout->men...r() != menuBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
547 // Reparent corner widgets before we delete the old menu bar.-
548 QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar());-
549 if (menuBar) {
menuBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
550 // TopLeftCorner widget.-
551 QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner);-
552 if (cornerWidget)
cornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
553 menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner);
never executed: menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner);
0
554 // TopRightCorner widget.-
555 cornerWidget = oldMenuBar->cornerWidget(Qt::TopRightCorner);-
556 if (cornerWidget)
cornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
557 menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner);
never executed: menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner);
0
558 }
never executed: end of block
0
559 oldMenuBar->hide();-
560 oldMenuBar->deleteLater();-
561 }
never executed: end of block
0
562 topLayout->setMenuBar(menuBar);-
563}
never executed: end of block
0
564-
565/*!-
566 \since 4.2-
567-
568 Returns the menu bar for the main window. This function returns-
569 null if a menu bar hasn't been constructed yet.-
570*/-
571QWidget *QMainWindow::menuWidget() const-
572{-
573 QWidget *menuBar = d_func()->layout->menuBar();-
574 return menuBar;
never executed: return menuBar;
0
575}-
576-
577/*!-
578 \since 4.2-
579-
580 Sets the menu bar for the main window to \a menuBar.-
581-
582 QMainWindow takes ownership of the \a menuBar pointer and-
583 deletes it at the appropriate time.-
584*/-
585void QMainWindow::setMenuWidget(QWidget *menuBar)-
586{-
587 Q_D(QMainWindow);-
588 if (d->layout->menuBar() && d->layout->menuBar() != menuBar) {
d->layout->menuBar()Description
TRUEnever evaluated
FALSEnever evaluated
d->layout->men...r() != menuBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
589 d->layout->menuBar()->hide();-
590 d->layout->menuBar()->deleteLater();-
591 }
never executed: end of block
0
592 d->layout->setMenuBar(menuBar);-
593}
never executed: end of block
0
594#endif // QT_NO_MENUBAR-
595-
596#ifndef QT_NO_STATUSBAR-
597/*!-
598 Returns the status bar for the main window. This function creates-
599 and returns an empty status bar if the status bar does not exist.-
600-
601 \sa setStatusBar()-
602*/-
603QStatusBar *QMainWindow::statusBar() const-
604{-
605 QStatusBar *statusbar = d_func()->layout->statusBar();-
606 if (!statusbar) {
!statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
607 QMainWindow *self = const_cast<QMainWindow *>(this);-
608 statusbar = new QStatusBar(self);-
609 statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);-
610 self->setStatusBar(statusbar);-
611 }
never executed: end of block
0
612 return statusbar;
never executed: return statusbar;
0
613}-
614-
615/*!-
616 Sets the status bar for the main window to \a statusbar.-
617-
618 Setting the status bar to 0 will remove it from the main window.-
619 Note that QMainWindow takes ownership of the \a statusbar pointer-
620 and deletes it at the appropriate time.-
621-
622 \sa statusBar()-
623*/-
624void QMainWindow::setStatusBar(QStatusBar *statusbar)-
625{-
626 Q_D(QMainWindow);-
627 if (d->layout->statusBar() && d->layout->statusBar() != statusbar) {
d->layout->statusBar()Description
TRUEnever evaluated
FALSEnever evaluated
d->layout->sta...) != statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
628 d->layout->statusBar()->hide();-
629 d->layout->statusBar()->deleteLater();-
630 }
never executed: end of block
0
631 d->layout->setStatusBar(statusbar);-
632}
never executed: end of block
0
633#endif // QT_NO_STATUSBAR-
634-
635/*!-
636 Returns the central widget for the main window. This function-
637 returns zero if the central widget has not been set.-
638-
639 \sa setCentralWidget()-
640*/-
641QWidget *QMainWindow::centralWidget() const-
642{
never executed: return d_func()->layout->centralWidget();
return d_func()->layout->centralWidget(); }
never executed: return d_func()->layout->centralWidget();
0
643-
644/*!-
645 Sets the given \a widget to be the main window's central widget.-
646-
647 Note: QMainWindow takes ownership of the \a widget pointer and-
648 deletes it at the appropriate time.-
649-
650 \sa centralWidget()-
651*/-
652void QMainWindow::setCentralWidget(QWidget *widget)-
653{-
654 Q_D(QMainWindow);-
655 if (d->layout->centralWidget() && d->layout->centralWidget() != widget) {
d->layout->centralWidget()Description
TRUEnever evaluated
FALSEnever evaluated
d->layout->cen...et() != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
656 d->layout->centralWidget()->hide();-
657 d->layout->centralWidget()->deleteLater();-
658 }
never executed: end of block
0
659 d->layout->setCentralWidget(widget);-
660}
never executed: end of block
0
661-
662/*!-
663 Removes the central widget from this main window.-
664-
665 The ownership of the removed widget is passed to the caller.-
666-
667 \since Qt 5.2-
668*/-
669QWidget *QMainWindow::takeCentralWidget()-
670{-
671 Q_D(QMainWindow);-
672 QWidget *oldcentralwidget = d->layout->centralWidget();-
673 if (oldcentralwidget) {
oldcentralwidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
674 oldcentralwidget->setParent(0);-
675 d->layout->setCentralWidget(0);-
676 }
never executed: end of block
0
677 return oldcentralwidget;
never executed: return oldcentralwidget;
0
678}-
679-
680#ifndef QT_NO_DOCKWIDGET-
681/*!-
682 Sets the given dock widget \a area to occupy the specified \a-
683 corner.-
684-
685 \sa corner()-
686*/-
687void QMainWindow::setCorner(Qt::Corner corner, Qt::DockWidgetArea area)-
688{-
689 bool valid = false;-
690 switch (corner) {-
691 case Qt::TopLeftCorner:
never executed: case Qt::TopLeftCorner:
0
692 valid = (area == Qt::TopDockWidgetArea || area == Qt::LeftDockWidgetArea);
area == Qt::TopDockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
area == Qt::LeftDockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
693 break;
never executed: break;
0
694 case Qt::TopRightCorner:
never executed: case Qt::TopRightCorner:
0
695 valid = (area == Qt::TopDockWidgetArea || area == Qt::RightDockWidgetArea);
area == Qt::TopDockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
area == Qt::Ri...DockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
696 break;
never executed: break;
0
697 case Qt::BottomLeftCorner:
never executed: case Qt::BottomLeftCorner:
0
698 valid = (area == Qt::BottomDockWidgetArea || area == Qt::LeftDockWidgetArea);
area == Qt::Bo...DockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
area == Qt::LeftDockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
699 break;
never executed: break;
0
700 case Qt::BottomRightCorner:
never executed: case Qt::BottomRightCorner:
0
701 valid = (area == Qt::BottomDockWidgetArea || area == Qt::RightDockWidgetArea);
area == Qt::Bo...DockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
area == Qt::Ri...DockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
702 break;
never executed: break;
0
703 }-
704 if (Q_UNLIKELY(!valid))
__builtin_expe...valid), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
705 qWarning("QMainWindow::setCorner(): 'area' is not valid for 'corner'");
never executed: QMessageLogger(__FILE__, 705, __PRETTY_FUNCTION__).warning("QMainWindow::setCorner(): 'area' is not valid for 'corner'");
0
706 else-
707 d_func()->layout->setCorner(corner, area);
never executed: d_func()->layout->setCorner(corner, area);
0
708}-
709-
710/*!-
711 Returns the dock widget area that occupies the specified \a-
712 corner.-
713-
714 \sa setCorner()-
715*/-
716Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const-
717{
never executed: return d_func()->layout->corner(corner);
return d_func()->layout->corner(corner); }
never executed: return d_func()->layout->corner(corner);
0
718#endif-
719-
720#ifndef QT_NO_TOOLBAR-
721-
722static bool checkToolBarArea(Qt::ToolBarArea area, const char *where)-
723{-
724 switch (area) {-
725 case Qt::LeftToolBarArea:
never executed: case Qt::LeftToolBarArea:
0
726 case Qt::RightToolBarArea:
never executed: case Qt::RightToolBarArea:
0
727 case Qt::TopToolBarArea:
never executed: case Qt::TopToolBarArea:
0
728 case Qt::BottomToolBarArea:
never executed: case Qt::BottomToolBarArea:
0
729 return true;
never executed: return true;
0
730 default:
never executed: default:
0
731 break;
never executed: break;
0
732 }-
733 qWarning("%s: invalid 'area' argument", where);-
734 return false;
never executed: return false;
0
735}-
736-
737/*!-
738 Adds a toolbar break to the given \a area after all the other-
739 objects that are present.-
740*/-
741void QMainWindow::addToolBarBreak(Qt::ToolBarArea area)-
742{-
743 if (!checkToolBarArea(area, "QMainWindow::addToolBarBreak"))
!checkToolBarA...ToolBarBreak")Description
TRUEnever evaluated
FALSEnever evaluated
0
744 return;
never executed: return;
0
745 d_func()->layout->addToolBarBreak(area);-
746}
never executed: end of block
0
747-
748/*!-
749 Inserts a toolbar break before the toolbar specified by \a before.-
750*/-
751void QMainWindow::insertToolBarBreak(QToolBar *before)-
752{
never executed: end of block
d_func()->layout->insertToolBarBreak(before); }
never executed: end of block
0
753-
754/*!-
755 Removes a toolbar break previously inserted before the toolbar specified by \a before.-
756*/-
757-
758void QMainWindow::removeToolBarBreak(QToolBar *before)-
759{-
760 Q_D(QMainWindow);-
761 d->layout->removeToolBarBreak(before);-
762}
never executed: end of block
0
763-
764/*!-
765 Adds the \a toolbar into the specified \a area in this main-
766 window. The \a toolbar is placed at the end of the current tool-
767 bar block (i.e. line). If the main window already manages \a toolbar-
768 then it will only move the toolbar to \a area.-
769-
770 \sa insertToolBar(), addToolBarBreak(), insertToolBarBreak()-
771*/-
772void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)-
773{-
774 if (!checkToolBarArea(area, "QMainWindow::addToolBar"))
!checkToolBarA...::addToolBar")Description
TRUEnever evaluated
FALSEnever evaluated
0
775 return;
never executed: return;
0
776-
777 Q_D(QMainWindow);-
778-
779 disconnect(this, SIGNAL(iconSizeChanged(QSize)),-
780 toolbar, SLOT(_q_updateIconSize(QSize)));-
781 disconnect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),-
782 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle)));-
783-
784 if(toolbar->d_func()->state && toolbar->d_func()->state->dragging) {
toolbar->d_func()->stateDescription
TRUEnever evaluated
FALSEnever evaluated
toolbar->d_fun...tate->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
785 //removing a toolbar which is dragging will cause crash-
786#ifndef QT_NO_DOCKWIDGET-
787 bool animated = isAnimated();-
788 setAnimated(false);-
789#endif-
790 toolbar->d_func()->endDrag();-
791#ifndef QT_NO_DOCKWIDGET-
792 setAnimated(animated);-
793#endif-
794 }
never executed: end of block
0
795-
796 if (!d->layout->usesHIToolBar(toolbar)) {
!d->layout->us...olBar(toolbar)Description
TRUEnever evaluated
FALSEnever evaluated
0
797 d->layout->removeWidget(toolbar);-
798 } else {
never executed: end of block
0
799 d->layout->removeToolBar(toolbar);-
800 }
never executed: end of block
0
801-
802 toolbar->d_func()->_q_updateIconSize(d->iconSize);-
803 toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle);-
804 connect(this, SIGNAL(iconSizeChanged(QSize)),-
805 toolbar, SLOT(_q_updateIconSize(QSize)));-
806 connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),-
807 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle)));-
808-
809 d->layout->addToolBar(area, toolbar);-
810}
never executed: end of block
0
811-
812/*! \overload-
813 Equivalent of calling addToolBar(Qt::TopToolBarArea, \a toolbar)-
814*/-
815void QMainWindow::addToolBar(QToolBar *toolbar)-
816{
never executed: end of block
addToolBar(Qt::TopToolBarArea, toolbar); }
never executed: end of block
0
817-
818/*!-
819 \overload-
820-
821 Creates a QToolBar object, setting its window title to \a title,-
822 and inserts it into the top toolbar area.-
823-
824 \sa setWindowTitle()-
825*/-
826QToolBar *QMainWindow::addToolBar(const QString &title)-
827{-
828 QToolBar *toolBar = new QToolBar(this);-
829 toolBar->setWindowTitle(title);-
830 addToolBar(toolBar);-
831 return toolBar;
never executed: return toolBar;
0
832}-
833-
834/*!-
835 Inserts the \a toolbar into the area occupied by the \a before toolbar-
836 so that it appears before it. For example, in normal left-to-right-
837 layout operation, this means that \a toolbar will appear to the left-
838 of the toolbar specified by \a before in a horizontal toolbar area.-
839-
840 \sa insertToolBarBreak(), addToolBar(), addToolBarBreak()-
841*/-
842void QMainWindow::insertToolBar(QToolBar *before, QToolBar *toolbar)-
843{-
844 Q_D(QMainWindow);-
845-
846 d->layout->removeToolBar(toolbar);-
847-
848 toolbar->d_func()->_q_updateIconSize(d->iconSize);-
849 toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle);-
850 connect(this, SIGNAL(iconSizeChanged(QSize)),-
851 toolbar, SLOT(_q_updateIconSize(QSize)));-
852 connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),-
853 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle)));-
854-
855 d->layout->insertToolBar(before, toolbar);-
856}
never executed: end of block
0
857-
858/*!-
859 Removes the \a toolbar from the main window layout and hides-
860 it. Note that the \a toolbar is \e not deleted.-
861*/-
862void QMainWindow::removeToolBar(QToolBar *toolbar)-
863{-
864 if (toolbar) {
toolbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
865 d_func()->layout->removeToolBar(toolbar);-
866 toolbar->hide();-
867 }
never executed: end of block
0
868}
never executed: end of block
0
869-
870/*!-
871 Returns the Qt::ToolBarArea for \a toolbar. If \a toolbar has not-
872 been added to the main window, this function returns \c-
873 Qt::NoToolBarArea.-
874-
875 \sa addToolBar(), addToolBarBreak(), Qt::ToolBarArea-
876*/-
877Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const-
878{
never executed: return d_func()->layout->toolBarArea(toolbar);
return d_func()->layout->toolBarArea(toolbar); }
never executed: return d_func()->layout->toolBarArea(toolbar);
0
879-
880/*!-
881-
882 Returns whether there is a toolbar-
883 break before the \a toolbar.-
884-
885 \sa addToolBarBreak(), insertToolBarBreak()-
886*/-
887bool QMainWindow::toolBarBreak(QToolBar *toolbar) const-
888{-
889 return d_func()->layout->toolBarBreak(toolbar);
never executed: return d_func()->layout->toolBarBreak(toolbar);
0
890}-
891-
892#endif // QT_NO_TOOLBAR-
893-
894#ifndef QT_NO_DOCKWIDGET-
895-
896/*! \property QMainWindow::animated-
897 \brief whether manipulating dock widgets and tool bars is animated-
898 \since 4.2-
899-
900 When a dock widget or tool bar is dragged over the-
901 main window, the main window adjusts its contents-
902 to indicate where the dock widget or tool bar will-
903 be docked if it is dropped. Setting this property-
904 causes QMainWindow to move its contents in a smooth-
905 animation. Clearing this property causes the contents-
906 to snap into their new positions.-
907-
908 By default, this property is set. It may be cleared if-
909 the main window contains widgets which are slow at resizing-
910 or repainting themselves.-
911-
912 Setting this property is identical to setting the AnimatedDocks-
913 option using setDockOptions().-
914*/-
915-
916bool QMainWindow::isAnimated() const-
917{-
918 Q_D(const QMainWindow);-
919 return d->layout->dockOptions & AnimatedDocks;
never executed: return d->layout->dockOptions & AnimatedDocks;
0
920}-
921-
922void QMainWindow::setAnimated(bool enabled)-
923{-
924 Q_D(QMainWindow);-
925-
926 DockOptions opts = d->layout->dockOptions;-
927 opts.setFlag(AnimatedDocks, enabled);-
928-
929 d->layout->setDockOptions(opts);-
930}
never executed: end of block
0
931-
932/*! \property QMainWindow::dockNestingEnabled-
933 \brief whether docks can be nested-
934 \since 4.2-
935-
936 If this property is \c false, dock areas can only contain a single row-
937 (horizontal or vertical) of dock widgets. If this property is \c true,-
938 the area occupied by a dock widget can be split in either direction to contain-
939 more dock widgets.-
940-
941 Dock nesting is only necessary in applications that contain a lot of-
942 dock widgets. It gives the user greater freedom in organizing their-
943 main window. However, dock nesting leads to more complex-
944 (and less intuitive) behavior when a dock widget is dragged over the-
945 main window, since there are more ways in which a dropped dock widget-
946 may be placed in the dock area.-
947-
948 Setting this property is identical to setting the AllowNestedDocks option-
949 using setDockOptions().-
950*/-
951-
952bool QMainWindow::isDockNestingEnabled() const-
953{-
954 Q_D(const QMainWindow);-
955 return d->layout->dockOptions & AllowNestedDocks;
never executed: return d->layout->dockOptions & AllowNestedDocks;
0
956}-
957-
958void QMainWindow::setDockNestingEnabled(bool enabled)-
959{-
960 Q_D(QMainWindow);-
961-
962 DockOptions opts = d->layout->dockOptions;-
963 opts.setFlag(AllowNestedDocks, enabled);-
964-
965 d->layout->setDockOptions(opts);-
966}
never executed: end of block
0
967-
968#if 0-
969/*! \property QMainWindow::verticalTabsEnabled-
970 \brief whether left and right dock areas use vertical tabs-
971 \since 4.2-
972-
973 If this property is set to false, dock areas containing tabbed dock widgets-
974 display horizontal tabs, simmilar to Visual Studio.-
975-
976 If this property is set to true, then the right and left dock areas display vertical-
977 tabs, simmilar to KDevelop.-
978-
979 This property should be set before any dock widgets are added to the main window.-
980*/-
981-
982bool QMainWindow::verticalTabsEnabled() const-
983{-
984 return d_func()->layout->verticalTabsEnabled();-
985}-
986-
987void QMainWindow::setVerticalTabsEnabled(bool enabled)-
988{-
989 d_func()->layout->setVerticalTabsEnabled(enabled);-
990}-
991#endif-
992-
993static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where)-
994{-
995 switch (area) {-
996 case Qt::LeftDockWidgetArea:
never executed: case Qt::LeftDockWidgetArea:
0
997 case Qt::RightDockWidgetArea:
never executed: case Qt::RightDockWidgetArea:
0
998 case Qt::TopDockWidgetArea:
never executed: case Qt::TopDockWidgetArea:
0
999 case Qt::BottomDockWidgetArea:
never executed: case Qt::BottomDockWidgetArea:
0
1000 return true;
never executed: return true;
0
1001 default:
never executed: default:
0
1002 break;
never executed: break;
0
1003 }-
1004 qWarning("%s: invalid 'area' argument", where);-
1005 return false;
never executed: return false;
0
1006}-
1007-
1008#ifndef QT_NO_TABBAR-
1009/*!-
1010 \property QMainWindow::documentMode-
1011 \brief whether the tab bar for tabbed dockwidgets is set to document mode.-
1012 \since 4.5-
1013-
1014 The default is false.-
1015-
1016 \sa QTabBar::documentMode-
1017*/-
1018bool QMainWindow::documentMode() const-
1019{-
1020 return d_func()->layout->documentMode();
never executed: return d_func()->layout->documentMode();
0
1021}-
1022-
1023void QMainWindow::setDocumentMode(bool enabled)-
1024{-
1025 d_func()->layout->setDocumentMode(enabled);-
1026}
never executed: end of block
0
1027#endif // QT_NO_TABBAR-
1028-
1029#ifndef QT_NO_TABWIDGET-
1030/*!-
1031 \property QMainWindow::tabShape-
1032 \brief the tab shape used for tabbed dock widgets.-
1033 \since 4.5-
1034-
1035 The default is \l QTabWidget::Rounded.-
1036-
1037 \sa setTabPosition()-
1038*/-
1039QTabWidget::TabShape QMainWindow::tabShape() const-
1040{-
1041 return d_func()->layout->tabShape();
never executed: return d_func()->layout->tabShape();
0
1042}-
1043-
1044void QMainWindow::setTabShape(QTabWidget::TabShape tabShape)-
1045{-
1046 d_func()->layout->setTabShape(tabShape);-
1047}
never executed: end of block
0
1048-
1049/*!-
1050 \since 4.5-
1051-
1052 Returns the tab position for \a area.-
1053-
1054 \note The \l VerticalTabs dock option overrides the tab positions returned-
1055 by this function.-
1056-
1057 \sa setTabPosition(), tabShape()-
1058*/-
1059QTabWidget::TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area) const-
1060{-
1061 if (!checkDockWidgetArea(area, "QMainWindow::tabPosition"))
!checkDockWidg...:tabPosition")Description
TRUEnever evaluated
FALSEnever evaluated
0
1062 return QTabWidget::South;
never executed: return QTabWidget::South;
0
1063 return d_func()->layout->tabPosition(area);
never executed: return d_func()->layout->tabPosition(area);
0
1064}-
1065-
1066/*!-
1067 \since 4.5-
1068-
1069 Sets the tab position for the given dock widget \a areas to the specified-
1070 \a tabPosition. By default, all dock areas show their tabs at the bottom.-
1071-
1072 \note The \l VerticalTabs dock option overrides the tab positions set by-
1073 this method.-
1074-
1075 \sa tabPosition(), setTabShape()-
1076*/-
1077void QMainWindow::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition)-
1078{-
1079 d_func()->layout->setTabPosition(areas, tabPosition);-
1080}
never executed: end of block
0
1081#endif // QT_NO_TABWIDGET-
1082-
1083/*!-
1084 Adds the given \a dockwidget to the specified \a area.-
1085*/-
1086void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)-
1087{-
1088 if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget"))
!checkDockWidg...ddDockWidget")Description
TRUEnever evaluated
FALSEnever evaluated
0
1089 return;
never executed: return;
0
1090-
1091 Qt::Orientation orientation = Qt::Vertical;-
1092 switch (area) {-
1093 case Qt::TopDockWidgetArea:
never executed: case Qt::TopDockWidgetArea:
0
1094 case Qt::BottomDockWidgetArea:
never executed: case Qt::BottomDockWidgetArea:
0
1095 orientation = Qt::Horizontal;-
1096 break;
never executed: break;
0
1097 default:
never executed: default:
0
1098 break;
never executed: break;
0
1099 }-
1100 d_func()->layout->removeWidget(dockwidget); // in case it was already in here-
1101 addDockWidget(area, dockwidget, orientation);-
1102-
1103#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support-
1104 QMacAutoReleasePool pool;-
1105 extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp-
1106 if (qt_mac_is_macdrawer(dockwidget)) {-
1107 extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp-
1108 window()->createWinId();-
1109 dockwidget->window()->createWinId();-
1110 qt_mac_set_drawer_preferred_edge(dockwidget, area);-
1111 if (dockwidget->isVisible()) {-
1112 dockwidget->hide();-
1113 dockwidget->show();-
1114 }-
1115 }-
1116#endif-
1117}
never executed: end of block
0
1118-
1119/*!-
1120 Restores the state of \a dockwidget if it is created after the call-
1121 to restoreState(). Returns \c true if the state was restored; otherwise-
1122 returns \c false.-
1123-
1124 \sa restoreState(), saveState()-
1125*/-
1126-
1127bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget)-
1128{-
1129 return d_func()->layout->restoreDockWidget(dockwidget);
never executed: return d_func()->layout->restoreDockWidget(dockwidget);
0
1130}-
1131-
1132/*!-
1133 Adds \a dockwidget into the given \a area in the direction-
1134 specified by the \a orientation.-
1135*/-
1136void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,-
1137 Qt::Orientation orientation)-
1138{-
1139 if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget"))
!checkDockWidg...ddDockWidget")Description
TRUEnever evaluated
FALSEnever evaluated
0
1140 return;
never executed: return;
0
1141-
1142 // add a window to an area, placing done relative to the previous-
1143 d_func()->layout->addDockWidget(area, dockwidget, orientation);-
1144}
never executed: end of block
0
1145-
1146/*!-
1147 \fn void QMainWindow::splitDockWidget(QDockWidget *first, QDockWidget *second, Qt::Orientation orientation)-
1148-
1149 Splits the space covered by the \a first dock widget into two parts,-
1150 moves the \a first dock widget into the first part, and moves the-
1151 \a second dock widget into the second part.-
1152-
1153 The \a orientation specifies how the space is divided: A Qt::Horizontal-
1154 split places the second dock widget to the right of the first; a-
1155 Qt::Vertical split places the second dock widget below the first.-
1156-
1157 \e Note: if \a first is currently in a tabbed docked area, \a second will-
1158 be added as a new tab, not as a neighbor of \a first. This is because a-
1159 single tab can contain only one dock widget.-
1160-
1161 \e Note: The Qt::LayoutDirection influences the order of the dock widgets-
1162 in the two parts of the divided area. When right-to-left layout direction-
1163 is enabled, the placing of the dock widgets will be reversed.-
1164-
1165 \sa tabifyDockWidget(), addDockWidget(), removeDockWidget()-
1166*/-
1167void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,-
1168 Qt::Orientation orientation)-
1169{-
1170 d_func()->layout->splitDockWidget(after, dockwidget, orientation);-
1171}
never executed: end of block
0
1172-
1173/*!-
1174 \fn void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)-
1175-
1176 Moves \a second dock widget on top of \a first dock widget, creating a tabbed-
1177 docked area in the main window.-
1178-
1179 \sa tabifiedDockWidgets()-
1180*/-
1181void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)-
1182{-
1183 d_func()->layout->tabifyDockWidget(first, second);-
1184}
never executed: end of block
0
1185-
1186-
1187/*!-
1188 \fn QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const-
1189-
1190 Returns the dock widgets that are tabified together with \a dockwidget.-
1191-
1192 \since 4.5-
1193 \sa tabifyDockWidget()-
1194*/-
1195-
1196QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const-
1197{-
1198 QList<QDockWidget*> ret;-
1199#if defined(QT_NO_TABBAR)-
1200 Q_UNUSED(dockwidget);-
1201#else-
1202 const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget);-
1203 if (info && info->tabbed && info->tabBar) {
infoDescription
TRUEnever evaluated
FALSEnever evaluated
info->tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
info->tabBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1204 for(int i = 0; i < info->item_list.count(); ++i) {
i < info->item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1205 const QDockAreaLayoutItem &item = info->item_list.at(i);-
1206 if (item.widgetItem) {
item.widgetItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1207 if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) {
QDockWidget *d...tem->widget())Description
TRUEnever evaluated
FALSEnever evaluated
0
1208 if (dock != dockwidget) {
dock != dockwidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1209 ret += dock;-
1210 }
never executed: end of block
0
1211 }
never executed: end of block
0
1212 }
never executed: end of block
0
1213 }
never executed: end of block
0
1214 }
never executed: end of block
0
1215#endif-
1216 return ret;
never executed: return ret;
0
1217}-
1218-
1219-
1220/*!-
1221 Removes the \a dockwidget from the main window layout and hides-
1222 it. Note that the \a dockwidget is \e not deleted.-
1223*/-
1224void QMainWindow::removeDockWidget(QDockWidget *dockwidget)-
1225{-
1226 if (dockwidget) {
dockwidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1227 d_func()->layout->removeWidget(dockwidget);-
1228 dockwidget->hide();-
1229 }
never executed: end of block
0
1230}
never executed: end of block
0
1231-
1232/*!-
1233 Returns the Qt::DockWidgetArea for \a dockwidget. If \a dockwidget-
1234 has not been added to the main window, this function returns \c-
1235 Qt::NoDockWidgetArea.-
1236-
1237 \sa addDockWidget(), splitDockWidget(), Qt::DockWidgetArea-
1238*/-
1239Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const-
1240{
never executed: return d_func()->layout->dockWidgetArea(dockwidget);
return d_func()->layout->dockWidgetArea(dockwidget); }
never executed: return d_func()->layout->dockWidgetArea(dockwidget);
0
1241-
1242-
1243/*!-
1244 \since 5.6-
1245 Resizes the dock widgets in the list \a docks to the corresponding size in-
1246 pixels from the list \a sizes. If \a orientation is Qt::Horizontal, adjusts-
1247 the width, otherwise adjusts the height of the dock widgets.-
1248 The sizes will be adjusted such that the maximum and the minimum sizes are-
1249 respected and the QMainWindow itself will not be resized.-
1250 Any additional/missing space is distributed amongst the widgets according-
1251 to the relative weight of the sizes.-
1252-
1253 Example:-
1254 \code-
1255 resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);-
1256 \endcode-
1257 If the blue and the yellow widget are nested on the same level they will be-
1258 resized such that the yellowWidget is twice as big as the blueWidget-
1259-
1260 If some widgets are grouped in tabs, only one widget per group should be-
1261 specified. Widgets not in the list might be changed to repect the constraints.-
1262*/-
1263void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks,-
1264 const QList<int> &sizes, Qt::Orientation orientation)-
1265{-
1266 d_func()->layout->layoutState.dockAreaLayout.resizeDocks(docks, sizes, orientation);-
1267 d_func()->layout->invalidate();-
1268}
never executed: end of block
0
1269-
1270-
1271#endif // QT_NO_DOCKWIDGET-
1272-
1273/*!-
1274 Saves the current state of this mainwindow's toolbars and-
1275 dockwidgets. This includes the corner settings which can-
1276 be set with setCorner(). The \a version number is stored-
1277 as part of the data.-
1278-
1279 The \l{QObject::objectName}{objectName} property is used-
1280 to identify each QToolBar and QDockWidget. You should make sure-
1281 that this property is unique for each QToolBar and QDockWidget you-
1282 add to the QMainWindow-
1283-
1284 To restore the saved state, pass the return value and \a version-
1285 number to restoreState().-
1286-
1287 To save the geometry when the window closes, you can-
1288 implement a close event like this:-
1289-
1290 \snippet code/src_gui_widgets_qmainwindow.cpp 0-
1291-
1292 \sa restoreState(), QWidget::saveGeometry(), QWidget::restoreGeometry()-
1293*/-
1294QByteArray QMainWindow::saveState(int version) const-
1295{-
1296 QByteArray data;-
1297 QDataStream stream(&data, QIODevice::WriteOnly);-
1298 stream << QMainWindowLayout::VersionMarker;-
1299 stream << version;-
1300 d_func()->layout->saveState(stream);-
1301 return data;
never executed: return data;
0
1302}-
1303-
1304/*!-
1305 Restores the \a state of this mainwindow's toolbars and-
1306 dockwidgets. Also restores the corner settings too. The-
1307 \a version number is compared with that stored in \a state.-
1308 If they do not match, the mainwindow's state is left-
1309 unchanged, and this function returns \c false; otherwise, the state-
1310 is restored, and this function returns \c true.-
1311-
1312 To restore geometry saved using QSettings, you can use code like-
1313 this:-
1314-
1315 \snippet code/src_gui_widgets_qmainwindow.cpp 1-
1316-
1317 \sa saveState(), QWidget::saveGeometry(),-
1318 QWidget::restoreGeometry(), restoreDockWidget()-
1319*/-
1320bool QMainWindow::restoreState(const QByteArray &state, int version)-
1321{-
1322 if (state.isEmpty())
state.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1323 return false;
never executed: return false;
0
1324 QByteArray sd = state;-
1325 QDataStream stream(&sd, QIODevice::ReadOnly);-
1326 int marker, v;-
1327 stream >> marker;-
1328 stream >> v;-
1329 if (stream.status() != QDataStream::Ok || marker != QMainWindowLayout::VersionMarker || v != version)
stream.status(...DataStream::OkDescription
TRUEnever evaluated
FALSEnever evaluated
marker != QMai...:VersionMarkerDescription
TRUEnever evaluated
FALSEnever evaluated
v != versionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1330 return false;
never executed: return false;
0
1331 bool restored = d_func()->layout->restoreState(stream);-
1332 return restored;
never executed: return restored;
0
1333}-
1334-
1335#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)-
1336QCursor QMainWindowPrivate::separatorCursor(const QList<int> &path) const-
1337{-
1338 QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path);-
1339 Q_ASSERT(info != 0);-
1340 if (path.size() == 1) { // is this the "top-level" separator which separates a dock area
path.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1341 // from the central widget?-
1342 switch (path.first()) {-
1343 case QInternal::LeftDock:
never executed: case QInternal::LeftDock:
0
1344 case QInternal::RightDock:
never executed: case QInternal::RightDock:
0
1345 return Qt::SplitHCursor;
never executed: return Qt::SplitHCursor;
0
1346 case QInternal::TopDock:
never executed: case QInternal::TopDock:
0
1347 case QInternal::BottomDock:
never executed: case QInternal::BottomDock:
0
1348 return Qt::SplitVCursor;
never executed: return Qt::SplitVCursor;
0
1349 default:
never executed: default:
0
1350 break;
never executed: break;
0
1351 }-
1352 }-
1353-
1354 // no, it's a splitter inside a dock area, separating two dock widgets-
1355-
1356 return info->o == Qt::Horizontal
never executed: return info->o == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor;
0
1357 ? Qt::SplitHCursor : Qt::SplitVCursor;
never executed: return info->o == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor;
0
1358}-
1359-
1360void QMainWindowPrivate::adjustCursor(const QPoint &pos)-
1361{-
1362 Q_Q(QMainWindow);-
1363-
1364 hoverPos = pos;-
1365-
1366 if (pos == QPoint(0, 0)) {
pos == QPoint(0, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1367 if (!hoverSeparator.isEmpty())
!hoverSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1368 q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
never executed: q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
0
1369 hoverSeparator.clear();-
1370-
1371 if (cursorAdjusted) {
cursorAdjustedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1372 cursorAdjusted = false;-
1373 if (hasOldCursor)
hasOldCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1374 q->setCursor(oldCursor);
never executed: q->setCursor(oldCursor);
0
1375 else-
1376 q->unsetCursor();
never executed: q->unsetCursor();
0
1377 }-
1378 } else if (layout->movingSeparator.isEmpty()) { // Don't change cursor when moving separator
never executed: end of block
layout->moving...ator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1379 QList<int> pathToSeparator-
1380 = layout->layoutState.dockAreaLayout.findSeparator(pos);-
1381-
1382 if (pathToSeparator != hoverSeparator) {
pathToSeparato...hoverSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1383 if (!hoverSeparator.isEmpty())
!hoverSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1384 q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
never executed: q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
0
1385-
1386 hoverSeparator = pathToSeparator;-
1387-
1388 if (hoverSeparator.isEmpty()) {
hoverSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1389 if (cursorAdjusted) {
cursorAdjustedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1390 cursorAdjusted = false;-
1391 if (hasOldCursor)
hasOldCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1392 q->setCursor(oldCursor);
never executed: q->setCursor(oldCursor);
0
1393 else-
1394 q->unsetCursor();
never executed: q->unsetCursor();
0
1395 }-
1396 } else {
never executed: end of block
0
1397 q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));-
1398 if (!cursorAdjusted) {
!cursorAdjustedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1399 oldCursor = q->cursor();-
1400 hasOldCursor = q->testAttribute(Qt::WA_SetCursor);-
1401 }
never executed: end of block
0
1402 adjustedCursor = separatorCursor(hoverSeparator);-
1403 q->setCursor(adjustedCursor);-
1404 cursorAdjusted = true;-
1405 }
never executed: end of block
0
1406 }-
1407 }
never executed: end of block
0
1408}
never executed: end of block
0
1409#endif-
1410-
1411/*! \reimp */-
1412bool QMainWindow::event(QEvent *event)-
1413{-
1414 Q_D(QMainWindow);-
1415 switch (event->type()) {-
1416-
1417#ifndef QT_NO_DOCKWIDGET-
1418 case QEvent::Paint: {
never executed: case QEvent::Paint:
0
1419 QPainter p(this);-
1420 QRegion r = static_cast<QPaintEvent*>(event)->region();-
1421 d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos);-
1422 break;
never executed: break;
0
1423 }-
1424-
1425#ifndef QT_NO_CURSOR-
1426 case QEvent::HoverMove: {
never executed: case QEvent::HoverMove:
0
1427 d->adjustCursor(static_cast<QHoverEvent*>(event)->pos());-
1428 break;
never executed: break;
0
1429 }-
1430-
1431 // We don't want QWidget to call update() on the entire QMainWindow-
1432 // on HoverEnter and HoverLeave, hence accept the event (return true).-
1433 case QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
1434 return true;
never executed: return true;
0
1435 case QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
1436 d->adjustCursor(QPoint(0, 0));-
1437 return true;
never executed: return true;
0
1438 case QEvent::ShortcutOverride: // when a menu pops up
never executed: case QEvent::ShortcutOverride:
0
1439 d->adjustCursor(QPoint(0, 0));-
1440 break;
never executed: break;
0
1441#endif // QT_NO_CURSOR-
1442-
1443 case QEvent::MouseButtonPress: {
never executed: case QEvent::MouseButtonPress:
0
1444 QMouseEvent *e = static_cast<QMouseEvent*>(event);-
1445 if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) {
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
d->layout->sta...Move(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1446 // The click was on a separator, eat this event-
1447 e->accept();-
1448 return true;
never executed: return true;
0
1449 }-
1450 break;
never executed: break;
0
1451 }-
1452-
1453 case QEvent::MouseMove: {
never executed: case QEvent::MouseMove:
0
1454 QMouseEvent *e = static_cast<QMouseEvent*>(event);-
1455-
1456#ifndef QT_NO_CURSOR-
1457 d->adjustCursor(e->pos());-
1458#endif-
1459 if (e->buttons() & Qt::LeftButton) {
e->buttons() & Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1460 if (d->layout->separatorMove(e->pos())) {
d->layout->sep...Move(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1461 // We're moving a separator, eat this event-
1462 e->accept();-
1463 return true;
never executed: return true;
0
1464 }-
1465 }
never executed: end of block
0
1466-
1467 break;
never executed: break;
0
1468 }-
1469-
1470 case QEvent::MouseButtonRelease: {
never executed: case QEvent::MouseButtonRelease:
0
1471 QMouseEvent *e = static_cast<QMouseEvent*>(event);-
1472 if (d->layout->endSeparatorMove(e->pos())) {
d->layout->end...Move(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
1473 // We've released a separator, eat this event-
1474 e->accept();-
1475 return true;
never executed: return true;
0
1476 }-
1477 break;
never executed: break;
0
1478 }-
1479-
1480#endif-
1481-
1482#ifndef QT_NO_TOOLBAR-
1483 case QEvent::ToolBarChange: {
never executed: case QEvent::ToolBarChange:
0
1484 d->layout->toggleToolBarsVisible();-
1485 return true;
never executed: return true;
0
1486 }-
1487#endif-
1488-
1489#ifndef QT_NO_STATUSTIP-
1490 case QEvent::StatusTip:
never executed: case QEvent::StatusTip:
0
1491#ifndef QT_NO_STATUSBAR-
1492 if (QStatusBar *sb = d->layout->statusBar())
QStatusBar *sb...t->statusBar()Description
TRUEnever evaluated
FALSEnever evaluated
0
1493 sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip());
never executed: sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip());
0
1494 else-
1495#endif-
1496 static_cast<QStatusTipEvent*>(event)->ignore();
never executed: static_cast<QStatusTipEvent*>(event)->ignore();
0
1497 return true;
never executed: return true;
0
1498#endif // QT_NO_STATUSTIP-
1499-
1500 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1501#ifndef QT_NO_DOCKWIDGET-
1502 d->layout->layoutState.dockAreaLayout.styleChangedEvent();-
1503#endif-
1504 if (!d->explicitIconSize)
!d->explicitIconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1505 setIconSize(QSize());
never executed: setIconSize(QSize());
0
1506 break;
never executed: break;
0
1507#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1508 case QEvent::Show:-
1509 if (unifiedTitleAndToolBarOnMac())-
1510 d->layout->syncUnifiedToolbarVisibility();-
1511 d->layout->blockVisiblityCheck = false;-
1512 break;-
1513 case QEvent::WindowStateChange:-
1514 {-
1515 if (isHidden()) {-
1516 // We are coming out of a minimize, leave things as is.-
1517 d->layout->blockVisiblityCheck = true;-
1518 }-
1519 // We need to update the HIToolbar status when we go out of or into fullscreen.-
1520 QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event);-
1521 if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) {-
1522 d->layout->updateHIToolBarStatus();-
1523 }-
1524 }-
1525 break;-
1526#endif // Q_DEAD_CODE_FROM_QT4_MAC-
1527#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)-
1528 case QEvent::CursorChange:
never executed: case QEvent::CursorChange:
0
1529 // CursorChange events are triggered as mouse moves to new widgets even-
1530 // if the cursor doesn't actually change, so do not change oldCursor if-
1531 // the "changed" cursor has same shape as adjusted cursor.-
1532 if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) {
d->cursorAdjustedDescription
TRUEnever evaluated
FALSEnever evaluated
d->adjustedCur...rsor().shape()Description
TRUEnever evaluated
FALSEnever evaluated
0
1533 d->oldCursor = cursor();-
1534 d->hasOldCursor = testAttribute(Qt::WA_SetCursor);-
1535-
1536 // Ensure our adjusted cursor stays visible-
1537 setCursor(d->adjustedCursor);-
1538 }
never executed: end of block
0
1539 break;
never executed: break;
0
1540#endif-
1541 default:
never executed: default:
0
1542 break;
never executed: break;
0
1543 }-
1544-
1545 return QWidget::event(event);
never executed: return QWidget::event(event);
0
1546}-
1547-
1548#ifndef QT_NO_TOOLBAR-
1549-
1550/*!-
1551 \property QMainWindow::unifiedTitleAndToolBarOnMac-
1552 \brief whether the window uses the unified title and toolbar look on \macos-
1553-
1554 Note that the Qt 5 implementation has several limitations compared to Qt 4:-
1555 \list-
1556 \li Use in windows with OpenGL content is not supported. This includes QGLWidget and QOpenGLWidget.-
1557 \li Using dockable or movable toolbars may result in painting errors and is not recommended-
1558 \endlist-
1559-
1560 \since 5.2-
1561*/-
1562void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)-
1563{-
1564#ifdef Q_OS_OSX-
1565 Q_D(QMainWindow);-
1566 if (isWindow()) {-
1567 d->useUnifiedToolBar = set;-
1568 createWinId();-
1569-
1570 QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();-
1571 QPlatformNativeInterface::NativeResourceForIntegrationFunction function =-
1572 nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled");-
1573 if (!function)-
1574 return; // Not Cocoa platform plugin.-
1575-
1576 typedef void (*SetContentBorderEnabledFunction)(QWindow *window, bool enable);-
1577 (reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set);-
1578 update();-
1579 }-
1580#endif-
1581-
1582#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1583 Q_D(QMainWindow);-
1584 if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3)-
1585 return;-
1586-
1587 d->useHIToolBar = set;-
1588 createWinId(); // We need the hiview for down below.-
1589-
1590 // Activate the unified toolbar with the raster engine.-
1591 if (windowSurface() && set) {-
1592 d->layout->unifiedSurface = new QUnifiedToolbarSurface(this);-
1593 }-
1594-
1595 d->layout->updateHIToolBarStatus();-
1596-
1597 // Deactivate the unified toolbar with the raster engine.-
1598 if (windowSurface() && !set) {-
1599 if (d->layout->unifiedSurface) {-
1600 delete d->layout->unifiedSurface;-
1601 d->layout->unifiedSurface = 0;-
1602 }-
1603 }-
1604-
1605 // Enabling the unified toolbar clears the opaque size grip setting, update it.-
1606 d->macUpdateOpaqueSizeGrip();-
1607#else-
1608 Q_UNUSED(set)-
1609#endif-
1610}
never executed: end of block
0
1611-
1612bool QMainWindow::unifiedTitleAndToolBarOnMac() const-
1613{-
1614#ifdef Q_OS_OSX-
1615 return d_func()->useUnifiedToolBar;-
1616#endif-
1617#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1618 return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint);-
1619#endif-
1620 return false;
never executed: return false;
0
1621}-
1622-
1623#endif // QT_NO_TOOLBAR-
1624-
1625/*!-
1626 \internal-
1627*/-
1628bool QMainWindow::isSeparator(const QPoint &pos) const-
1629{-
1630#ifndef QT_NO_DOCKWIDGET-
1631 Q_D(const QMainWindow);-
1632 return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty();
never executed: return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty();
0
1633#else-
1634 Q_UNUSED(pos);-
1635 return false;-
1636#endif-
1637}-
1638-
1639#ifndef QT_NO_CONTEXTMENU-
1640/*!-
1641 \reimp-
1642*/-
1643void QMainWindow::contextMenuEvent(QContextMenuEvent *event)-
1644{-
1645 event->ignore();-
1646 // only show the context menu for direct QDockWidget and QToolBar-
1647 // children and for the menu bar as well-
1648 QWidget *child = childAt(event->pos());-
1649 while (child && child != this) {
childDescription
TRUEnever evaluated
FALSEnever evaluated
child != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1650#ifndef QT_NO_MENUBAR-
1651 if (QMenuBar *mb = qobject_cast<QMenuBar *>(child)) {
QMenuBar *mb =...uBar *>(child)Description
TRUEnever evaluated
FALSEnever evaluated
0
1652 if (mb->parentWidget() != this)
mb->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1653 return;
never executed: return;
0
1654 break;
never executed: break;
0
1655 }-
1656#endif-
1657#ifndef QT_NO_DOCKWIDGET-
1658 if (QDockWidget *dw = qobject_cast<QDockWidget *>(child)) {
QDockWidget *d...dget *>(child)Description
TRUEnever evaluated
FALSEnever evaluated
0
1659 if (dw->parentWidget() != this)
dw->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1660 return;
never executed: return;
0
1661 if (dw->widget()
dw->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1662 && dw->widget()->geometry().contains(child->mapFrom(this, event->pos()))) {
dw->widget()->...event->pos()))Description
TRUEnever evaluated
FALSEnever evaluated
0
1663 // ignore the event if the mouse is over the QDockWidget contents-
1664 return;
never executed: return;
0
1665 }-
1666 break;
never executed: break;
0
1667 }-
1668#endif // QT_NO_DOCKWIDGET-
1669#ifndef QT_NO_TOOLBAR-
1670 if (QToolBar *tb = qobject_cast<QToolBar *>(child)) {
QToolBar *tb =...lBar *>(child)Description
TRUEnever evaluated
FALSEnever evaluated
0
1671 if (tb->parentWidget() != this)
tb->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1672 return;
never executed: return;
0
1673 break;
never executed: break;
0
1674 }-
1675#endif-
1676 child = child->parentWidget();-
1677 }
never executed: end of block
0
1678 if (child == this)
child == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1679 return;
never executed: return;
0
1680-
1681#ifndef QT_NO_MENU-
1682 QMenu *popup = createPopupMenu();-
1683 if (popup) {
popupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1684 if (!popup->isEmpty()) {
!popup->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1685 popup->setAttribute(Qt::WA_DeleteOnClose);-
1686 popup->popup(event->globalPos());-
1687 event->accept();-
1688 } else {
never executed: end of block
0
1689 delete popup;-
1690 }
never executed: end of block
0
1691 }-
1692#endif-
1693}
never executed: end of block
0
1694#endif // QT_NO_CONTEXTMENU-
1695-
1696#ifndef QT_NO_MENU-
1697/*!-
1698 Returns a popup menu containing checkable entries for the toolbars and-
1699 dock widgets present in the main window. If there are no toolbars and-
1700 dock widgets present, this function returns a null pointer.-
1701-
1702 By default, this function is called by the main window when the user-
1703 activates a context menu, typically by right-clicking on a toolbar or a dock-
1704 widget.-
1705-
1706 If you want to create a custom popup menu, reimplement this function and-
1707 return a newly-created popup menu. Ownership of the popup menu is transferred-
1708 to the caller.-
1709-
1710 \sa addDockWidget(), addToolBar(), menuBar()-
1711*/-
1712QMenu *QMainWindow::createPopupMenu()-
1713{-
1714 Q_D(QMainWindow);-
1715 QMenu *menu = 0;-
1716#ifndef QT_NO_DOCKWIDGET-
1717 QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>();-
1718 if (dockwidgets.size()) {
dockwidgets.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1719 menu = new QMenu(this);-
1720 for (int i = 0; i < dockwidgets.size(); ++i) {
i < dockwidgets.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1721 QDockWidget *dockWidget = dockwidgets.at(i);-
1722 // filter to find out if we own this QDockWidget-
1723 if (dockWidget->parentWidget() == this) {
dockWidget->pa...dget() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1724 if (d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty())
d->layout->lay...get).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1725 continue;
never executed: continue;
0
1726 } else if (QDockWidgetGroupWindow *dwgw =
never executed: end of block
QDockWidgetGro...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
1727 qobject_cast<QDockWidgetGroupWindow *>(dockWidget->parentWidget())) {
QDockWidgetGro...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
1728 if (dwgw->parentWidget() != this)
dwgw->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1729 continue;
never executed: continue;
0
1730 if (dwgw->layoutInfo()->indexOf(dockWidget).isEmpty())
dwgw->layoutIn...get).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1731 continue;
never executed: continue;
0
1732 } else {
never executed: end of block
0
1733 continue;
never executed: continue;
0
1734 }-
1735 menu->addAction(dockwidgets.at(i)->toggleViewAction());-
1736 }
never executed: end of block
0
1737 menu->addSeparator();-
1738 }
never executed: end of block
0
1739#endif // QT_NO_DOCKWIDGET-
1740#ifndef QT_NO_TOOLBAR-
1741 QList<QToolBar *> toolbars = findChildren<QToolBar *>();-
1742 if (toolbars.size()) {
toolbars.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1743 if (!menu)
!menuDescription
TRUEnever evaluated
FALSEnever evaluated
0
1744 menu = new QMenu(this);
never executed: menu = new QMenu(this);
0
1745 for (int i = 0; i < toolbars.size(); ++i) {
i < toolbars.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1746 QToolBar *toolBar = toolbars.at(i);-
1747 if (toolBar->parentWidget() == this
toolBar->paren...dget() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1748 && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) {
(!d->layout->l...ar).isEmpty())Description
TRUEnever evaluated
FALSEnever evaluated
0
1749 menu->addAction(toolbars.at(i)->toggleViewAction());-
1750 }
never executed: end of block
0
1751 }
never executed: end of block
0
1752 }
never executed: end of block
0
1753#endif-
1754 Q_UNUSED(d);-
1755 return menu;
never executed: return menu;
0
1756}-
1757#endif // QT_NO_MENU-
1758-
1759QT_END_NAMESPACE-
1760-
1761#include "moc_qmainwindow.cpp"-
1762-
1763#endif // QT_NO_MAINWINDOW-
Source codeSwitch to Preprocessed file

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