Shrink dock areas if main window width/height is below 160px
Empty drop areas have a fixed size of 80 pixels in QDockAreaLayout. If a main window is below 160 pixels wide or high, drop areas start to overlap. If a main window's width or height is 80px or less, drop areas fully overlap. Dock widgets can't be dropped in overlapping areas, because the dock area becomes ambigous. This patch decreases the width and height used to calculate the drop area rectangle by the extent necessary to prevent docking. QDockAreaLayout::sep (margin between a dock widget and its dock) is used as the new minimum height and width. Change-Id: I1db3282cfc7c602b59bb2f20ba616efe1719b0cb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>bb10
parent
656dde05e8
commit
a5dec542fa
|
|
@ -2452,28 +2452,33 @@ QRect QDockAreaLayout::gapRect(QInternal::DockPosition dockPos) const
|
|||
{
|
||||
Q_ASSERT_X(mainWindow, "QDockAreaLayout::gapRect", "Called without valid mainWindow pointer.");
|
||||
|
||||
// Determine gap size depending on MainWindow size (QTBUG-101657)
|
||||
const QSize gapSize = (mainWindow->size()/2).boundedTo(QSize(EmptyDropAreaSize, EmptyDropAreaSize));
|
||||
|
||||
// Warn if main window is too small to create proper docks.
|
||||
// Do not fail because this can be triggered by the user.
|
||||
if (mainWindow->height() < (2 * EmptyDropAreaSize)) {
|
||||
qCWarning(lcQpaDockWidgets, "QDockAreaLayout::gapRect: Main window height %i is too small. Docking will not be possible.",
|
||||
mainWindow->height());
|
||||
// Do not fail because this can be triggered by a user making MainWindow too small
|
||||
if (mainWindow->height() < (2 * sep)) {
|
||||
qCWarning(lcQpaDockWidgets,
|
||||
"QDockAreaLayout::gapRect: Main window height %i is too small. Docking will not be possible.",
|
||||
mainWindow->height());
|
||||
|
||||
}
|
||||
if (mainWindow->width() < (2 * EmptyDropAreaSize)) {
|
||||
qCWarning(lcQpaDockWidgets, "QDockAreaLayout::gapRect: Main window width %i is too small. Docking will not be possible.",
|
||||
mainWindow->width());
|
||||
if (mainWindow->width() < (2 * sep)) {
|
||||
qCWarning(lcQpaDockWidgets,
|
||||
"QDockAreaLayout::gapRect: Main window width %i is too small. Docking will not be possible.",
|
||||
mainWindow->width());
|
||||
}
|
||||
|
||||
// Calculate rectangle of requested dock
|
||||
switch (dockPos) {
|
||||
case QInternal::LeftDock:
|
||||
return QRect(rect.left(), rect.top(), EmptyDropAreaSize, rect.height());
|
||||
return QRect(rect.left(), rect.top(), gapSize.width(), rect.height());
|
||||
case QInternal::RightDock:
|
||||
return QRect(rect.right() - EmptyDropAreaSize, rect.top(), EmptyDropAreaSize, rect.height());
|
||||
return QRect(rect.right() - gapSize.width(), rect.top(), gapSize.width(), rect.height());
|
||||
case QInternal::TopDock:
|
||||
return QRect(rect.left(), rect.top(), rect.width(), EmptyDropAreaSize);
|
||||
return QRect(rect.left(), rect.top(), rect.width(), gapSize.height());
|
||||
case QInternal::BottomDock:
|
||||
return QRect(rect.left(), rect.bottom() - EmptyDropAreaSize, rect.width(), EmptyDropAreaSize);
|
||||
return QRect(rect.left(), rect.bottom() - gapSize.height(), rect.width(), gapSize.height());
|
||||
case QInternal::DockCount:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue