From 963d42fbf1fb68c2bd09b12dedbad000d8001b94 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 9 Nov 2009 17:25:49 +0100 Subject: Make sure the dock widget is updated when changing closable property Task-number: QTBUG-1665 Reviewed-by: ogoffart --- src/gui/widgets/qdockwidget.cpp | 5 +++++ tests/auto/qdockwidget/tst_qdockwidget.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index a8e2a37..9cf6af1 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1225,6 +1225,7 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) features &= DockWidgetFeatureMask; if (d->features == features) return; + const bool closableChanged = (d->features ^ features) & DockWidgetClosable; d->features = features; QDockWidgetLayout *layout = qobject_cast(this->layout()); @@ -1233,6 +1234,10 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable); emit featuresChanged(d->features); update(); + if (closableChanged && layout->nativeWindowDeco()) { + //this ensures the native decoration is drawn + d->setWindowState(true /*floating*/, true /*unplug*/); + } } QDockWidget::DockWidgetFeatures QDockWidget::features() const diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index e62ba8c..eb3f641 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -93,6 +93,7 @@ private slots: void task237438_setFloatingCrash(); void task248604_infiniteResize(); void task258459_visibilityChanged(); + void taskQTBUG_1665_closableChanged(); }; // Testing get/set functions @@ -834,5 +835,22 @@ void tst_QDockWidget::task258459_visibilityChanged() QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible } +void tst_QDockWidget::taskQTBUG_1665_closableChanged() +{ + QDockWidget dock; + dock.show(); + QTest::qWaitForWindowShown(&dock); + + if (dock.windowFlags() & Qt::FramelessWindowHint) + QSKIP("this machine doesn't support native dock widget", SkipAll); + + QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint); + + //now let's remove the closable attribute + dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable); + QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint)); +} + + QTEST_MAIN(tst_QDockWidget) #include "tst_qdockwidget.moc" -- cgit v0.12