Don't set the FloatingWindow geometry directly

Let's have an indirection, so FloatingWindow can do some adjustments
and use a smaller rect incase of max-size.

Since we don't want to enforce max-size, just when showing the window.
This commit is contained in:
Sergio Martins
2020-06-04 21:21:11 +01:00
parent 69a737e286
commit 874fd7d69f
3 changed files with 22 additions and 3 deletions

View File

@@ -84,6 +84,11 @@ public:
updateTitle();
}
FloatingWindow *floatingWindow() const
{
return qobject_cast<FloatingWindow*>(q->window());
}
QPoint defaultCenterPosForFloating();
void updateTitle();
@@ -265,9 +270,10 @@ void DockWidgetBase::setFloating(bool floats)
}
auto lastGeo = lastPositions().lastFloatingGeometry();
if (lastGeo.isValid())
window()->setGeometry(lastGeo);
if (lastGeo.isValid()) {
if (auto fw = d->floatingWindow())
fw->setSuggestedGeometry(lastGeo);
}
} else {
saveLastFloatingGeometry();
d->restoreToPreviousPosition();