summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-11-09 16:25:49 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-11-09 16:25:49 (GMT)
commit963d42fbf1fb68c2bd09b12dedbad000d8001b94 (patch)
treec1c8cc710fe1e6ebf08f03fa4347b616a574237e
parent0b7a5ebb7c4a65a931d2c69b9d3780cdc6ece893 (diff)
downloadQt-963d42fbf1fb68c2bd09b12dedbad000d8001b94.zip
Qt-963d42fbf1fb68c2bd09b12dedbad000d8001b94.tar.gz
Qt-963d42fbf1fb68c2bd09b12dedbad000d8001b94.tar.bz2
Make sure the dock widget is updated when changing closable property
Task-number: QTBUG-1665 Reviewed-by: ogoffart
-rw-r--r--src/gui/widgets/qdockwidget.cpp5
-rw-r--r--tests/auto/qdockwidget/tst_qdockwidget.cpp18
2 files changed, 23 insertions, 0 deletions
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<QDockWidgetLayout*>(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"