QDockWidget: Keep position when undocking.
Initialize undockedGeometry to roughly the current position. Task-number: QTBUG-31044 Change-Id: I03cbe280d1215bb58ab721b60e29b45359cde76d Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
parent
0715dc9ee3
commit
0d459619a9
@ -1259,6 +1259,9 @@ void QDockWidget::setFloating(bool floating)
|
||||
d->endDrag(true);
|
||||
|
||||
QRect r = d->undockedGeometry;
|
||||
// Keep position when undocking for the first time.
|
||||
if (floating && isVisible() && !r.isValid())
|
||||
r = QRect(mapToGlobal(QPoint(0, 0)), size());
|
||||
|
||||
d->setWindowState(floating, false, floating ? r : QRect());
|
||||
|
||||
|
@ -347,7 +347,9 @@ void tst_QDockWidget::features()
|
||||
|
||||
void tst_QDockWidget::setFloating()
|
||||
{
|
||||
const QRect deskRect = QApplication::desktop()->availableGeometry();
|
||||
QMainWindow mw;
|
||||
mw.move(deskRect.left() + deskRect.width() * 2 / 3, deskRect.top() + deskRect.height() / 3);
|
||||
QDockWidget dw;
|
||||
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
|
||||
|
||||
@ -355,10 +357,16 @@ void tst_QDockWidget::setFloating()
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&mw));
|
||||
|
||||
QVERIFY(!dw.isFloating());
|
||||
const QPoint dockedPosition = dw.mapToGlobal(dw.pos());
|
||||
|
||||
QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool)));
|
||||
|
||||
dw.setFloating(true);
|
||||
const QPoint floatingPosition = dw.pos();
|
||||
|
||||
// QTBUG-31044, show approximately at old position, give or take window frame.
|
||||
QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50);
|
||||
|
||||
QVERIFY(dw.isFloating());
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
|
||||
|
Loading…
x
Reference in New Issue
Block a user