diff options
-rw-r--r-- | src/gui/widgets/qdockwidget.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qdockwidget/tst_qdockwidget.cpp | 19 |
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() { |