summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp70
1 files changed, 41 insertions, 29 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index c5b08387a3..939453473a 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -221,11 +221,10 @@ public:
}
void setGeometry(const QRect&r) Q_DECL_OVERRIDE
{
+ static_cast<QDockWidgetGroupWindow *>(parent())->destroyOrHideIfEmpty();
QDockAreaLayoutInfo *li = layoutInfo();
- if (li->isEmpty()) {
- static_cast<QDockWidgetGroupWindow *>(parent())->destroyIfEmpty();
+ if (li->isEmpty())
return;
- }
int fw = frameWidth();
li->reparentWidgets(parentWidget());
li->rect = r.adjusted(fw, fw, -fw, -fw);
@@ -278,6 +277,10 @@ bool QDockWidgetGroupWindow::event(QEvent *e)
if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
adjustFlags();
break;
+ case QEvent::LayoutRequest:
+ // We might need to show the widget again
+ destroyOrHideIfEmpty();
+ break;
default:
break;
}
@@ -331,34 +334,43 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
}
/*! \internal
- Destroy this window if there is no more QDockWidget in it.
+ Destroy or hide this window if there is no more QDockWidget in it.
+ Otherwise make sure it is shown.
*/
-void QDockWidgetGroupWindow::destroyIfEmpty()
-{
- if (layoutInfo()->isEmpty()) {
- // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent
- foreach (QDockWidget *dw,
- findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
- bool wasFloating = dw->isFloating();
- bool wasHidden = dw->isHidden();
- dw->setParent(parentWidget());
- if (wasFloating) {
- dw->setFloating(true);
- } else {
- // maybe it was hidden, we still have to put it back in the main layout.
- QMainWindowLayout *ml = qt_mainwindow_layout(static_cast<QMainWindow*>(parentWidget()));
- Qt::DockWidgetArea area = ml->dockWidgetArea(this);
- if (area == Qt::NoDockWidgetArea)
- area = Qt::LeftDockWidgetArea;
- static_cast<QMainWindow*>(parentWidget())->addDockWidget(area, dw);
- }
- if (!wasHidden)
- dw->show();
+void QDockWidgetGroupWindow::destroyOrHideIfEmpty()
+{
+ if (!layoutInfo()->isEmpty()) {
+ show(); // It might have been hidden,
+ return;
+ }
+ // There might still be placeholders
+ if (!layoutInfo()->item_list.isEmpty()) {
+ hide();
+ return;
+ }
+
+ // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent
+ foreach (QDockWidget *dw, findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
+ bool wasFloating = dw->isFloating();
+ bool wasHidden = dw->isHidden();
+ dw->setParent(parentWidget());
+ if (wasFloating) {
+ dw->setFloating(true);
+ } else {
+ // maybe it was hidden, we still have to put it back in the main layout.
+ QMainWindowLayout *ml =
+ qt_mainwindow_layout(static_cast<QMainWindow *>(parentWidget()));
+ Qt::DockWidgetArea area = ml->dockWidgetArea(this);
+ if (area == Qt::NoDockWidgetArea)
+ area = Qt::LeftDockWidgetArea;
+ static_cast<QMainWindow *>(parentWidget())->addDockWidget(area, dw);
}
- foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))
- tb->setParent(parentWidget());
- deleteLater();
+ if (!wasHidden)
+ dw->show();
}
+ foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))
+ tb->setParent(parentWidget());
+ deleteLater();
}
/*! \internal
@@ -2093,7 +2105,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
item.subinfo->reparentWidgets(parentWidget());
item.subinfo->setTabBarShape(parentInfo->tabBarShape);
}
- dwgw->destroyIfEmpty();
+ dwgw->destroyOrHideIfEmpty();
}
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {