summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2024-02-27 16:42:24 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2024-02-29 21:14:40 +0000
commitcd2a3e970aaeb8f5f92d9c6e52ede7a82f953150 (patch)
tree56ec630d42c6164cc0dbee810ac592c23aba1451 /src/widgets/widgets/qmainwindow.cpp
parent08dde3ac0c5005ee48848a6fac9d03fe1fe2f184 (diff)
Refactor and fix QMainWindow::tabifiedDockWidgets()
The method traversed QDockAreaLayoutInfo::item_list, to identify dock widgets tabbed with the QDockWidget argument in a tab bar It relied on bool QDockAreLayoutInfo::tabbed, which is set to true, when a QMainWindowTabBar is to be added to a QDockAreaLayoutInfo. This flag isn't cleared, when the second last dock widget is removed from the tab bar. It can't be replaced by QMainWindowLayout::isDockWidgetTabbed, because the flag also represents intermediate states, where e.g. a dock widget is hovered over, prepares to become a floating tab and then rolls back, because hovering doesn't result in a drop. In that case, tabbed must become true, which the dock widget isn't actually tabbed. Furthermore, the way to traverse item_list didn't find dock widgets in a floating tab. In that case, tabifiedDockWidgets() wrongly returned an empty list. To fix both issues, refactor QMainWindow::tabifiedDockWidgets() to read the list of dock widgets directly from the QMainWindowTabBar. Add tests in tst_QDockWidget::floatingTabs() and updateTabBarOnVisibilityChanged() Fixes: QTBUG-122001 Pick-to: 6.7 6.6 6.5 Change-Id: Ia9eb3711be642101261f34ee447521cc6accc20c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index a91128ba09..30176edd49 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1123,21 +1123,8 @@ void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const
{
- QList<QDockWidget*> ret;
- const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget);
- if (info && info->tabbed && info->tabBar) {
- for(int i = 0; i < info->item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = info->item_list.at(i);
- if (item.widgetItem) {
- if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) {
- if (dock != dockwidget) {
- ret += dock;
- }
- }
- }
- }
- }
- return ret;
+ Q_D(const QMainWindow);
+ return d->layout ? d->layout->tabifiedDockWidgets(dockwidget) : QList<QDockWidget *>();
}
#endif // QT_CONFIG(tabbar)