summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-10-28 10:31:33 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-10-28 10:33:29 (GMT)
commit44f8fac4e2fc4a4258b921ac595c2826ca96e99c (patch)
tree2eb123b1b431ca43bcf3a681ebc04d7fd5a98c22
parent42fdaf078b9332e13d260df00359e8adc8522872 (diff)
downloadQt-44f8fac4e2fc4a4258b921ac595c2826ca96e99c.zip
Qt-44f8fac4e2fc4a4258b921ac595c2826ca96e99c.tar.gz
Qt-44f8fac4e2fc4a4258b921ac595c2826ca96e99c.tar.bz2
Double-clicking a dock widget titlebar could make it disappear
If it wasn't already docked on a mainwindow, its state would become unexpected. Task-number: QTBUG-945 Reviewed-by: gabi
-rw-r--r--src/gui/widgets/qdockwidget.cpp10
-rw-r--r--tests/auto/qdockwidget/tst_qdockwidget.cpp19
2 files changed, 25 insertions, 4 deletions
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 6710275..a8e2a37 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -685,8 +685,6 @@ void QDockWidgetPrivate::_q_toggleTopLevel()
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
- Q_Q(QDockWidget);
-
if (state != 0)
return;
@@ -694,8 +692,6 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
Q_ASSERT(layout != 0);
- if (layout->layoutState.indexOf(q).isEmpty()) //The dock widget has not been added into the main window
- return;
if (layout->pluggingWidget != 0) // the main window is animating a docking operation
return;
@@ -1012,6 +1008,12 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
{
Q_Q(QDockWidget);
+ if (!floating && parent) {
+ QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
+ if (!mwlayout || mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
+ return; // this dockwidget can't be redocked
+ }
+
bool wasFloating = q->isFloating();
bool hidden = q->isHidden();
diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp
index dc67f36..e62ba8c 100644
--- a/tests/auto/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp
@@ -86,6 +86,7 @@ private slots:
void visibilityChanged();
void dockLocationChanged();
void setTitleBarWidget();
+ void titleBarDoubleClick();
// task specific tests:
void task165177_deleteFocusWidget();
void task169808_setFloating();
@@ -694,6 +695,24 @@ void tst_QDockWidget::setTitleBarWidget()
QCOMPARE(w2.isVisible(), false);
}
+void tst_QDockWidget::titleBarDoubleClick()
+{
+ QMainWindow win;
+ QDockWidget dock(&win);
+ win.show();
+ dock.setFloating(true);
+
+ QEvent e(QEvent::NonClientAreaMouseButtonDblClick);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea);
+
+ win.addDockWidget(Qt::TopDockWidgetArea, &dock);
+ dock.setFloating(true);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(!dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea);
+}
void tst_QDockWidget::task165177_deleteFocusWidget()
{