diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index c107699252a..aa5e0a9427d 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -169,20 +169,16 @@ void SubWindow::changeEvent( QEvent *event ) void SubWindow::setVisible(bool visible) { - if (isDetached()) + if (isDetached() || visible) { // When detached, top-level window is the child widget itself. (This is janky and is best changed at some point.) // For that reason we forward show/hide to the child widget, and don't touch the hidden attached window frame. widget()->setVisible(visible); } - else + if (!isDetached()) { // When attached, visibility of the actual window is controlled by SubWindow. - // SubWindow::hide() when it's already hidden still causes a size recalculation, - // if the child widget is hidden it does not get included into the layout, and maximum size is set to 0x0. - // There shouldn't be a reason to keep the child widget hidden when the subwindow is attached. - // see bug #8292 - widget()->show(); + // Nevertheless, the subwindow contents still need to be visible, which is addressed above. QMdiSubWindow::setVisible(visible); } } @@ -617,10 +613,6 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) switch (event->type()) { - case QEvent::WindowStateChange: - event->accept(); - return true; - case QEvent::Close: if (isDetached()) { @@ -649,6 +641,15 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) hide(); } return QMdiSubWindow::eventFilter(obj, event); + + case QEvent::Hide: + layout()->setSizeConstraint(QLayout::SetNoConstraint); + return QMdiSubWindow::eventFilter(obj, event); + + case QEvent::Show: + layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); + resize(widget()->size().addMargins(decorationMargins())); // manually sync the sizes again + return QMdiSubWindow::eventFilter(obj, event); default: return QMdiSubWindow::eventFilter(obj, event);