From 6d44daddab9f36fd8c34bb3776c0fb0d93635e6e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 10 Mar 2010 15:56:25 +0200 Subject: Fixed dialog resize not to move the dialog for Symbian. QDialog::resize() also moved the dialog in Symbian. This occured since adjustPosition was called as an result of resize and that method did not check if dialog position was explicitly set. In addition it was found that in Symbian WA_Resized and WA_Moved attributes were basically set for almost all top-level widgets by system. This was also fixed and a new auto test was introduced to verify these attributes in all platforms. Windows platform also suffers from bug in this area, and a separate task QTBUG-5897 for it was created Task-number: QTBUG-5897 Reviewed-by: Sami Merila --- src/gui/dialogs/qdialog.cpp | 11 ++++++-- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/kernel/qwidget_s60.cpp | 7 ++++- tests/auto/qwidget/tst_qwidget.cpp | 53 +++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index d86d63e..d8ac9a8 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -415,8 +415,15 @@ bool QDialog::event(QEvent *e) result = true; } #else - if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) - adjustPosition(parentWidget()); + if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) { + if (!testAttribute(Qt::WA_Moved)) { + Qt::WindowStates state = windowState(); + adjustPosition(parentWidget()); + setAttribute(Qt::WA_Moved, false); // not really an explicit position + if (state != windowState()) + setWindowState(state); + } + } #endif return result; } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 395ceca..79b2bff 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1034,7 +1034,7 @@ void QSymbianControl::HandleResourceChange(int resourceType) qwidget->adjustSize(); qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize } - if (!qwidget->testAttribute(Qt::WA_Moved)) { + if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { TRect r = static_cast(S60->appUi())->ClientRect(); SetPosition(r.iTl); qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 7fb21d2..81c4198 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1052,6 +1052,8 @@ void QWidget::setWindowState(Qt::WindowStates newstate) return; if (isWindow()) { + const bool wasResized = testAttribute(Qt::WA_Resized); + const bool wasMoved = testAttribute(Qt::WA_Moved); QSymbianControl *window = static_cast(effectiveWinId()); if (window && newstate & Qt::WindowMinimized) { @@ -1090,7 +1092,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) createWinId(); Q_ASSERT(testAttribute(Qt::WA_WState_Created)); // Ensure the initial size is valid, since we store it as normalGeometry below. - if (!testAttribute(Qt::WA_Resized) && !isVisible()) + if (!wasResized && !isVisible()) adjustSize(); QTLWExtra *top = d->topData(); @@ -1105,6 +1107,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate) //restore normal geometry top->normalGeometry = normalGeometry; + + setAttribute(Qt::WA_Resized, wasResized); + setAttribute(Qt::WA_Moved, wasMoved); } data->window_state = newstate; diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index abd9604..f03b7d7 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -402,6 +402,7 @@ private slots: void scrollWithoutBackingStore(); void taskQTBUG_7532_tabOrderWithFocusProxy(); + void movedAndResizedAttributes(); private: bool ensureScreenSize(int width, int height); @@ -10040,5 +10041,57 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() // No Q_ASSERT, then it's allright. } +void tst_QWidget::movedAndResizedAttributes() +{ + QWidget w; + w.show(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowFullScreen); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMaximized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMinimized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showMaximized(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showFullScreen(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + w.move(10,10); + QVERIFY(w.testAttribute(Qt::WA_Moved)); +#if defined(Q_OS_WIN) + QEXPECT_FAIL("", "FixMe, QTBUG-8911", Abort); +#endif + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.resize(100, 100); + QVERIFY(w.testAttribute(Qt::WA_Moved)); + QVERIFY(w.testAttribute(Qt::WA_Resized)); + +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v0.12