Fix floating windows not restoring to previous position

The dock widget wrapper that we deleted had that info. We need
to preserve it.
This commit is contained in:
Sergio Martins
2022-02-04 16:57:44 +00:00
parent 719803ecfa
commit 4f8aac7df3
2 changed files with 19 additions and 2 deletions

View File

@@ -157,8 +157,21 @@ FloatingWindow::FloatingWindow(Frame *frame, QRect suggestedGeometry, MainWindow
return;
}
auto dwMDIWrapper = frame->dockWidgetAt(0);
auto dropAreaMDIWrapper = dwMDIWrapper->d->mdiDropAreaWrapper();
DockWidgetBase *dwMDIWrapper = frame->dockWidgetAt(0);
DropArea *dropAreaMDIWrapper = dwMDIWrapper->d->mdiDropAreaWrapper();
if (dropAreaMDIWrapper->hasSingleFrame()) {
Frame *innerFrame = dropAreaMDIWrapper->frames().constFirst();
if (innerFrame->hasSingleDockWidget()) {
// When pressing the unfloat button, the dock widgets gets docked to the previous
// position it was at. DockWidgetBase::Private::m_lastPosition stores that location,
// however, when having nested MDI, we have an extra Dock Widget, the wrapper, and it
// contains the last position. So, when floating, we need to transfer that and not lose it.
DockWidgetBase *dw = innerFrame->dockWidgetAt(0);
dw->d->lastPosition() = dwMDIWrapper->d->lastPosition();
}
}
m_dropArea->addMultiSplitter(dropAreaMDIWrapper, Location_OnTop);
dwMDIWrapper->deleteLater();
} else {

View File

@@ -5267,6 +5267,10 @@ void TestDocks::tst_mdi_mixed_with_docking2()
QVERIFY(!lastMdiFrame->titleBar()->isFloating());
lastMdiFrame->titleBar()->onFloatClicked();
QVERIFY(mdiWidget2->isFloating());
// put it in the MDI area again
mdiWidget2->titleBar()->onFloatClicked();
QVERIFY(!mdiWidget2->isFloating());
}
void TestDocks::tst_mdi_mixed_with_docking_setMDISize()