QDockWidget: Restore using setGeometry since the geometry is used for the state
This solves an instance where restoreState() was used when the dockwidget was already floating and the saved state was also for a floating dockwidget. Change-Id: I1fe764ae2a6b0351ae26e33ffec682ad37c944d7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
b84c61b088
commit
0c019d7bd2
|
|
@ -1944,12 +1944,8 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
|
|||
qt_mac_set_drawer_preferred_edge(widget, toDockWidgetArea(dockPos));
|
||||
} else
|
||||
#endif
|
||||
if (!testing) {
|
||||
QRect r(x, y, w, h);
|
||||
r = QDockAreaLayout::constrainedRect(r, widget);
|
||||
widget->move(r.topLeft());
|
||||
widget->resize(r.size());
|
||||
}
|
||||
if (!testing)
|
||||
widget->setGeometry(QDockAreaLayout::constrainedRect(QRect(x, y, w, h), widget));
|
||||
|
||||
if (!testing) {
|
||||
widget->setVisible(flags & StateFlagVisible);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ private slots:
|
|||
void titleBarDoubleClick();
|
||||
void restoreStateOfFloating();
|
||||
void restoreDockWidget();
|
||||
void restoreStateWhileStillFloating();
|
||||
// task specific tests:
|
||||
void task165177_deleteFocusWidget();
|
||||
void task169808_setFloating();
|
||||
|
|
@ -757,6 +758,31 @@ void tst_QDockWidget::restoreStateOfFloating()
|
|||
QVERIFY(!dock->isFloating());
|
||||
}
|
||||
|
||||
void tst_QDockWidget::restoreStateWhileStillFloating()
|
||||
{
|
||||
// When the dock widget is already floating then it takes a different code path
|
||||
// so this test covers the case where the restoreState() is effectively just
|
||||
// moving it back and resizing it
|
||||
const QRect availGeom = QApplication::desktop()->availableGeometry();
|
||||
const QPoint startingDockPos = availGeom.center();
|
||||
QMainWindow mw;
|
||||
QDockWidget *dock = createTestDock(mw);
|
||||
mw.addDockWidget(Qt::TopDockWidgetArea, dock);
|
||||
dock->setFloating(true);
|
||||
dock->move(startingDockPos);
|
||||
mw.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&mw));
|
||||
QVERIFY(dock->isFloating());
|
||||
QByteArray ba = mw.saveState();
|
||||
const QPoint dockPos = dock->pos();
|
||||
dock->move(availGeom.topLeft() + QPoint(10, 10));
|
||||
dock->resize(dock->size() + QSize(10, 10));
|
||||
QVERIFY(mw.restoreState(ba));
|
||||
QVERIFY(dock->isFloating());
|
||||
if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive))
|
||||
QTRY_COMPARE(dock->pos(), dockPos);
|
||||
}
|
||||
|
||||
void tst_QDockWidget::restoreDockWidget()
|
||||
{
|
||||
QByteArray geometry;
|
||||
|
|
|
|||
Loading…
Reference in New Issue