diff options
author | Axel Spoerl <Axel.Spoerl@qt.io> | 2022-03-10 16:47:26 +0100 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2022-03-11 09:57:07 +0000 |
commit | dfe5f991207dcc74868d41feae5bc2bbad277808 (patch) | |
tree | b4dae8d3015522171f8f352223faa5009b3c7118 /src/widgets/widgets/qmainwindowlayout.cpp | |
parent | 7d77deb281d6b0491415e64136b34c0e231e5556 (diff) |
Fix QDockWidget's dock area permissions after hovering
When a QDockWidget's dock areas are restricted by setAllowedAreas(...)
and a second QDockWidget is hovered over it, the first QDockWidget can
be docked to any dock area of the main window. Area restrictions will
be ignored.
That is due to the first QDockWidget being implicitely mutated into a
QDockWidgetGroupWindow upon hovering. By definition, the latter has no
docking restricitons.
This fix adds a check if a QDockWidgetGroupWindow has a single QDockWidget child.
In that case, the single child's area permissions will restrict docking.
Fixes: QTBUG-100670
Pick-to: 6.3 6.2 5.15
Change-Id: I903b074739953791634f482c9cf4b9a95a1d93d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 60db982cb7..3346e0202f 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2725,8 +2725,18 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1))); - if (qobject_cast<QDockWidgetGroupWindow *>(widget)) - allowed = true; + // Read permissions from a DockWidgetGroupWindow depending on its DockWidget children + if (QDockWidgetGroupWindow* dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) { + const QList<QDockWidget*> children = dwgw->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly); + + if (children.count() == 1) { + // Group window has a single child => read its permissions + allowed = children.at(0)->isAreaAllowed(toDockWidgetArea(path.at(1))); + } else { + // Group window has more than one or no children => dock it anywhere + allowed = true; + } + } #endif #if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) |