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";
166#if QT_CONFIG(dockwidget)
167class QDockWidgetGroupLayout :
public QLayout,
176 ~QDockWidgetGroupLayout() {
177 layoutState.deleteAllLayoutItems();
181 int count()
const override {
return 0; }
185 return layoutState.itemAt(&
x,
index);
191 if (savedState.rect.isValid() &&
ret->widget()) {
195 savedState.remove(
path);
197 path = layoutState.indexOf(
ret->widget());
199 layoutState.remove(
path);
205 int fw = frameWidth();
206 return layoutState.sizeHint() +
QSize(fw, fw);
210 int fw = frameWidth();
211 return layoutState.minimumSize() +
QSize(fw, fw);
215 int fw = frameWidth();
216 return layoutState.maximumSize() +
QSize(fw, fw);
220 groupWindow()->destroyOrHideIfEmpty();
224 int fw = frameWidth();
231 if (savedState.rect.isValid())
238 bool nativeWindowDeco()
const
240 return groupWindow()->hasNativeDecos();
243 int frameWidth()
const
245 return nativeWindowDeco() ? 0 :
249 QDockWidgetGroupWindow *groupWindow()
const
251 return static_cast<QDockWidgetGroupWindow *
>(
parent());
258bool QDockWidgetGroupWindow::event(
QEvent *
e)
260 auto lay =
static_cast<QDockWidgetGroupLayout *
>(
layout());
261 if (lay && lay->windowEvent(
e))
297 destroyOrHideIfEmpty();
300 updateCurrentGapRect();
308void QDockWidgetGroupWindow::paintEvent(
QPaintEvent *)
310 QDockWidgetGroupLayout *lay =
static_cast<QDockWidgetGroupLayout *
>(
layout());
311 bool nativeDeco = lay->nativeWindowDeco();
323 return static_cast<QDockWidgetGroupLayout *
>(
layout())->dockAreaLayoutInfo();
339 bool isSingle =
false;
340 for (
const auto &
item :
info->item_list) {
343 if (
next || isSingle)
347 else if (
item.widgetItem)
360QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget()
const
366 if (
info->tabBar &&
info->tabBar->currentIndex() >= 0) {
367 int i =
info->tabIndexToListIndex(
info->tabBar->currentIndex());
371 dw = qobject_cast<QDockWidget *>(
item.widgetItem->widget());
375 for (
int i = 0; !dw &&
i <
info->item_list.
size(); ++
i) {
379 if (!
item.widgetItem)
381 dw = qobject_cast<QDockWidget *>(
item.widgetItem->widget());
392void QDockWidgetGroupWindow::destroyOrHideIfEmpty()
395 if (!
info->isEmpty()) {
400 if (!
info->item_list.isEmpty()) {
409 const bool wasHidden = dw->
isHidden();
411 qCDebug(lcQpaDockWidgets) <<
"Reparented:" << dw <<
"to" << parentWidget() <<
"by" <<
this;
422 qCDebug(lcQpaDockWidgets) <<
"Redocked to Mainwindow:" <<
area << dw <<
"by" <<
this;
438void QDockWidgetGroupWindow::adjustFlags()
440 Qt::WindowFlags oldFlags = windowFlags();
441 Qt::WindowFlags
flags = oldFlags;
451 }
else if (
static_cast<QDockWidgetGroupLayout *
>(
layout())->nativeWindowDeco()) {
460 if (oldFlags !=
flags) {
463 setWindowFlags(
flags);
469 if (lostNativeDecos) {
470 QRect newGeometry = geometry();
474 setGeometry(newGeometry);
475 }
else if (gainedNativeDecos && m_removedFrameSize.isValid()) {
477 r.adjust(-m_removedFrameSize.width() / 2, 0,
478 -m_removedFrameSize.width() / 2, -m_removedFrameSize.height());
480 m_removedFrameSize =
QSize();
491bool QDockWidgetGroupWindow::hasNativeDecos()
const
514bool QDockWidgetGroupWindow::hover(
QLayoutItem *widgetItem,
const QPoint &mousePos)
518 savedState = *layoutInfo();
520 QMainWindow::DockOptions opts =
static_cast<QMainWindow *
>(parentWidget())->dockOptions();
522 bool nestingEnabled =
525#if !QT_CONFIG(tabbar)
529 if (
auto group = qobject_cast<QDockWidgetGroupWindow *>(widgetItem->
widget())) {
530 if (!
group->tabLayoutInfo())
542 auto newGapPos =
newState.gapIndex(mousePos, nestingEnabled, tabMode);
547 if (newGapPos == currentGapPos ||
newState.hasGapItem(newGapPos))
550 currentGapPos = newGapPos;
551 newState.insertGap(currentGapPos, widgetItem);
553 *layoutInfo() = std::move(
newState);
554 updateCurrentGapRect();
559void QDockWidgetGroupWindow::updateCurrentGapRect()
561 if (!currentGapPos.isEmpty())
562 currentGapRect = layoutInfo()->info(currentGapPos)->itemRect(currentGapPos.last(),
true);
568void QDockWidgetGroupWindow::restore()
572 *layoutInfo() = savedState;
575 currentGapRect =
QRect();
576 currentGapPos.clear();
578 layoutInfo()->fitItems();
579 layoutInfo()->apply(
static_cast<QMainWindow *
>(parentWidget())->dockOptions()
586void QDockWidgetGroupWindow::apply()
588 static_cast<QDockWidgetGroupLayout *
>(
layout())->savedState.
clear();
589 currentGapRect =
QRect();
590 layoutInfo()->plug(currentGapPos);
591 currentGapPos.clear();
593 layoutInfo()->apply(
false);
607 toolBarAreaLayout(
win),
624#if QT_CONFIG(dockwidget)
625 result = dockAreaLayout.sizeHint();
631#if QT_CONFIG(toolbar)
642#if QT_CONFIG(dockwidget)
643 result = dockAreaLayout.minimumSize();
649#if QT_CONFIG(toolbar)
667#if QT_CONFIG(dockwidget)
668 size = dockAreaLayout.minimumStableSize();
671#if QT_CONFIG(toolbar)
683#if QT_CONFIG(toolbar)
684 toolBarAreaLayout.apply(animated);
687#if QT_CONFIG(dockwidget)
689 dockAreaLayout.apply(animated);
702#if !QT_CONFIG(toolbar)
705 toolBarAreaLayout.rect =
rect;
706 r = toolBarAreaLayout.fitLayout();
709#if QT_CONFIG(dockwidget)
710 dockAreaLayout.rect =
r;
711 dockAreaLayout.fitLayout();
719#if QT_CONFIG(toolbar)
720 toolBarAreaLayout.deleteAllLayoutItems();
723#if QT_CONFIG(dockwidget)
724 dockAreaLayout.deleteAllLayoutItems();
730#if QT_CONFIG(dockwidget)
731 delete dockAreaLayout.centralWidgetItem;
732 dockAreaLayout.centralWidgetItem =
nullptr;
741#if QT_CONFIG(toolbar)
746#if QT_CONFIG(dockwidget)
759#if QT_CONFIG(toolbar)
764#if QT_CONFIG(dockwidget)
782#if QT_CONFIG(toolbar)
785 result = toolBarAreaLayout.indexOf(toolBar);
792#if QT_CONFIG(dockwidget)
794 if (qobject_cast<QDockWidget *>(
widget) || qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
807#if QT_CONFIG(dockwidget)
808 if (dockAreaLayout.centralWidgetItem !=
nullptr && dockAreaLayout.centralWidgetItem->widget() ==
widget)
810 if (!dockAreaLayout.indexOf(
widget).isEmpty())
817#if QT_CONFIG(toolbar)
818 if (!toolBarAreaLayout.indexOf(
widget).isEmpty())
833#if QT_CONFIG(dockwidget)
834 dockAreaLayout.centralWidgetItem =
item;
844#if QT_CONFIG(dockwidget)
845 item = dockAreaLayout.centralWidgetItem;
851 return item->widget();
860#if QT_CONFIG(toolbar)
862 if (qobject_cast<QToolBar*>(
widget) !=
nullptr) {
863 result = toolBarAreaLayout.gapIndex(
pos);
870#if QT_CONFIG(dockwidget)
872 if (qobject_cast<QDockWidget *>(
widget) !=
nullptr
873 || qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
874 bool disallowTabs =
false;
876 if (
auto *
group = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
877 if (!
group->tabLayoutInfo())
881 result = dockAreaLayout.gapIndex(
pos, disallowTabs);
896 int i =
path.first();
898#if QT_CONFIG(toolbar)
900 Q_ASSERT(qobject_cast<QToolBar*>(
item->widget()) !=
nullptr);
901 return toolBarAreaLayout.insertGap(
path.mid(1),
item);
905#if QT_CONFIG(dockwidget)
907 Q_ASSERT(qobject_cast<QDockWidget*>(
item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(
item->widget()));
908 return dockAreaLayout.insertGap(
path.mid(1),
item);
917 int i =
path.first();
919#if QT_CONFIG(toolbar)
921 toolBarAreaLayout.remove(
path.mid(1));
924#if QT_CONFIG(dockwidget)
926 dockAreaLayout.remove(
path.mid(1));
932#if QT_CONFIG(toolbar)
933 toolBarAreaLayout.remove(
item);
936#if QT_CONFIG(dockwidget)
941 dockAreaLayout.remove(
path);
948#if QT_CONFIG(toolbar)
949 toolBarAreaLayout.clear();
952#if QT_CONFIG(dockwidget)
953 dockAreaLayout.clear();
968 int i =
path.first();
970#if QT_CONFIG(toolbar)
978#if QT_CONFIG(dockwidget)
980 return dockAreaLayout.item(
path.mid(1)).widgetItem;
988 int i =
path.first();
990#if QT_CONFIG(toolbar)
992 return toolBarAreaLayout.itemRect(
path.mid(1));
995#if QT_CONFIG(dockwidget)
997 return dockAreaLayout.itemRect(
path.mid(1));
1005 int i =
path.first();
1007#if QT_CONFIG(toolbar)
1009 return toolBarAreaLayout.itemRect(
path.mid(1));
1012#if QT_CONFIG(dockwidget)
1014 return dockAreaLayout.gapRect(
path.mid(1));
1022 int i =
path.first();
1024#if QT_CONFIG(toolbar)
1026 return toolBarAreaLayout.plug(
path.mid(1));
1029#if QT_CONFIG(dockwidget)
1031 return dockAreaLayout.plug(
path.mid(1));
1039 int i =
path.first();
1041#if !QT_CONFIG(toolbar)
1045 return toolBarAreaLayout.unplug(
path.mid(1),
other ? &
other->toolBarAreaLayout :
nullptr);
1048#if QT_CONFIG(dockwidget)
1050 return dockAreaLayout.unplug(
path.mid(1));
1058#if QT_CONFIG(dockwidget)
1059 dockAreaLayout.saveState(
stream);
1060#if QT_CONFIG(tabbar)
1064 for (QDockWidgetGroupWindow *floating : floatingTabs) {
1065 if (floating->layoutInfo()->isEmpty())
1068 floating->layoutInfo()->saveState(
stream);
1072#if QT_CONFIG(toolbar)
1073 toolBarAreaLayout.saveState(
stream);
1077template <
typename T>
1084 if (T
t = qobject_cast<T>(
list[
i])) {
1092#if QT_CONFIG(dockwidget)
1097 if (
auto *dw = qobject_cast<QDockWidget*>(
c)) {
1099 }
else if (
auto *gw = qobject_cast<QDockWidgetGroupWindow*>(
c)) {
1100 for (
QObject *
c : gw->children()) {
1101 if (
auto *dw = qobject_cast<QDockWidget*>(
c))
1114 while (!
stream.atEnd()) {
1119#if QT_CONFIG(toolbar)
1124 if (!toolBarAreaLayout.restoreState(
stream, toolBars,
marker,
true )) {
1131#if QT_CONFIG(dockwidget)
1134 const auto dockWidgets = allMyDockWidgets(
mainWindow);
1135 if (!dockAreaLayout.restoreState(
stream, dockWidgets,
true )) {
1140#if QT_CONFIG(tabbar)
1146 auto dockWidgets = allMyDockWidgets(
mainWindow);
1147 if (!
info.restoreState(
stream, dockWidgets,
true ))
1168 while(!_stream.
atEnd()) {
1184 while (!
stream.atEnd()) {
1189#if QT_CONFIG(dockwidget)
1192 const auto dockWidgets = allMyDockWidgets(
mainWindow);
1193 if (!dockAreaLayout.restoreState(
stream, dockWidgets))
1196 for (
int i = 0;
i < dockWidgets.size(); ++
i) {
1199 if (
path.isEmpty()) {
1205 if (
info ==
nullptr) {
1213#if QT_CONFIG(tabwidget)
1216 auto dockWidgets = allMyDockWidgets(
mainWindow);
1224 if (!
info->restoreState(
stream, dockWidgets,
false))
1227 floatingTab->move(geometry.
topLeft());
1228 floatingTab->resize(geometry.
size());
1232 if (
info->onlyHasPlaceholders())
1233 info->reparentWidgets(floatingTab);
1235 floatingTab->show();
1241#if QT_CONFIG(toolbar)
1246 if (!toolBarAreaLayout.restoreState(
stream, toolBars,
marker))
1249 for (
int i = 0;
i < toolBars.
size(); ++
i) {
1252 if (
path.isEmpty()) {
1257 toolBarAreaLayout.docks[oldPath.
at(0)].insertToolBar(
nullptr,
w);
1276#if QT_CONFIG(toolbar)
1324 validateToolBarArea(
area);
1333void QMainWindowLayout::insertToolBarBreak(
QToolBar *before)
1335 layoutState.toolBarAreaLayout.insertToolBarBreak(before);
1337 savedState.toolBarAreaLayout.insertToolBarBreak(before);
1341void QMainWindowLayout::removeToolBarBreak(
QToolBar *before)
1343 layoutState.toolBarAreaLayout.removeToolBarBreak(before);
1345 savedState.toolBarAreaLayout.removeToolBarBreak(before);
1349void QMainWindowLayout::moveToolBar(
QToolBar *toolbar,
int pos)
1359void QMainWindowLayout::removeToolBar(
QToolBar *toolbar)
1363 toolbar,
SLOT(_q_updateIconSize(
QSize)));
1378 validateToolBarArea(
area);
1389 toolbar->d_func()->updateWindowFlags(
false );
1426bool QMainWindowLayout::toolBarBreak(
QToolBar *toolBar)
const
1428 return layoutState.toolBarAreaLayout.toolBarBreak(toolBar);
1431void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *
option,
QToolBar *toolBar)
const
1433 option->toolBarArea = toolBarArea(toolBar);
1437void QMainWindowLayout::toggleToolBarsVisible()
1457#if QT_CONFIG(dockwidget)
1480#if QT_CONFIG(dockwidget)
1483 Q_ASSERT_X((
path.size() > 1),
"isAreaAllowed",
"invalid path size");
1490 qCDebug(lcQpaDockWidgets) <<
"No permission for single DockWidget" <<
widget <<
"to dock on" <<
area;
1495 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
1498 if (children.
size() == 1) {
1500 const bool allowed = children.
at(0)->isAreaAllowed(
area);
1502 qCDebug(lcQpaDockWidgets) <<
"No permission for DockWidgetGroupWindow" <<
widget <<
"to dock on" <<
area;
1506 qCDebug(lcQpaDockWidgets) <<
"DockWidgetGroupWindow" <<
widget <<
"has" << children.
size() <<
"children:";
1507 qCDebug(lcQpaDockWidgets) << children;
1508 qCDebug(lcQpaDockWidgets) <<
"DockWidgetGroupWindow" <<
widget <<
"can dock at" <<
area <<
"and anywhere else.";
1512 qCDebug(lcQpaDockWidgets) <<
"Docking requested for invalid widget type (coding error)." <<
widget <<
area;
1529 return layoutState.dockAreaLayout.corners[corner];
1535#if QT_CONFIG(dockwidget)
1542 qCDebug(lcQpaDockWidgets) <<
"QMainWindowLayout::dockWidgetAreaRect called with" <<
area;
1561 if (!movingSeparator.isEmpty())
1562 endSeparatorMove(movingSeparatorPos);
1564 layoutState.dockAreaLayout.addDockWidget(toDockPos(
area), dockwidget, orientation);
1569bool QMainWindowLayout::restoreDockWidget(
QDockWidget *dockwidget)
1572 if (!
layoutState.dockAreaLayout.restoreDockWidget(dockwidget))
1579#if QT_CONFIG(tabbar)
1588bool QMainWindowLayout::documentMode()
const
1590 return _documentMode;
1593void QMainWindowLayout::setDocumentMode(
bool enabled)
1601 for (
QTabBar *bar :
std::as_const(usedTabBars))
1602 bar->setDocumentMode(_documentMode);
1603 for (
QTabBar *bar :
std::as_const(unusedTabBars))
1604 bar->setDocumentMode(_documentMode);
1607void QMainWindowLayout::setVerticalTabsEnabled(
bool enabled)
1609 if (verticalTabsEnabled ==
enabled)
1612 verticalTabsEnabled =
enabled;
1614 updateTabBarShapes();
1617#if QT_CONFIG(tabwidget)
1625 if (_tabShape == tabShape)
1628 _tabShape = tabShape;
1630 updateTabBarShapes();
1637 return tabPositions[dockPos];
1638 qWarning(
"QMainWindowLayout::tabPosition called with out-of-bounds value '%d'",
int(
area));
1658 if (areas & dockWidgetAreas[
i])
1659 tabPositions[dockPositions[
i]] = tabPosition;
1661 updateTabBarShapes();
1667void QMainWindowLayout::updateTabBarShapes()
1669#if QT_CONFIG(tabwidget)
1688#if QT_CONFIG(tabwidget)
1694 layout.docks[
i].setTabBarShape(shape);
1699void QMainWindowLayout::splitDockWidget(
QDockWidget *after,
1704 layoutState.dockAreaLayout.splitDockWidget(after, dockwidget, orientation);
1722#if QT_CONFIG(tabbar)
1725class QMainWindowTabBar :
public QTabBar
1741 setExpanding(
false);
1756 if (
d->dragInProgress && !
r.contains(
e->position().toPoint()) &&
d->validIndex(
d->pressedIndex)) {
1760 int idx =
info->tabIndexToListIndex(
d->pressedIndex);
1763 && (draggingDock = qobject_cast<QDockWidget *>(
item.widgetItem->widget()))) {
1766 d->moveTabFinished(
d->pressedIndex);
1767 d->pressedIndex = -1;
1769 d->movingTab->setVisible(
false);
1770 d->dragStartPosition =
QPoint();
1777 if (dockPriv->
state)
1785 if (dockPriv->
state && dockPriv->
state->dragging) {
1786 QPoint pos =
e->globalPosition().toPoint() - dockPriv->
state->pressPos;
1787 draggingDock->move(
pos);
1794void QMainWindowTabBar::mouseReleaseEvent(
QMouseEvent *
e)
1798 if (dockPriv->
state && dockPriv->
state->dragging) {
1801 draggingDock =
nullptr;
1806bool QMainWindowTabBar::event(
QEvent *
e)
1824QTabBar *QMainWindowLayout::getTabBar()
1826 if (!usedTabBars.isEmpty() && !isInRestoreState) {
1836 if (!unusedTabBars.isEmpty()) {
1837 result = unusedTabBars.takeLast();
1840 result->setDrawBase(
true);
1842 result->setDocumentMode(_documentMode);
1843 result->setMovable(
true);
1848 usedTabBars.insert(
result);
1853QWidget *QMainWindowLayout::getSeparatorWidget()
1856 if (!unusedSeparatorWidgets.isEmpty()) {
1857 result = unusedSeparatorWidgets.takeLast();
1861 result->setAutoFillBackground(
false);
1862 result->setObjectName(
"qt_qmainwindow_extended_splitter"_L1);
1864 usedSeparatorWidgets.insert(
result);
1879 for (QDockWidgetGroupWindow *dwgw :
groups) {
1887void QMainWindowLayout::tabChanged()
1893 if (
info ==
nullptr)
1901 if (
auto dwgw = qobject_cast<QDockWidgetGroupWindow*>(tb->
parentWidget()))
1902 dwgw->adjustFlags();
1908void QMainWindowLayout::tabMoved(
int from,
int to)
1915 info->moveTab(from, to);
1921 if (
info ==
nullptr)
1976#if QT_CONFIG(toolbar)
2014 r.setBottom(sbr.
top() - 1);
2059{
qWarning(
"QMainWindowLayout::addItem: Please use the public QMainWindow API instead"); }
2089#if QT_CONFIG(dockwidget)
2090void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *
w)
2092 if (currentHoveredFloat !=
w) {
2093 if (currentHoveredFloat) {
2095 this, &QMainWindowLayout::updateGapIndicator);
2096 disconnect(currentHoveredFloat.data(), &QDockWidgetGroupWindow::resized,
2097 this, &QMainWindowLayout::updateGapIndicator);
2098 if (currentHoveredFloat)
2099 currentHoveredFloat->restore();
2104 currentHoveredFloat =
w;
2109 connect(
w, &QDockWidgetGroupWindow::resized,
2113 updateGapIndicator();
2124#if QT_CONFIG(toolbar)
2125 QToolBar *toolBar = qobject_cast<QToolBar*>(
item->widget());
2126 if (toolBar ==
nullptr)
2174#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) && QT_CONFIG(tabbar)
2175 if (currentHoveredFloat) {
2180 previousPath = currentHoveredFloat->layoutInfo()->
indexOf(
widget);
2184 for (QDockWidgetGroupWindow *dwgw :
groups) {
2185 if (dwgw == currentHoveredFloat)
2188 if (!
path.isEmpty())
2189 dwgw->layoutInfo()->remove(
path);
2192 currentHoveredFloat->apply();
2194 currentHoveredFloat->layoutInfo()->remove(previousPath);
2195 QRect globalRect = currentHoveredFloat->currentGapRect;
2210#if QT_CONFIG(dockwidget)
2214 for (QDockWidgetGroupWindow *dwgw :
groups) {
2216 if (!
path.isEmpty())
2217 dwgw->layoutInfo()->remove(
path);
2233#if QT_CONFIG(dockwidget)
2234 if (qobject_cast<QDockWidget*>(
widget) !=
nullptr) {
2236 if (
layout->nativeWindowDeco()) {
2240 globalRect.
adjust(-fw, -fw, fw, fw);
2253#if QT_CONFIG(toolbar)
2267#if QT_CONFIG(dockwidget)
2268#if QT_CONFIG(tabbar)
2269 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
2278 if (currentHoveredFloat) {
2279 dstPath = currentHoveredFloat->layoutInfo()->
indexOf(
widget);
2281 dstParentInfo = currentHoveredFloat->layoutInfo()->
info(dstPath);
2285 dstParentInfo =
layoutState.dockAreaLayout.info(dstPath);
2290 if (dstParentInfo->tabbed && srcTabInfo) {
2292 delete dstParentInfo->
item_list[idx].widgetItem;
2297 quintptr currentId = srcTabInfo->currentTabId();
2299 dstParentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
2301 dstParentInfo->updateTabBar();
2302 dstParentInfo->setCurrentTabId(currentId);
2306 delete item.widgetItem;
2307 item.widgetItem =
nullptr;
2310 item.subinfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
2312 item.subinfo->setTabBarShape(dstParentInfo->tabBarShape);
2314 dwgw->destroyOrHideIfEmpty();
2324#if QT_CONFIG(toolbar)
2332#if QT_CONFIG(dockwidget)
2333 setCurrentHoveredFloat(
nullptr);
2339#if QT_CONFIG(dockwidget)
2340#if QT_CONFIG(tabbar)
2341 if (qobject_cast<QDockWidget*>(
widget) !=
nullptr) {
2353#if QT_CONFIG(dockwidget)
2355#if QT_CONFIG(tabbar)
2356 const auto usedTabBarsCopy = usedTabBars;
2357 for (
QTabBar *tab_bar : usedTabBarsCopy)
2363 updateGapIndicator();
2373 if (!keepSavedState)
2377 updateGapIndicator();
2382 , layoutState(mainwindow)
2383 , savedState(mainwindow)
2388 , _documentMode(
false)
2389 , verticalTabsEnabled(
false)
2395 , widgetAnimator(
this)
2401#if QT_CONFIG(dockwidget)
2402#if QT_CONFIG(tabbar)
2406#if QT_CONFIG(tabwidget)
2431#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar)
2438#if QT_CONFIG(statusbar)
2439QStatusBar *QMainWindowLayout::statusBar()
const
2442void QMainWindowLayout::setStatusBar(
QStatusBar *sb)
2463#if QT_CONFIG(dockwidget)
2465 savedState.dockAreaLayout.fallbackToSizeHints =
true;
2473#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2488 QDockWidgetGroupWindow *floatingTabs =
layout->createTabbedDockWindow();
2494 floatingTabs->show();
2495 floatingTabs->raise();
2496 *
item =
new QDockWidgetGroupWindowItem(floatingTabs);
2502#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2506 if (qobject_cast<QDockWidget *>(
w)) {
2538#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2539 auto *groupWindow = qobject_cast<const QDockWidgetGroupWindow *>(
widget->
parentWidget());
2541 if (
group && groupWindow->tabLayoutInfo()) {
2555 && unplugGroup(
this, &
item, parentItem)) {
2567 QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
2579 info->tabbed =
true;
2580 info->tabBar = getTabBar();
2581 info->tabBar->hide();
2582 updateGapIndicator();
2588 parentItem.
widgetItem =
new QDockWidgetGroupWindowItem(floatingTabs);
2589 layoutState.dockAreaLayout.docks[dockPos].item_list.append(parentItem);
2593 info->item_list = {parentItem};
2596 for (
const auto &listItem :
layoutState.dockAreaLayout.docks[dockPos].item_list) {
2597 if (listItem.GapItem || !listItem.widgetItem)
2599 info->tabBar->addTab(listItem.widgetItem->widget()->objectName());
2604 floatingTabs->layoutInfo()->fitItems();
2606 groupWindow->layoutInfo()->fitItems();
2609 info->reparentWidgets(floatingTabs);
2611 info->updateTabBar();
2622 updateGapIndicator();
2624 floatingTabs->show();
2625 floatingTabs->raise();
2643#if QT_CONFIG(dockwidget)
2646#if QT_CONFIG(tabwidget)
2648 && unplugGroup(
this, &
item,
2657 switch (dockWidgetArea(dw)) {
2660 r.setHeight(
r.height() -
sep);
2664 r.setWidth(
r.width() -
sep);
2675 const auto *
layout = qobject_cast<QDockWidgetLayout *>(dw->
layout());
2676 const bool verticalTitleBar =
layout ?
layout->verticalTitleBar :
false;
2680 const int minHeight = verticalTitleBar ? 2 * tbHeight : tbHeight;
2681 const int minWidth = verticalTitleBar ? tbHeight : 2 * tbHeight;
2682 r.setSize(
r.size().expandedTo(
QSize(minWidth, minHeight)));
2683 qCDebug(lcQpaDockWidgets) << dw <<
"will be unplugged with size" <<
r.
size();
2685 dw->d_func()->unplug(
r);
2689#if QT_CONFIG(toolbar)
2691 tb->d_func()->unplug(
r);
2695#if !QT_CONFIG(dockwidget) || !QT_CONFIG(tabbar)
2703 updateGapIndicator();
2710void QMainWindowLayout::updateGapIndicator()
2712#if QT_CONFIG(rubberband)
2715 || currentHoveredFloat
2719#if QT_CONFIG(dockwidget)
2720 currentHoveredFloat ? currentHoveredFloat.data() :
2723 if (!gapIndicator) {
2726 gapIndicator->setObjectName(
"qt_rubberband"_L1);
2727 }
else if (gapIndicator->parent() != expectedParent) {
2728 gapIndicator->setParent(expectedParent);
2732 const bool sigBlockState = gapIndicator->signalsBlocked();
2733 auto resetSignals =
qScopeGuard([
this, sigBlockState](){ gapIndicator->blockSignals(sigBlockState); });
2734 gapIndicator->blockSignals(
true);
2736#if QT_CONFIG(dockwidget)
2737 if (currentHoveredFloat)
2738 gapIndicator->setGeometry(currentHoveredFloat->currentGapRect);
2743 gapIndicator->show();
2744 gapIndicator->raise();
2748 }
else if (gapIndicator) {
2749 gapIndicator->hide();
2756 const QPoint &mousePos) {
2763#if QT_CONFIG(dockwidget)
2765 || qobject_cast<QDockWidgetGroupWindow *>(
widget))) {
2776 if (!qobject_cast<QDockWidget*>(
w) && !qobject_cast<QDockWidgetGroupWindow *>(
w))
2785 if (QDockWidgetGroupWindow *
group = qobject_cast<QDockWidgetGroupWindow *>(
w)) {
2788 const auto groupChildren =
group->children();
2801 if (screen1 && screen2 && screen1 != screen2)
2803 if (!
w->geometry().contains(mousePos))
2806#if QT_CONFIG(tabwidget)
2807 if (
auto dropTo = qobject_cast<QDockWidget *>(
w)) {
2810 w = dropTo->widget();
2813 if (!qobject_cast<QDockWidgetGroupWindow *>(
w)) {
2814 QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
2815 floatingTabs->setGeometry(dropTo->geometry());
2817 const QTabBar::Shape shape = tabwidgetPositionToTabBarShape(dropTo);
2822 info->tabBar = getTabBar();
2823 info->tabbed =
true;
2825 info->item_list.append(
2828 dropTo->setParent(floatingTabs);
2829 qCDebug(lcQpaDockWidgets) <<
"Wrapping" <<
widget <<
"into floating tabs" << floatingTabs;
2835 qCDebug(lcQpaDockWidgets) <<
"Showing" << dropTo;
2840 auto group = qobject_cast<QDockWidgetGroupWindow *>(
w);
2842 if (
group->hover(hoverTarget,
group->mapFromGlobal(mousePos))) {
2843 setCurrentHoveredFloat(
group);
2849 setCurrentHoveredFloat(
nullptr);
2850 layoutState.dockAreaLayout.fallbackToSizeHints =
false;
2860 if (!
path.isEmpty()) {
2861 bool allowed =
false;
2863#if QT_CONFIG(dockwidget)
2866#if QT_CONFIG(toolbar)
2868 allowed = tb->isAreaAllowed(toToolBarArea(
path.at(1)));
2879 if (
path.isEmpty()) {
2897 if (min.width() >
size.width() || min.height() >
size.height()) {
2906#if QT_CONFIG(dockwidget)
2912 updateGapIndicator();
2915#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2916QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()
2919 new QDockWidgetGroupLayout(
f);
2932#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
2936 for (QDockWidgetGroupWindow *dwgw :
groups)
2937 used += dwgw->layoutInfo()->usedTabBars();
2941 for (
QTabBar *tab_bar : retired) {
2943 while (tab_bar->count() > 0)
2944 tab_bar->removeTab(0);
2945 unusedTabBars.append(tab_bar);
2950 const QSet<QWidget*> retiredSeps = usedSeparatorWidgets - usedSeps;
2951 usedSeparatorWidgets = usedSeps;
2952 for (
QWidget *sepWidget : retiredSeps) {
2953 unusedSeparatorWidgets.append(sepWidget);
3006#if QT_CONFIG(dockwidget)
3008#if QT_CONFIG(tabbar)
3009 for (
QTabBar *tab_bar : std::as_const(usedTabBars))
3019#if QT_CONFIG(draganddrop)
3020bool QMainWindowLayout::needsPlatformDrag()
3022 static const bool wayland =
3028 const QPoint &pressPosition)
3030 draggingWidget = widgetItem;
3036 auto serialize = [](
const auto &
object) {
3043 serialize(
reinterpret_cast<qintptr>(window)));
3044 mimeData->
setData(
"application/x-qt-mainwindowdrag-position"_L1, serialize(pressPosition));
3047 auto result = drag.exec();
3049 draggingWidget =
nullptr;
3056#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.
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
int timerId() const noexcept
Returns the timer's ID.
void stop()
Stops the timer.
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
int readRawData(char *, int len)
Reads at most len bytes from the stream into s and returns the number of bytes read.
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
int version() const
Returns the version number of the data serialization format.
void setVersion(int)
Sets the version number of the data serialization format to v, a value of the \l Version enum.
QDockWidget * apply(bool animate)
QList< QDockAreaLayoutItem > item_list
QDockAreaLayoutInfo * info(const QList< int > &path)
@ FloatingDockWidgetTabMarker
QRect gapRect(const QList< int > &path) const
static QRect constrainedRect(QRect rect, QWidget *widget)
QDockAreaLayoutInfo docks[4]
@ NonClientAreaMouseButtonDblClick
@ NonClientAreaMouseButtonRelease
@ NonClientAreaMouseButtonPress
qint64 size() const
Returns the file size in bytes.
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 int heightForWidth(int) const
Returns the preferred height for this layout item, given the width, which is not used in this default...
virtual void setGeometry(const QRect &)=0
Implemented in subclasses to set this item's geometry to r.
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().
QSize maximumSize() const override
Returns the maximum size of this layout.
void setSizeConstraint(SizeConstraint)
bool activate()
Redoes the layout for parentWidget() if necessary.
virtual void addItem(QLayoutItem *)=0
Implemented in subclasses to add an item.
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
virtual QLayoutItem * takeAt(int index)=0
Must be implemented in subclasses to remove the layout item at index from the layout,...
QSize minimumSize() const override
Returns the minimum size of this layout.
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 int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
virtual void setGeometry(const QRect &) override
\reimp
QLayout * layout() override
\reimp
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
void prepend(rvalue_ref t)
const T & constFirst() const noexcept
const_iterator cend() const noexcept
const_iterator cbegin() 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
QBasicTimer discardRestoredStateTimer
QLayoutItem * unplug(QWidget *widget, bool group=false)
QLayoutItem * itemAt(int index) const override
Must be implemented in subclasses to return the layout item at index.
void setDockOptions(QMainWindow::DockOptions opts)
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)
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
QString objectName
the name of this object
void setParent(QObject *parent)
Makes the object a child of parent.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
QList< T > findChildren(const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
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.
\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 void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void moveBottom(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate.
constexpr void moveRight(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate.
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 int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
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.
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
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.
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.
const char * 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)
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 const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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]
QFileInfo info(fileName)
[8]
myObject disconnect()
[26]
file setParent(multiPart)
QDockAreaLayoutInfo * subinfo
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent