diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index bc40a6a..300fd1c 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -331,6 +331,8 @@ void MainWindowPrivate::createContent() auto ToolBar = FileSystemWidget->createDefaultToolBar(); ToolBar->addAction(ui.actionSaveState); ToolBar->addAction(ui.actionRestoreState); + FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false); + appendFeaturStringToWindowTitle(FileSystemWidget); DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget); FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); @@ -484,9 +486,9 @@ CMainWindow::CMainWindow(QWidget *parent) : // a QToolButton instead of a QPushButton // CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton); - // comment the following line if you want to use opaque undocking and + // uncomment the following line if you want to use opaque undocking and // opaque splitter resizing - CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); + // CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig); // uncomment the following line if you want a fixed tab width that does // not change if the visibility of the close button changes diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 3beae3e..53d5396 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -600,7 +600,11 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev) // If one single dock widget in this area is not floatable then the whole // area is not floatable - if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)) + // If we do non opaque undocking, then we can create the floating drag + // preview if the dock widget is movable + auto Features = d->DockArea->features(); + if (!Features.testFlag(CDockWidget::DockWidgetFloatable) + && !(Features.testFlag(CDockWidget::DockWidgetMovable) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))) { return; } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index b5a7d11..1ac5a91 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -58,7 +58,7 @@ namespace ads { -static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultOpaqueConfig; +static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig; /** * Private data class of CDockManager class (pimpl) diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 4e8323f..c721cbd 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -368,8 +368,13 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev) return; } - // Floating is only allowed for widgets that are movable - if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) + + // Floating is only allowed for widgets that are floatable + // If we do non opaque undocking, then can create the drag preview + // if the widget is movable. + auto Features = d->DockWidget->features(); + if (Features.testFlag(CDockWidget::DockWidgetFloatable) + || (Features.testFlag(CDockWidget::DockWidgetMovable) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))) { // If we undock, we need to restore the initial position of this // tab because it looks strange if it remains on its dragged position diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index 14346df..47904a8 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -291,25 +291,33 @@ void CFloatingDragPreview::finishDragging() else { CDockWidget* DockWidget = qobject_cast(d->Content); - CFloatingDockContainer* FloatingWidget; - if (DockWidget) + CFloatingDockContainer* FloatingWidget = nullptr; + + if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) { FloatingWidget = new CFloatingDockContainer(DockWidget); } else { CDockAreaWidget* DockArea = qobject_cast(d->Content); - FloatingWidget = new CFloatingDockContainer(DockArea); + if (DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)) + { + FloatingWidget = new CFloatingDockContainer(DockArea); + } } - FloatingWidget->setGeometry(this->geometry()); - FloatingWidget->show(); - if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame)) + + if (FloatingWidget) { - QApplication::processEvents(); - int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height(); - QRect FixedGeometry = this->geometry(); - FixedGeometry.adjust(0, FrameHeight, 0, 0); - FloatingWidget->setGeometry(FixedGeometry); + FloatingWidget->setGeometry(this->geometry()); + FloatingWidget->show(); + if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame)) + { + QApplication::processEvents(); + int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height(); + QRect FixedGeometry = this->geometry(); + FixedGeometry.adjust(0, FrameHeight, 0, 0); + FloatingWidget->setGeometry(FixedGeometry); + } } }