7#if QT_CONFIG(dockwidget)
19#if QT_CONFIG(rubberband)
27#if QT_CONFIG(draganddrop)
31#if QT_CONFIG(statusbar)
43#ifndef QT_NO_DEBUG_STREAM
48#include <private/qmenu_p.h>
49#include <private/qapplication_p.h>
50#include <private/qlayoutengine_p.h>
51#include <private/qwidgetresizehandler_p.h>
53#include <QScopedValueRollback>
65#if QT_CONFIG(dockwidget) && !defined(QT_NO_DEBUG_STREAM)
71 qout << indent <<
"QDockAreaLayoutItem: "
76 if (
item.widgetItem !=
nullptr) {
77 qout << indent <<
"widget: "
78 <<
item.widgetItem->widget()->metaObject()->className()
79 <<
" \"" <<
item.widgetItem->widget()->windowTitle() <<
"\"\n";
80 }
else if (
item.subinfo !=
nullptr) {
81 qout << indent <<
"subinfo:\n";
82 dumpLayout(
qout, *
item.subinfo, indent +
" "_L1);
83 }
else if (
item.placeHolderItem !=
nullptr) {
85 qout << indent <<
"placeHolder: "
89 <<
" objectName:" <<
item.placeHolderItem->objectName
90 <<
" hidden:" <<
item.placeHolderItem->hidden
92 <<
" rect:" <<
r.
x() <<
',' <<
r.y() <<
' '
93 <<
r.width() <<
'x' <<
r.height() <<
'\n';
100 qout << indent <<
"QDockAreaLayoutInfo: "
101 <<
layout.rect.left() <<
','
102 <<
layout.rect.top() <<
' '
103 <<
layout.rect.width() <<
'x'
105 <<
" min size: " << minSize.
width() <<
',' << minSize.
height()
108 <<
" tabbed:" <<
layout.tabbed
109 <<
" tbshape:" <<
layout.tabBarShape
115 for (
int i = 0;
i <
layout.item_list.size(); ++
i) {
116 qout << indent <<
"Item: " <<
i <<
'\n';
117 dumpLayout(
qout,
layout.item_list.at(
i), indent +
" "_L1);
123 qout <<
"QDockAreaLayout: "
124 <<
layout.rect.left() <<
','
125 <<
layout.rect.top() <<
' '
126 <<
layout.rect.width() <<
'x'
127 <<
layout.rect.height() <<
'\n';
129 qout <<
"TopDockArea:\n";
131 qout <<
"LeftDockArea:\n";
133 qout <<
"RightDockArea:\n";
135 qout <<
"BottomDockArea:\n";
160 const auto &
list =
layout->layoutState.dockAreaLayout.docks[
i].item_list;
163 qDebug() << function << comment <<
"Dock" <<
i <<
list;
166#define DUMP(comment) dumpItemLists(this, __FUNCTION__, comment)
205#if QT_CONFIG(dockwidget)
206class QDockWidgetGroupLayout :
public QLayout,
211 QDockWidgetGroupLayout(QDockWidgetGroupWindow* parent) :
QLayout(parent) {
215 ~QDockWidgetGroupLayout() {
216 layoutState.deleteAllLayoutItems();
220 int count()
const override {
return 0; }
224 return layoutState.itemAt(&
x,
index);
230 if (savedState.rect.isValid() &&
ret->widget()) {
232 QList<int>
path = savedState.indexOf(
ret->widget());
234 savedState.remove(
path);
236 path = layoutState.indexOf(
ret->widget());
238 layoutState.remove(
path);
242 QSize sizeHint()
const override
244 int fw = frameWidth();
245 return layoutState.sizeHint() +
QSize(fw, fw);
247 QSize minimumSize()
const override
249 int fw = frameWidth();
250 return layoutState.minimumSize() +
QSize(fw, fw);
252 QSize maximumSize()
const override
254 int fw = frameWidth();
255 return layoutState.maximumSize() +
QSize(fw, fw);
257 void setGeometry(
const QRect&
r)
override
259 groupWindow()->destroyOrHideIfEmpty();
263 int fw = frameWidth();
265 li->reparentWidgets(parentWidget());
267 li->rect =
r.adjusted(fw, fw, -fw, -fw);
270 if (savedState.rect.isValid())
271 savedState.rect = li->rect;
277 bool nativeWindowDeco()
const
279 return groupWindow()->hasNativeDecos();
282 int frameWidth()
const
284 return nativeWindowDeco() ? 0 :
288 QDockWidgetGroupWindow *groupWindow()
const
290 return static_cast<QDockWidgetGroupWindow *
>(parent());
297bool QDockWidgetGroupWindow::event(
QEvent *e)
299 auto lay =
static_cast<QDockWidgetGroupLayout *
>(
layout());
300 if (lay && lay->windowEvent(e))
336 destroyOrHideIfEmpty();
339 updateCurrentGapRect();
348void QDockWidgetGroupWindow::paintEvent(
QPaintEvent *)
350 QDockWidgetGroupLayout *lay =
static_cast<QDockWidgetGroupLayout *
>(
layout());
351 bool nativeDeco = lay->nativeWindowDeco();
363 return static_cast<QDockWidgetGroupLayout *
>(
layout())->dockAreaLayoutInfo();
379 bool isSingle =
false;
380 for (
const auto &
item :
info->item_list) {
383 if (
next || isSingle)
387 else if (
item.widgetItem)
400QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget()
const
406 if (
info->tabBar &&
info->tabBar->currentIndex() >= 0) {
407 int i =
info->tabIndexToListIndex(
info->tabBar->currentIndex());
411 dw = qobject_cast<QDockWidget *>(
item.widgetItem->widget());
415 for (
int i = 0; !dw &&
i <
info->item_list.size(); ++
i) {
419 if (!
item.widgetItem)
421 dw = qobject_cast<QDockWidget *>(
item.widgetItem->widget());
432void QDockWidgetGroupWindow::destroyOrHideIfEmpty()
435 if (!
info->isEmpty()) {
440 if (!
info->item_list.isEmpty()) {
446 const auto dockWidgetsList = dockWidgets();
448 const bool wasFloating = dw->isFloating();
449 const bool wasHidden = dw->isHidden();
450 dw->setParent(parentWidget());
451 qCDebug(lcQpaDockWidgets) <<
"Reparented:" << dw <<
"to" << parentWidget() <<
"by" <<
this;
453 dw->setFloating(
true);
462 qCDebug(lcQpaDockWidgets) <<
"Redocked to Mainwindow:" <<
area << dw <<
"by" <<
this;
475bool QDockWidgetGroupWindow::hasVisibleDockWidgets()
const
478 for (
auto child : children) {
492void QDockWidgetGroupWindow::adjustFlags()
494 Qt::WindowFlags oldFlags = windowFlags();
495 Qt::WindowFlags
flags = oldFlags;
505 }
else if (
static_cast<QDockWidgetGroupLayout *
>(
layout())->nativeWindowDeco()) {
514 if (oldFlags !=
flags) {
517 setWindowFlags(
flags);
523 if (lostNativeDecos) {
524 QRect newGeometry = geometry();
526 const int bottomFrame = geometry().top() -
frameGeometry().top();
528 setGeometry(newGeometry);
529 }
else if (gainedNativeDecos && m_removedFrameSize.isValid()) {
531 r.adjust(-m_removedFrameSize.width() / 2, 0,
532 -m_removedFrameSize.width() / 2, -m_removedFrameSize.height());
534 m_removedFrameSize =
QSize();
537 setVisible(hasVisibleDockWidgets());
541 setWindowTitle(titleBarOf->windowTitle());
542 setWindowIcon(titleBarOf->windowIcon());
545bool QDockWidgetGroupWindow::hasNativeDecos()
const
555 return dw->titleBarWidget() ==
nullptr;
568bool QDockWidgetGroupWindow::hover(
QLayoutItem *widgetItem,
const QPoint &mousePos)
572 savedState = *layoutInfo();
574 QMainWindow::DockOptions opts =
static_cast<QMainWindow *
>(parentWidget())->dockOptions();
576 bool nestingEnabled =
579#if !QT_CONFIG(tabbar)
583 if (
auto group = qobject_cast<QDockWidgetGroupWindow *>(widgetItem->
widget())) {
584 if (!
group->tabLayoutInfo())
596 auto newGapPos =
newState.gapIndex(mousePos, nestingEnabled, tabMode);
601 if (newGapPos == currentGapPos ||
newState.hasGapItem(newGapPos))
604 currentGapPos = newGapPos;
605 newState.insertGap(currentGapPos, widgetItem);
607 *layoutInfo() = std::move(
newState);
608 updateCurrentGapRect();
613void QDockWidgetGroupWindow::updateCurrentGapRect()
615 if (!currentGapPos.isEmpty())
616 currentGapRect = layoutInfo()->info(currentGapPos)->itemRect(currentGapPos.last(),
true);
622void QDockWidgetGroupWindow::restore()
626 *layoutInfo() = savedState;
629 currentGapRect =
QRect();
630 currentGapPos.clear();
632 layoutInfo()->fitItems();
633 layoutInfo()->apply(
static_cast<QMainWindow *
>(parentWidget())->dockOptions()
640void QDockWidgetGroupWindow::apply()
642 static_cast<QDockWidgetGroupLayout *
>(
layout())->savedState.
clear();
643 currentGapRect =
QRect();
644 layoutInfo()->plug(currentGapPos);
645 currentGapPos.clear();
647 layoutInfo()->apply(
false);
652 switch (
event->type()) {
656 destroyIfSingleItemLeft();
673 switch (
event->type()) {
694void QDockWidgetGroupWindow::destroyIfSingleItemLeft()
696 const auto &dockWidgets = this->dockWidgets();
699 if (dockWidgets.count() != 1)
702 auto *lastDockWidget = dockWidgets.at(0);
707 if (layoutInfo()->
indexOf(lastDockWidget).isEmpty())
710 auto *
mainWindow = qobject_cast<QMainWindow *>(parentWidget());
715 lastDockWidget->setGeometry(geometry());
719 QDockAreaLayoutInfo &parentInfo = mwLayout->layoutState.dockAreaLayout.docks[layoutInfo()->dockPos];
722 reparent(lastDockWidget);
725 layoutInfo()->item_list.clear();
728 parentInfo.remove(
this);
729 destroyOrHideIfEmpty();
738 auto *
mainWindow = qobject_cast<QMainWindow *>(parentWidget());
742 QDockAreaLayoutInfo &parentInfo = mwLayout->layoutState.dockAreaLayout.docks[layoutInfo()->dockPos];
763 toolBarAreaLayout(
win),
780#if QT_CONFIG(dockwidget)
781 result = dockAreaLayout.sizeHint();
787#if QT_CONFIG(toolbar)
798#if QT_CONFIG(dockwidget)
799 result = dockAreaLayout.minimumSize();
805#if QT_CONFIG(toolbar)
823#if QT_CONFIG(dockwidget)
824 size = dockAreaLayout.minimumStableSize();
827#if QT_CONFIG(toolbar)
839#if QT_CONFIG(toolbar)
840 toolBarAreaLayout.apply(animated);
843#if QT_CONFIG(dockwidget)
845 dockAreaLayout.apply(animated);
858#if !QT_CONFIG(toolbar)
861 toolBarAreaLayout.rect =
rect;
862 r = toolBarAreaLayout.fitLayout();
865#if QT_CONFIG(dockwidget)
866 dockAreaLayout.rect =
r;
867 dockAreaLayout.fitLayout();
875#if QT_CONFIG(toolbar)
876 toolBarAreaLayout.deleteAllLayoutItems();
879#if QT_CONFIG(dockwidget)
880 dockAreaLayout.deleteAllLayoutItems();
886#if QT_CONFIG(dockwidget)
887 delete dockAreaLayout.centralWidgetItem;
888 dockAreaLayout.centralWidgetItem =
nullptr;
897#if QT_CONFIG(toolbar)
902#if QT_CONFIG(dockwidget)
915#if QT_CONFIG(toolbar)
920#if QT_CONFIG(dockwidget)
938#if QT_CONFIG(toolbar)
941 result = toolBarAreaLayout.indexOf(toolBar);
948#if QT_CONFIG(dockwidget)
950 if (qobject_cast<QDockWidget *>(
widget) || qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
963#if QT_CONFIG(dockwidget)
964 if (dockAreaLayout.centralWidgetItem !=
nullptr && dockAreaLayout.centralWidgetItem->widget() ==
widget)
966 if (!dockAreaLayout.indexOf(
widget).isEmpty())
973#if QT_CONFIG(toolbar)
974 if (!toolBarAreaLayout.indexOf(
widget).isEmpty())
989#if QT_CONFIG(dockwidget)
990 dockAreaLayout.centralWidgetItem =
item;
1000#if QT_CONFIG(dockwidget)
1001 item = dockAreaLayout.centralWidgetItem;
1006 if (
item !=
nullptr)
1007 return item->widget();
1016#if QT_CONFIG(toolbar)
1018 if (qobject_cast<QToolBar*>(
widget) !=
nullptr) {
1019 result = toolBarAreaLayout.gapIndex(
pos);
1026#if QT_CONFIG(dockwidget)
1028 if (qobject_cast<QDockWidget *>(
widget) !=
nullptr
1029 || qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
1030 bool disallowTabs =
false;
1031#if QT_CONFIG(tabbar)
1032 if (
auto *
group = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
1033 if (!
group->tabLayoutInfo())
1034 disallowTabs =
true;
1037 result = dockAreaLayout.gapIndex(
pos, disallowTabs);
1052 int i =
path.first();
1054#if QT_CONFIG(toolbar)
1056 Q_ASSERT(qobject_cast<QToolBar*>(
item->widget()) !=
nullptr);
1057 return toolBarAreaLayout.insertGap(
path.mid(1),
item);
1061#if QT_CONFIG(dockwidget)
1063 Q_ASSERT(qobject_cast<QDockWidget*>(
item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(
item->widget()));
1064 return dockAreaLayout.insertGap(
path.mid(1),
item);
1073 int i =
path.first();
1075#if QT_CONFIG(toolbar)
1077 toolBarAreaLayout.remove(
path.mid(1));
1080#if QT_CONFIG(dockwidget)
1082 dockAreaLayout.remove(
path.mid(1));
1088#if QT_CONFIG(toolbar)
1089 toolBarAreaLayout.remove(
item);
1092#if QT_CONFIG(dockwidget)
1096 if (!
path.isEmpty())
1097 dockAreaLayout.remove(
path);
1104#if QT_CONFIG(toolbar)
1105 toolBarAreaLayout.clear();
1108#if QT_CONFIG(dockwidget)
1109 dockAreaLayout.clear();
1124 int i =
path.first();
1126#if QT_CONFIG(toolbar)
1130 return tbItem->widgetItem;
1134#if QT_CONFIG(dockwidget)
1136 return dockAreaLayout.item(
path.mid(1)).widgetItem;
1144 int i =
path.first();
1146#if QT_CONFIG(toolbar)
1148 return toolBarAreaLayout.itemRect(
path.mid(1));
1151#if QT_CONFIG(dockwidget)
1153 return dockAreaLayout.itemRect(
path.mid(1));
1161 int i =
path.first();
1163#if QT_CONFIG(toolbar)
1165 return toolBarAreaLayout.itemRect(
path.mid(1));
1168#if QT_CONFIG(dockwidget)
1170 return dockAreaLayout.gapRect(
path.mid(1));
1178 int i =
path.first();
1180#if QT_CONFIG(toolbar)
1182 return toolBarAreaLayout.plug(
path.mid(1));
1185#if QT_CONFIG(dockwidget)
1187 return dockAreaLayout.plug(
path.mid(1));
1195 int i =
path.first();
1197#if !QT_CONFIG(toolbar)
1201 return toolBarAreaLayout.unplug(
path.mid(1),
other ? &
other->toolBarAreaLayout :
nullptr);
1204#if QT_CONFIG(dockwidget)
1206 return dockAreaLayout.unplug(
path.mid(1));
1214#if QT_CONFIG(dockwidget)
1215 dockAreaLayout.saveState(
stream);
1216#if QT_CONFIG(tabbar)
1217 const QList<QDockWidgetGroupWindow *> floatingTabs =
1220 for (QDockWidgetGroupWindow *floating : floatingTabs) {
1221 if (floating->layoutInfo()->isEmpty())
1224 floating->layoutInfo()->saveState(
stream);
1228#if QT_CONFIG(toolbar)
1229 toolBarAreaLayout.saveState(
stream);
1233template <
typename T>
1240 if (T
t = qobject_cast<T>(
list[
i])) {
1248#if QT_CONFIG(dockwidget)
1249static QList<QDockWidget*> allMyDockWidgets(
const QWidget *mainWindow)
1251 QList<QDockWidget*>
result;
1253 if (
auto *dw = qobject_cast<QDockWidget*>(
c)) {
1255 }
else if (
auto *gw = qobject_cast<QDockWidgetGroupWindow*>(
c)) {
1256 for (
QObject *
c : gw->children()) {
1257 if (
auto *dw = qobject_cast<QDockWidget*>(
c))
1270 while (!
stream.atEnd()) {
1275#if QT_CONFIG(toolbar)
1279 QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(
mainWindow);
1280 if (!toolBarAreaLayout.restoreState(
stream, toolBars,
marker,
true )) {
1287#if QT_CONFIG(dockwidget)
1290 const auto dockWidgets = allMyDockWidgets(
mainWindow);
1291 if (!dockAreaLayout.restoreState(
stream, dockWidgets,
true )) {
1296#if QT_CONFIG(tabbar)
1302 auto dockWidgets = allMyDockWidgets(
mainWindow);
1303 if (!
info.restoreState(
stream, dockWidgets,
true ))
1324 while(!_stream.atEnd()) {
1338 stream.setVersion(_stream.version());
1340 while (!
stream.atEnd()) {
1345#if QT_CONFIG(dockwidget)
1348 const auto dockWidgets = allMyDockWidgets(
mainWindow);
1349 if (!dockAreaLayout.restoreState(
stream, dockWidgets))
1352 for (
int i = 0;
i < dockWidgets.size(); ++
i) {
1354 QList<int>
path = dockAreaLayout.indexOf(
w);
1355 if (
path.isEmpty()) {
1356 QList<int> oldPath = oldState.dockAreaLayout.
indexOf(
w);
1357 if (oldPath.isEmpty()) {
1361 if (
info ==
nullptr) {
1369#if QT_CONFIG(tabwidget)
1372 auto dockWidgets = allMyDockWidgets(
mainWindow);
1380 if (!
info->restoreState(
stream, dockWidgets,
false))
1383 floatingTab->move(geometry.
topLeft());
1384 floatingTab->resize(geometry.
size());
1388 if (
info->onlyHasPlaceholders())
1389 info->reparentWidgets(floatingTab);
1391 floatingTab->show();
1397#if QT_CONFIG(toolbar)
1401 QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(
mainWindow);
1402 if (!toolBarAreaLayout.restoreState(
stream, toolBars,
marker))
1405 for (
int i = 0;
i < toolBars.size(); ++
i) {
1407 QList<int>
path = toolBarAreaLayout.indexOf(
w);
1408 if (
path.isEmpty()) {
1409 QList<int> oldPath = oldState.toolBarAreaLayout.
indexOf(
w);
1410 if (oldPath.isEmpty()) {
1413 toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(
nullptr,
w);
1432#if QT_CONFIG(toolbar)
1490void QMainWindowLayout::insertToolBarBreak(
QToolBar *before)
1492 layoutState.toolBarAreaLayout.insertToolBarBreak(before);
1494 savedState.toolBarAreaLayout.insertToolBarBreak(before);
1498void QMainWindowLayout::removeToolBarBreak(
QToolBar *before)
1500 layoutState.toolBarAreaLayout.removeToolBarBreak(before);
1502 savedState.toolBarAreaLayout.removeToolBarBreak(before);
1506void QMainWindowLayout::moveToolBar(
QToolBar *toolbar,
int pos)
1516void QMainWindowLayout::removeToolBar(
QToolBar *toolbar)
1520 toolbar,
SLOT(_q_updateIconSize(
QSize)));
1546 toolbar->d_func()->updateWindowFlags(
false );
1583bool QMainWindowLayout::toolBarBreak(
QToolBar *toolBar)
const
1585 return layoutState.toolBarAreaLayout.toolBarBreak(toolBar);
1588void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *
option,
QToolBar *toolBar)
const
1590 option->toolBarArea = toolBarArea(toolBar);
1594void QMainWindowLayout::toggleToolBarsVisible()
1614#if QT_CONFIG(dockwidget)
1639 Q_ASSERT_X((
path.size() > 1),
"isAreaAllowed",
"invalid path size");
1644 const bool allowed = dw->isAreaAllowed(
area);
1646 qCDebug(lcQpaDockWidgets) <<
"No permission for single DockWidget" <<
widget <<
"to dock on" <<
area;
1651 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
1654 if (children.size() == 1) {
1656 const bool allowed = children.at(0)->isAreaAllowed(
area);
1658 qCDebug(lcQpaDockWidgets) <<
"No permission for DockWidgetGroupWindow" <<
widget <<
"to dock on" <<
area;
1662 qCDebug(lcQpaDockWidgets) <<
"DockWidgetGroupWindow" <<
widget <<
"has" << children.size() <<
"children:";
1663 qCDebug(lcQpaDockWidgets) << children;
1664 qCDebug(lcQpaDockWidgets) <<
"DockWidgetGroupWindow" <<
widget <<
"can dock at" <<
area <<
"and anywhere else.";
1668 qCDebug(lcQpaDockWidgets) <<
"Docking requested for invalid widget type (coding error)." <<
widget <<
area;
1684 return layoutState.dockAreaLayout.corners[corner];
1696 qCDebug(lcQpaDockWidgets) <<
"QMainWindowLayout::dockWidgetAreaRect called with" <<
area;
1703 return (
size == Maximum) ? dl.
gapRect(dockPosition) : dl.docks[dockPosition].rect;
1714 if (!movingSeparator.isEmpty())
1715 endSeparatorMove(movingSeparatorPos);
1717 layoutState.dockAreaLayout.addDockWidget(toDockPos(
area), dockwidget, orientation);
1718 emit dockwidget->dockLocationChanged(
area);
1722bool QMainWindowLayout::restoreDockWidget(
QDockWidget *dockwidget)
1725 if (!
layoutState.dockAreaLayout.restoreDockWidget(dockwidget))
1732#if QT_CONFIG(tabbar)
1742bool QMainWindowLayout::documentMode()
const
1744 return _documentMode;
1747void QMainWindowLayout::setDocumentMode(
bool enabled)
1755 for (
QTabBar *bar :
std::as_const(usedTabBars))
1756 bar->setDocumentMode(_documentMode);
1757 for (
QTabBar *bar :
std::as_const(unusedTabBars))
1758 bar->setDocumentMode(_documentMode);
1761void QMainWindowLayout::setVerticalTabsEnabled(
bool enabled)
1763 if (verticalTabsEnabled ==
enabled)
1766 verticalTabsEnabled =
enabled;
1768 updateTabBarShapes();
1771#if QT_CONFIG(tabwidget)
1779 if (_tabShape == tabShape)
1782 _tabShape = tabShape;
1784 updateTabBarShapes();
1791 return tabPositions[dockPos];
1792 qWarning(
"QMainWindowLayout::tabPosition called with out-of-bounds value '%d'",
int(
area));
1812 if (areas & dockWidgetAreas[
i])
1813 tabPositions[dockPositions[
i]] = tabPosition;
1815 updateTabBarShapes();
1821void QMainWindowLayout::updateTabBarShapes()
1823#if QT_CONFIG(tabwidget)
1842#if QT_CONFIG(tabwidget)
1848 layout.docks[
i].setTabBarShape(shape);
1853void QMainWindowLayout::splitDockWidget(
QDockWidget *after,
1859 layoutState.dockAreaLayout.splitDockWidget(after, dockwidget, orientation);
1867 if (pathToWidget.isEmpty())
1877#if QT_CONFIG(tabbar)
1880class QMainWindowTabBar :
public QTabBar
1884 QPointer<QDockWidget> draggingDock;
1887 ~QMainWindowTabBar();
1889 QList<QDockWidget *> dockWidgets()
const;
1900 for (
auto *bar : usedTabBars) {
1901 Q_ASSERT(qobject_cast<QMainWindowTabBar *>(bar));
1902 auto *tabBar =
static_cast<QMainWindowTabBar *
>(bar);
1909QMainWindowTabBar::QMainWindowTabBar(
QMainWindow *parent)
1912 setExpanding(
false);
1915QList<QDockWidget *> QMainWindowTabBar::dockWidgets()
const
1917 QList<QDockWidget *> docks;
1918 for (
int i = 0;
i <
count(); ++
i) {
1927 for (
int i = 0;
i <
count(); ++
i) {
1941 QMainWindowTabBar *that =
const_cast<QMainWindowTabBar *
>(
this);
1947 const int itemIndex =
info->tabIndexToListIndex(
index);
1948 if (itemIndex >= 0) {
1949 Q_ASSERT(itemIndex < info->item_list.count());
1951 return item.widgetItem ? qobject_cast<QDockWidget *>(
item.widgetItem->widget()) :
nullptr;
1957void QMainWindowTabBar::mouseMoveEvent(
QMouseEvent *e)
1969 if (
d->dragInProgress && !
r.contains(e->
position().
toPoint()) &&
d->validIndex(
d->pressedIndex)) {
1970 draggingDock = dockAt(
d->pressedIndex);
1974 d->moveTabFinished(
d->pressedIndex);
1975 d->pressedIndex = -1;
1977 d->movingTab->setVisible(
false);
1978 d->dragStartPosition =
QPoint();
1983 dockPriv->initDrag(dwlayout->titleArea().center(),
true);
1985 if (dockPriv->state)
1993 if (dockPriv->state && dockPriv->state->dragging) {
1995 draggingDock->move(
pos);
2002QMainWindowTabBar::~QMainWindowTabBar()
2004 if (!mainWindow || mainWindow == parentWidget())
2013 mwLayout->unusedTabBars.removeOne(
this);
2014 mwLayout->usedTabBars.remove(
this);
2017void QMainWindowTabBar::mouseReleaseEvent(
QMouseEvent *e)
2021 if (dockPriv->state && dockPriv->state->dragging)
2024 draggingDock =
nullptr;
2029bool QMainWindowTabBar::event(
QEvent *e)
2053 QList<QDockWidget *> buddies = bar->dockWidgets();
2066 return bar && bar->count() > 1;
2069QTabBar *QMainWindowLayout::getTabBar()
2071 if (!usedTabBars.isEmpty() && !isInRestoreState) {
2081 if (!unusedTabBars.isEmpty()) {
2082 result = unusedTabBars.takeLast();
2085 result->setDrawBase(
true);
2087 result->setDocumentMode(_documentMode);
2088 result->setMovable(
true);
2093 usedTabBars.insert(
result);
2098QWidget *QMainWindowLayout::getSeparatorWidget()
2101 if (!unusedSeparatorWidgets.isEmpty()) {
2102 result = unusedSeparatorWidgets.takeLast();
2106 result->setAutoFillBackground(
false);
2107 result->setObjectName(
"qt_qmainwindow_extended_splitter"_L1);
2109 usedSeparatorWidgets.insert(
result);
2124 for (QDockWidgetGroupWindow *dwgw :
groups) {
2132void QMainWindowLayout::tabChanged()
2134 QTabBar *tb = qobject_cast<QTabBar*>(sender());
2138 if (
info ==
nullptr)
2144 emit static_cast<QMainWindow *
>(parentWidget())->tabifiedDockWidgetActivated(activated);
2146 if (
auto dwgw = qobject_cast<QDockWidgetGroupWindow*>(tb->parentWidget()))
2147 dwgw->adjustFlags();
2153void QMainWindowLayout::tabMoved(
int from,
int to)
2155 QTabBar *tb = qobject_cast<QTabBar*>(sender());
2160 info->moveTab(from, to);
2166 if (
info ==
nullptr)
2196 if (statusbar &&
x++ ==
index)
2209 widgetAnimator.abort(
w);
2210 if (
w == pluggingWidget)
2211 pluggingWidget =
nullptr;
2214 if (savedState.isValid() ) {
2218 layoutState.remove(
ret);
2221#if QT_CONFIG(toolbar)
2222 if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
2223 currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();
2224 if (!currentGapPos.isEmpty()) {
2225 currentGapPos.prepend(0);
2226 currentGapRect = layoutState.itemRect(currentGapPos);
2234 if (statusbar &&
x++ ==
index) {
2236 statusbar =
nullptr;
2262 if (restoredState) {
2263 layoutState = *restoredState;
2264 restoredState.reset();
2265 discardRestoredStateTimer.stop();
2273 if (savedState.isValid() || (restoredState && isInApplyState))
2282 QSize(
r.width(), statusbar->heightForWidth(
r.width()))
2284 sbr.moveBottom(
r.bottom());
2286 statusbar->setGeometry(vr);
2287 r.setBottom(sbr.top() - 1);
2290 if (restoredState) {
2298 layoutState = *restoredState;
2299 if (restoredState->fits()) {
2300 restoredState.reset();
2301 discardRestoredStateTimer.stop();
2312 discardRestoredStateTimer.start(150,
this);
2316 layoutState.rect =
r;
2318 layoutState.fitLayout();
2319 applyState(layoutState,
false);
2324 if (e->
timerId() == discardRestoredStateTimer.timerId()) {
2325 discardRestoredStateTimer.stop();
2326 restoredState.reset();
2332{
qWarning(
"QMainWindowLayout::addItem: Please use the public QMainWindow API instead"); }
2336 if (!szHint.isValid()) {
2337 szHint = layoutState.sizeHint();
2338 const QSize sbHint = statusbar ? statusbar->sizeHint() :
QSize(0, 0);
2339 szHint =
QSize(
qMax(sbHint.width(), szHint.width()),
2340 sbHint.height() + szHint.height());
2348 minSize = layoutState.minimumSize();
2349 const QSize sbMin = statusbar ? statusbar->minimumSize() :
QSize(0, 0);
2351 sbMin.height() + minSize.
height());
2359 minSize = szHint =
QSize();
2362#if QT_CONFIG(dockwidget)
2363void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *
w)
2365 if (currentHoveredFloat !=
w) {
2366 if (currentHoveredFloat) {
2368 this, &QMainWindowLayout::updateGapIndicator);
2369 disconnect(currentHoveredFloat.data(), &QDockWidgetGroupWindow::resized,
2370 this, &QMainWindowLayout::updateGapIndicator);
2371 if (currentHoveredFloat)
2372 currentHoveredFloat->restore();
2377 currentHoveredFloat =
w;
2382 connect(
w, &QDockWidgetGroupWindow::resized,
2386 updateGapIndicator();
2397#if QT_CONFIG(toolbar)
2398 QToolBar *toolBar = qobject_cast<QToolBar*>(
item->widget());
2399 if (toolBar ==
nullptr)
2402 QRect oldGeo = toolBar->geometry();
2408 if (
o != toolBar->orientation())
2409 toolBar->setOrientation(
o);
2411 QSize hint = toolBar->sizeHint().boundedTo(toolBar->maximumSize())
2412 .expandedTo(toolBar->minimumSize());
2414 if (toolBar->size() !=
hint) {
2417 newGeo.moveRight(oldGeo.right());
2418 toolBar->setGeometry(newGeo);
2429 if (!savedState.isValid())
2433 layoutState = savedState;
2435 if (currentGapPos.isEmpty())
2438 layoutState.unplug(currentGapPos);
2439 layoutState.fitLayout();
2440 currentGapRect = layoutState.itemRect(currentGapPos);
2447#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) && QT_CONFIG(tabbar)
2448 if (currentHoveredFloat) {
2450 QList<int> previousPath = layoutState.indexOf(
widget);
2451 if (!previousPath.isEmpty())
2452 layoutState.remove(previousPath);
2453 previousPath = currentHoveredFloat->layoutInfo()->indexOf(
widget);
2457 for (QDockWidgetGroupWindow *dwgw :
groups) {
2458 if (dwgw == currentHoveredFloat)
2460 QList<int>
path = dwgw->layoutInfo()->indexOf(
widget);
2461 if (!
path.isEmpty())
2462 dwgw->layoutInfo()->remove(
path);
2464 currentGapRect =
QRect();
2465 currentHoveredFloat->apply();
2466 if (!previousPath.isEmpty())
2467 currentHoveredFloat->layoutInfo()->remove(previousPath);
2468 QRect globalRect = currentHoveredFloat->currentGapRect;
2469 globalRect.
moveTopLeft(currentHoveredFloat->mapToGlobal(globalRect.topLeft()));
2476 if (!parentWidget()->
isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty())
2483#if QT_CONFIG(dockwidget)
2487 for (QDockWidgetGroupWindow *dwgw :
groups) {
2488 QList<int>
path = dwgw->layoutInfo()->indexOf(
widget);
2489 if (!
path.isEmpty())
2490 dwgw->layoutInfo()->remove(
path);
2494 QList<int> previousPath = layoutState.indexOf(
widget);
2500 if (!previousPath.isEmpty())
2501 layoutState.remove(previousPath);
2504 QRect globalRect = currentGapRect;
2505 globalRect.
moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));
2506#if QT_CONFIG(dockwidget)
2507 if (qobject_cast<QDockWidget*>(
widget) !=
nullptr) {
2509 if (
layout->nativeWindowDeco()) {
2510 globalRect.adjust(0,
layout->titleHeight(), 0, 0);
2513 globalRect.adjust(-fw, -fw, fw, fw);
2526#if QT_CONFIG(toolbar)
2528 QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());
2529 if (tbl->animating) {
2530 tbl->animating =
false;
2532 tbl->layoutActions(tb->size());
2538 if (
widget == pluggingWidget) {
2540#if QT_CONFIG(dockwidget)
2541#if QT_CONFIG(tabbar)
2542 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
2551 if (currentHoveredFloat) {
2552 dstPath = currentHoveredFloat->layoutInfo()->
indexOf(
widget);
2554 dstParentInfo = currentHoveredFloat->layoutInfo()->info(dstPath);
2556 dstPath = layoutState.dockAreaLayout.indexOf(
widget);
2558 dstParentInfo = layoutState.dockAreaLayout.info(dstPath);
2561 int idx = dstPath.constLast();
2562 Q_ASSERT(dstParentInfo->item_list[idx].widgetItem->widget() == dwgw);
2563 if (dstParentInfo->tabbed && srcTabInfo) {
2565 delete dstParentInfo->item_list[idx].widgetItem;
2566 dstParentInfo->item_list.removeAt(idx);
2567 std::copy(srcTabInfo->item_list.cbegin(), srcTabInfo->item_list.cend(),
2568 std::inserter(dstParentInfo->item_list,
2569 dstParentInfo->item_list.begin() + idx));
2570 quintptr currentId = srcTabInfo->currentTabId();
2572 dstParentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
2574 dstParentInfo->updateTabBar();
2575 dstParentInfo->setCurrentTabId(currentId);
2579 delete item.widgetItem;
2580 item.widgetItem =
nullptr;
2583 item.subinfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
2585 item.subinfo->setTabBarShape(dstParentInfo->tabBarShape);
2587 dwgw->destroyOrHideIfEmpty();
2592 dw->setParent(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget());
2594 dw->d_func()->plug(currentGapRect);
2597#if QT_CONFIG(toolbar)
2599 tb->d_func()->plug(currentGapRect);
2603 currentGapPos.clear();
2604 pluggingWidget =
nullptr;
2605#if QT_CONFIG(dockwidget)
2606 setCurrentHoveredFloat(
nullptr);
2610 layoutState.apply(
false);
2612#if QT_CONFIG(dockwidget)
2613#if QT_CONFIG(tabbar)
2614 if (qobject_cast<QDockWidget*>(
widget) !=
nullptr) {
2624 if (!widgetAnimator.animating()) {
2626#if QT_CONFIG(dockwidget)
2627 parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
2628#if QT_CONFIG(tabbar)
2629 const auto usedTabBarsCopy = usedTabBars;
2630 for (
QTabBar *tab_bar : usedTabBarsCopy)
2636 updateGapIndicator();
2641 if (!savedState.isValid())
2644 layoutState = savedState;
2645 applyState(layoutState);
2646 if (!keepSavedState)
2648 currentGapPos.clear();
2649 pluggingWidget =
nullptr;
2650 updateGapIndicator();
2655 , layoutState(mainwindow)
2656 , savedState(mainwindow)
2661 , _documentMode(
false)
2662 , verticalTabsEnabled(
false)
2668 , widgetAnimator(
this)
2674#if QT_CONFIG(dockwidget)
2675#if QT_CONFIG(tabbar)
2679#if QT_CONFIG(tabwidget)
2704#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar)
2711#if QT_CONFIG(statusbar)
2712QStatusBar *QMainWindowLayout::statusBar()
const
2715void QMainWindowLayout::setStatusBar(
QStatusBar *sb)
2736#if QT_CONFIG(dockwidget)
2738 savedState.dockAreaLayout.fallbackToSizeHints =
true;
2746#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2761 QDockWidgetGroupWindow *floatingTabs =
layout->createTabbedDockWindow();
2767 floatingTabs->show();
2768 floatingTabs->raise();
2769 *
item =
new QDockWidgetGroupWindowItem(floatingTabs);
2775#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2779 if (qobject_cast<QDockWidget *>(
w)) {
2811#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2812 auto *groupWindow = qobject_cast<const QDockWidgetGroupWindow *>(
widget->parentWidget());
2813 if (!
widget->isWindow() && groupWindow) {
2818 QList<int> groupWindowPath =
info->indexOf(
widget->parentWidget());
2819 return groupWindowPath.isEmpty() ?
nullptr :
info->item(groupWindowPath).widgetItem;
2824 QList<int>
path = groupWindow->layoutInfo()->indexOf(
widget);
2828 && unplugGroup(
this, &
item, parentItem)) {
2853#if QT_CONFIG(dockwidget)
2856#if QT_CONFIG(tabwidget)
2858 && unplugGroup(
this, &
item,
2867 switch (dockWidgetArea(dw)) {
2870 r.setHeight(
r.height() -
sep);
2874 r.setWidth(
r.width() -
sep);
2885 const auto *
layout = qobject_cast<QDockWidgetLayout *>(dw->layout());
2886 const bool verticalTitleBar =
layout ?
layout->verticalTitleBar :
false;
2890 const int minHeight = verticalTitleBar ? 2 * tbHeight : tbHeight;
2891 const int minWidth = verticalTitleBar ? tbHeight : 2 * tbHeight;
2892 r.setSize(
r.size().expandedTo(
QSize(minWidth, minHeight)));
2893 qCDebug(lcQpaDockWidgets) << dw <<
"will be unplugged with size" <<
r.size();
2895 dw->d_func()->unplug(
r);
2899#if QT_CONFIG(toolbar)
2901 tb->d_func()->unplug(
r);
2905#if !QT_CONFIG(dockwidget) || !QT_CONFIG(tabbar)
2913 updateGapIndicator();
2920void QMainWindowLayout::updateGapIndicator()
2922#if QT_CONFIG(rubberband)
2925 || currentHoveredFloat
2929#if QT_CONFIG(dockwidget)
2930 currentHoveredFloat ? currentHoveredFloat.data() :
2933 if (!gapIndicator) {
2936 gapIndicator->setObjectName(
"qt_rubberband"_L1);
2937 }
else if (gapIndicator->parent() != expectedParent) {
2938 gapIndicator->setParent(expectedParent);
2942 const bool sigBlockState = gapIndicator->signalsBlocked();
2943 auto resetSignals =
qScopeGuard([
this, sigBlockState](){ gapIndicator->blockSignals(sigBlockState); });
2944 gapIndicator->blockSignals(
true);
2946#if QT_CONFIG(dockwidget)
2947 if (currentHoveredFloat)
2948 gapIndicator->setGeometry(currentHoveredFloat->currentGapRect);
2953 gapIndicator->show();
2954 gapIndicator->raise();
2958 }
else if (gapIndicator) {
2959 gapIndicator->hide();
2966 const QPoint &mousePos) {
2973#if QT_CONFIG(dockwidget)
2976 || qobject_cast<QDockWidgetGroupWindow *>(
widget))) {
2979 QVarLengthArray<QWidget *, 10> candidates;
2987 if (!qobject_cast<QDockWidget*>(
w) && !qobject_cast<QDockWidgetGroupWindow *>(
w))
2993 if (
w !=
widget &&
w->isWindow() &&
w->isVisible() && !
w->isMinimized())
2996 if (QDockWidgetGroupWindow *
group = qobject_cast<QDockWidgetGroupWindow *>(
w)) {
2999 const auto groupChildren =
group->children();
3002 if (dw !=
widget && dw->isFloating() && dw->isVisible() && !dw->isMinimized())
3012 if (screen1 && screen2 && screen1 != screen2)
3014 if (!
w->geometry().contains(mousePos))
3017#if QT_CONFIG(tabwidget)
3018 if (
auto dropTo = qobject_cast<QDockWidget *>(
w)) {
3021 w = dropTo->widget();
3024 if (!qobject_cast<QDockWidgetGroupWindow *>(
w)) {
3025 QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
3026 floatingTabs->setGeometry(dropTo->geometry());
3028 const QTabBar::Shape shape = tabwidgetPositionToTabBarShape(dropTo);
3037 dockPosition = toDockPos(dockWidgetArea(
widget));
3044 info->tabBar = getTabBar();
3045 info->tabbed =
true;
3048 parentInfo.add(floatingTabs);
3049 dropTo->setParent(floatingTabs);
3050 qCDebug(lcQpaDockWidgets) <<
"Wrapping" <<
widget <<
"into floating tabs" << floatingTabs;
3056 qCDebug(lcQpaDockWidgets) <<
"Showing" << dropTo;
3061 auto *groupWindow = qobject_cast<QDockWidgetGroupWindow *>(
w);
3063 if (groupWindow->hover(hoverTarget, groupWindow->mapFromGlobal(mousePos))) {
3064 setCurrentHoveredFloat(groupWindow);
3073 if (currentHoveredFloat)
3074 currentHoveredFloat->destroyIfSingleItemLeft();
3076 setCurrentHoveredFloat(
nullptr);
3077 layoutState.dockAreaLayout.fallbackToSizeHints =
false;
3087 if (!
path.isEmpty()) {
3088 bool allowed =
false;
3090#if QT_CONFIG(dockwidget)
3093#if QT_CONFIG(toolbar)
3095 allowed = tb->isAreaAllowed(toToolBarArea(
path.at(1)));
3106 if (
path.isEmpty()) {
3124 if (min.width() >
size.width() || min.height() >
size.height()) {
3133#if QT_CONFIG(dockwidget)
3139 updateGapIndicator();
3142#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
3143QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()
3146 new QDockWidgetGroupLayout(
f);
3159#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
3160 QSet<QTabBar*> used =
newState.dockAreaLayout.usedTabBars();
3163 for (QDockWidgetGroupWindow *dwgw :
groups)
3164 used += dwgw->layoutInfo()->usedTabBars();
3166 const QSet<QTabBar*> retired = usedTabBars - used;
3168 for (
QTabBar *tab_bar : retired) {
3170 while (tab_bar->count() > 0)
3171 tab_bar->removeTab(0);
3172 unusedTabBars.append(tab_bar);
3176 const QSet<QWidget*> usedSeps =
newState.dockAreaLayout.usedSeparatorWidgets();
3177 const QSet<QWidget*> retiredSeps = usedSeparatorWidgets - usedSeps;
3178 usedSeparatorWidgets = usedSeps;
3179 for (
QWidget *sepWidget : retiredSeps) {
3180 unusedSeparatorWidgets.append(sepWidget);
3200 QScopedValueRollback<bool> guard(isInRestoreState,
true);
3233#if QT_CONFIG(dockwidget)
3235#if QT_CONFIG(tabbar)
3236 for (
QTabBar *tab_bar : std::as_const(usedTabBars))
3246#if QT_CONFIG(draganddrop)
3247bool QMainWindowLayout::needsPlatformDrag()
3249 static const bool wayland =
3255 const QPoint &pressPosition)
3257 draggingWidget = widgetItem;
3263 auto serialize = [](
const auto &
object) {
3270 serialize(
reinterpret_cast<qintptr>(window)));
3271 mimeData->
setData(
"application/x-qt-mainwindowdrag-position"_L1, serialize(pressPosition));
3274 auto result = drag.exec();
3276 draggingWidget =
nullptr;
3283#include "qmainwindowlayout.moc"
3284#include "moc_qmainwindowlayout_p.cpp"
static QStyle * style()
Returns the application's style object.
int startDragDistance
the minimum distance required for a drag and drop operation to start.
QSize minimumSize() const override
\reimp
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
\inmodule QtCore\reentrant
void setVersion(int)
Sets the version number of the data serialization format to v, a value of the \l Version enum.
QList< int > indexOf(QWidget *widget) const
QList< QDockAreaLayoutItem > item_list
void remove(const QList< int > &path)
@ FloatingDockWidgetTabMarker
static QRect constrainedRect(QRect rect, QWidget *widget)
@ NonClientAreaMouseButtonDblClick
@ NonClientAreaMouseButtonRelease
@ NonClientAreaMouseButtonPress
Type type() const
Returns the event type.
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
void show()
Shows the item (items are visible by default).
QPointF pos() const
Returns the position of the item in parent coordinates.
QGraphicsWidget * window() const
GraphicsItemFlags flags() const
Returns this item's flags.
qreal x
the x position of the item
QString platformName
The name of the underlying platform plugin.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
The QLayout class is the base class of geometry managers.
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
void update()
Updates the layout for parentWidget().
void invalidate() override
\reimp
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
virtual void setGeometry(const QRect &) override
\reimp
QLayout * layout() override
\reimp
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void prepend(rvalue_ref t)
const T & constFirst() const noexcept
QLayoutItem * takeAt(int index, int *x)
QSize minimumSize() const
void setCentralWidget(QWidget *widget)
void deleteAllLayoutItems()
bool insertGap(const QList< int > &path, QLayoutItem *item)
QList< int > indexOf(QWidget *widget) const
QRect gapRect(const QList< int > &path) const
QLayoutItem * centralWidgetItem
QLayoutItem * item(const QList< int > &path)
QRect itemRect(const QList< int > &path) const
bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState)
void saveState(QDataStream &stream) const
void remove(const QList< int > &path)
QLayoutItem * itemAt(int index, int *x) const
QWidget * centralWidget() const
void apply(bool animated)
bool checkFormat(QDataStream &stream)
QMainWindowLayoutState(QMainWindow *win)
QLayoutItem * unplug(const QList< int > &path, QMainWindowLayoutState *savedState=nullptr)
QList< int > gapIndex(QWidget *widget, const QPoint &pos) const
QLayoutItem * plug(const QList< int > &path)
bool contains(QWidget *widget) const
void deleteCentralWidgetItem()
void setCentralWidget(QWidget *cw)
QList< int > currentGapPos
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void hover(QLayoutItem *hoverTarget, const QPoint &mousePos)
void revert(QLayoutItem *widgetItem)
QSize sizeHint() const override
Implemented in subclasses to return the preferred size of this item.
QMainWindowLayoutState savedState
void applyRestoredState()
QLayoutItem * itemAt(int index) const override
Must be implemented in subclasses to return the layout item at index.
void setDockOptions(QMainWindow::DockOptions opts)
QLayoutItem * unplug(QWidget *widget, QDockWidgetPrivate::DragScope scope)
void invalidate() override
\reimp
void restore(bool keepSavedState=false)
void addItem(QLayoutItem *item) override
Implemented in subclasses to add an item.
QSize minimumSize() const override
Returns the minimum size of this layout.
QWidget * centralWidget() const
QWidgetAnimator widgetAnimator
bool plug(QLayoutItem *widgetItem)
QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout)
int count() const override
Must be implemented in subclasses to return the number of items in the layout.
std::unique_ptr< QMainWindowLayoutState > restoredState
void saveState(QDataStream &stream) const
QMainWindow::DockOptions dockOptions
void setGeometry(const QRect &r) override
\reimp
QLayoutItem * takeAt(int index) override
Must be implemented in subclasses to remove the layout item at index from the layout,...
void applyState(QMainWindowLayoutState &newState, bool animate=true)
bool restoreState(QDataStream &stream)
QMainWindowLayoutState layoutState
void animationFinished(QWidget *widget)
The QMainWindow class provides a main application window.
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
The QMoveEvent class contains event parameters for move events.
static QObjectPrivate * get(QObject *o)
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
void setParent(QObject *parent)
Makes the object a child of parent.
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void removeEventFilter(QObject *obj)
Removes an event filter object obj from this object.
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
QList< T > findChildren(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QPaintEvent class contains event parameters for paint events.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void moveTopLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
The QScreen class is used to query screen properties. \inmodule QtGui.
QPointF globalPosition() const
Returns the position of the point in this event on the screen or virtual desktop.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Qt::MouseButton button() const
Returns the button that caused the event.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
The QStatusBar class provides a horizontal bar suitable for presenting status information.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
\variable QStyleOptionFocusRect::backgroundColor
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
@ PM_DockWidgetFrameWidth
@ PM_DockWidgetSeparatorExtent
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QTabBar class provides a tab bar, e.g.
bool event(QEvent *) override
\reimp
void mouseReleaseEvent(QMouseEvent *) override
\reimp
void mouseMoveEvent(QMouseEvent *) override
\reimp
void tabMoved(int from, int to)
Shape
This enum type lists the built-in shapes supported by QTabBar.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
QSet< QString >::iterator it
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
@ FindChildrenRecursively
QLatin1StringView dockWidgetArea(int v)
MyMainWidget * mainWindow
static jboolean copy(JNIEnv *, jobject)
static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static int area(const QSize &s)
#define qCDebug(category,...)
static void fixToolBarOrientation(QLayoutItem *item, int dockPos)
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static QList< T > findChildrenHelper(const QObject *o)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLintptr offset
GLsizei const GLchar *const * path
static constexpr QSize frameSize(const T &frame)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
static constexpr QChar sep
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
static QRect frameGeometry(HWND hwnd, bool topLevel)
if(qFloatDistance(a, b)<(1<< 7))
[0]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
QDockAreaLayoutInfo * subinfo