Fix size calculation of unplugged dock widgets
When unplugging a dock widget, it still grows by the separator size when dragged upwards or to the left. The unplugged dock widget's size can become too small to drag it or to access window handles. This patch corrects the size offset for all drag directions. It expands the target size to a minimum size, making sure that title bar and window handles can be accessed after unplugging. Fixes: QTBUG-106531 Pick-to: 6.5 6.4 6.2 Change-Id: Ie771a9338ebfb4c0eafd3b3b4205de730cbd20ac Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
c69e727274
commit
e29ffd3bd1
@ -2654,21 +2654,36 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
|
|||||||
} else
|
} else
|
||||||
#endif // QT_CONFIG(tabwidget)
|
#endif // QT_CONFIG(tabwidget)
|
||||||
{
|
{
|
||||||
// Dock widget is unplugged from the main window
|
// Dock widget is unplugged from a main window dock
|
||||||
// => geometry needs to be adjusted by separator size
|
// => height or width need to be decreased by separator size
|
||||||
switch (dockWidgetArea(dw)) {
|
switch (dockWidgetArea(dw)) {
|
||||||
case Qt::LeftDockWidgetArea:
|
case Qt::LeftDockWidgetArea:
|
||||||
case Qt::RightDockWidgetArea:
|
case Qt::RightDockWidgetArea:
|
||||||
r.adjust(0, 0, 0, -sep);
|
r.setHeight(r.height() - sep);
|
||||||
break;
|
break;
|
||||||
case Qt::TopDockWidgetArea:
|
case Qt::TopDockWidgetArea:
|
||||||
case Qt::BottomDockWidgetArea:
|
case Qt::BottomDockWidgetArea:
|
||||||
r.adjust(0, 0, -sep, 0);
|
r.setWidth(r.width() - sep);
|
||||||
break;
|
break;
|
||||||
case Qt::NoDockWidgetArea:
|
case Qt::NoDockWidgetArea:
|
||||||
case Qt::DockWidgetArea_Mask:
|
case Qt::DockWidgetArea_Mask:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Depending on the title bar layout (vertical / horizontal),
|
||||||
|
// width and height have to provide minimum space for window handles
|
||||||
|
// and mouse dragging.
|
||||||
|
// Assuming horizontal title bar, if the dock widget does not have a layout.
|
||||||
|
const auto *layout = qobject_cast<QDockWidgetLayout *>(dw->layout());
|
||||||
|
const bool verticalTitleBar = layout ? layout->verticalTitleBar : false;
|
||||||
|
const int tbHeight = QApplication::style()
|
||||||
|
? QApplication::style()->pixelMetric(QStyle::PixelMetric::PM_TitleBarHeight)
|
||||||
|
: 20;
|
||||||
|
const int minHeight = verticalTitleBar ? 2 * tbHeight : tbHeight;
|
||||||
|
const int minWidth = verticalTitleBar ? tbHeight : 2 * tbHeight;
|
||||||
|
r.setSize(r.size().expandedTo(QSize(minWidth, minHeight)));
|
||||||
|
qCDebug(lcQpaDockWidgets) << dw << "will be unplugged with size" << r.size();
|
||||||
|
|
||||||
dw->d_func()->unplug(r);
|
dw->d_func()->unplug(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user