summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-05 06:39:30 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-05 13:57:12 +0200
commit657c2bfbeceda3faa2c7a76b4ccec6a65a3445a2 (patch)
tree83e0a1dab04afb291e181bb8fb6152ba96678795 /src/widgets/widgets/qmainwindowlayout.cpp
parent676129d7ee57347798683d444823e7723776d8ec (diff)
parentb94111116f09a6e48741d35cf7abea47af99ef26 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/testlib/selftests/generate_expected_output.py Change-Id: If856162abf9a24ae2c9946d336a7d1da03520fa7
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 b2c7225e8a..b138c42ba2 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
@@ -2089,7 +2101,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)) {