summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-08-11 09:20:44 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2023-08-15 10:47:28 +0200
commite03bc88a80382b68359ba6ea5fc4cb9507ceb85f (patch)
tree4e40c8cd913c44dc3579d1161e30492f51f6f671 /src/widgets/widgets/qmainwindowlayout.cpp
parent95768e38b74ea4189fd3a12b8848e0101e3ab944 (diff)
QDockWidgetGroupWindow::adjustFlags() - don't show() empty group window
The method calls show() on a dock widget group window, when the window flags have changed. When all of its contained, tabbed dock widgets are programmatically hidden or docked on the main window, an empty group window is shown. This patch implements bool hasVisibleDockWidgets(). It returns true, if at least one of the group window's dockwidget children is not hidden. It replaces show() by setVisible(), passing the return value of hasVisibleChildren(). It adapts tst_QDockWidget::floatingTabs() to test the fix. (Drive-by: remove dead code) Fixes: QTBUG-115058 Pick-to: 6.6 6.5 6.2 Change-Id: Ifb8e2450e91a7c78decc06f592e160631ca2faf5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index e9cfd05007..f51fc41494 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -432,6 +432,25 @@ void QDockWidgetGroupWindow::destroyOrHideIfEmpty()
deleteLater();
}
+/*!
+ \internal
+ \return \c true if the group window has at least one visible QDockWidget child,
+ otherwise false.
+ */
+bool QDockWidgetGroupWindow::hasVisibleDockWidgets() const
+{
+ const auto &children = findChildren<QDockWidget *>(Qt::FindChildrenRecursively);
+ for (auto child : children) {
+ // WA_WState_Visible is set on the dock widget, associated to the active tab
+ // and unset on all others.
+ // WA_WState_Hidden is set if the dock widgets have been explicitly hidden.
+ // This is the relevant information to check (equivalent to !child->isHidden()).
+ if (!child->testAttribute(Qt::WA_WState_Hidden))
+ return true;
+ }
+ return false;
+}
+
/*! \internal
Sets the flags of this window in accordance to the capabilities of the dock widgets
*/
@@ -480,7 +499,7 @@ void QDockWidgetGroupWindow::adjustFlags()
m_removedFrameSize = QSize();
}
- show(); // setWindowFlags hides the window
+ setVisible(hasVisibleDockWidgets());
}
QWidget *titleBarOf = top ? top : parentWidget();