summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2022-09-23 16:50:09 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2022-09-24 07:06:42 +0200
commitd46f317c8e69376b5f124fba3c42fff5e394699f (patch)
tree40e80c757178d8ab0c51189d1099220a515c4529 /src/widgets/widgets
parentd35feca20c02539d04f10c23fc057454cb3fcc12 (diff)
Fix native titlebar offset and resizing upon unplugging dock widgets
When a dock widget received a native title bar upon unplugging, the position of the newly unplugged dock widget was calculated without taking the title bar's height into consideration. Furthermore, dock widgets grew by the separator size upon undocking. That is fixed by 10a143ccd762c810f4096a5b2e986d16ea0107ad by relying on the assumption that passing a QRect() to the unplugging method leads to un unchanged dock widget geometry. However, when more than one dock widgets are docked in the same main window dock on macOS or Windows, the size is stil increased. This patch corrects the position offset for native title bars. It also corrects an unplugged dock widget's geometry by the sparator's size. Fixes: QTBUG-106530 Fixes: QTBUG-106531 Pick-to: 6.4 6.2 5.15 Change-Id: Ia4bcb556841e14146f19c1377f4010d5ae009bcf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qdockwidget.cpp8
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp17
2 files changed, 22 insertions, 3 deletions
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index eb6f1d83c1..cf9c1d565c 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1013,12 +1013,18 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
pos = event->globalPosition().toPoint() - state->pressPos - windowMarginOffset;
}
+ // If the newly floating dock widget has got a native title bar,
+ // offset the position by the native title bar's height or width
+ const int dx = q->geometry().x() - q->x();
+ const int dy = q->geometry().y() - q->y();
+ pos.rx() += dx;
+ pos.ry() += dy;
+
QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
if (floatingTab && !q->isFloating())
floatingTab->move(pos);
else
q->move(pos);
-
if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPosition().toPoint());
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index d5ea3d6e24..dc90731c68 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -2655,8 +2655,21 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
#endif // QT_CONFIG(tabwidget)
{
// Dock widget is unplugged from the main window
- // => geometry is not supposed to change
- dw->d_func()->unplug(QRect());
+ // => geometry needs to be adjusted by separator size
+ switch (dockWidgetArea(dw)) {
+ case Qt::LeftDockWidgetArea:
+ case Qt::RightDockWidgetArea:
+ r.adjust(0, 0, 0, -sep);
+ break;
+ case Qt::TopDockWidgetArea:
+ case Qt::BottomDockWidgetArea:
+ r.adjust(0, 0, -sep, 0);
+ break;
+ case Qt::NoDockWidgetArea:
+ case Qt::DockWidgetArea_Mask:
+ break;
+ }
+ dw->d_func()->unplug(r);
}
}
#endif // QT_CONFIG(dockwidget)