From 9c30169c42245a8fac15c5750c380f941e08e285 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 20 Jan 2023 11:50:34 +0100 Subject: [PATCH] Removed support for opaque undocking --- demo/MainWindow.cpp | 8 +------- src/DockAreaTitleBar.cpp | 17 +++-------------- src/DockManager.h | 3 +-- src/DockWidgetTab.cpp | 27 ++++++++------------------- 4 files changed, 13 insertions(+), 42 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 65e491a..a522515 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -544,13 +544,7 @@ void MainWindowPrivate::createContent() #ifdef Q_OS_WIN #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - // If opaque undocking is active, then undocking of widgets while - // active x widget is visible causes jerking while dragging a floating - // widget - if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking)) - { - DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(), RighDockArea); - } + DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(), RighDockArea); #endif #endif diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 68d0a7c..ef29a26 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -262,8 +262,7 @@ IFloatingWidget* DockAreaTitleBarPrivate::makeAreaFloating(const QPoint& Offset, { QSize Size = DockArea->size(); this->DragState = DragState; - bool CreateFloatingDockContainer = CDockManager::testConfigFlag( - CDockManager::OpaqueUndocking) || (DraggingFloatingWidget != DragState); + bool CreateFloatingDockContainer = (DraggingFloatingWidget != DragState); CFloatingDockContainer* FloatingDockContainer = nullptr; IFloatingWidget* FloatingWidget; if (CreateFloatingDockContainer) @@ -589,10 +588,6 @@ void CDockAreaTitleBar::mouseReleaseEvent(QMouseEvent* ev) if (ev->button() == Qt::LeftButton) { ADS_PRINT("CDockAreaTitleBar::mouseReleaseEvent"); - if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)) - { - releaseMouse(); - } ev->accept(); auto CurrentDragState = d->DragState; d->DragStartMousePos = QPoint(); @@ -637,11 +632,9 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev) // If one single dock widget in this area is not floatable then the whole // area is not floatable - // If we do non opaque undocking, then we can create the floating drag - // preview if the dock widget is movable + // 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))) + if (!Features.testFlag(CDockWidget::DockWidgetFloatable) && !(Features.testFlag(CDockWidget::DockWidgetMovable))) { return; } @@ -653,10 +646,6 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev) d->startFloating(d->DragStartMousePos); auto Overlay = d->DockArea->dockManager()->containerOverlay(); Overlay->setAllowedAreas(OuterDockAreas); - if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)) - { - grabMouse(); - } } return; diff --git a/src/DockManager.h b/src/DockManager.h index d4b27f8..db215e3 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -180,7 +180,6 @@ public: TabCloseButtonIsToolButton = 0x0040,//! If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default AllTabsHaveCloseButton = 0x0080, //!< if this flag is set, then all tabs that are closable show a close button RetainTabSizeWhenCloseButtonHidden = 0x0100, //!< if this flag is set, the space for the close button is reserved even if the close button is not visible - OpaqueUndocking = 0x0200,///< If enabled, the widgets are immediately undocked into floating widgets, if disabled, only a draw preview is undocked and the real undocking is deferred until the mouse is released DragPreviewIsDynamic = 0x0400,///< If opaque undocking is disabled, this flag defines the behavior of the drag preview window, if this flag is enabled, the preview will be adjusted dynamically to the drop area DragPreviewShowsContentPixmap = 0x0800,///< If opaque undocking is disabled, the created drag preview window shows a copy of the content of the dock widget / dock are that is dragged DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window @@ -216,7 +215,7 @@ public: DefaultOpaqueConfig = DefaultBaseConfig | OpaqueSplitterResize - | OpaqueUndocking, ///< the default configuration with opaque operations - this may cause issues if ActiveX or Qt 3D windows are involved + | DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations DefaultNonOpaqueConfig = DefaultBaseConfig | DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index dfdf908..5829a26 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -162,9 +162,9 @@ struct DockWidgetTabPrivate } template - IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking) + IFloatingWidget* createFloatingWidget(T* Widget, bool CreateContainer) { - if (OpaqueUndocking) + if (CreateContainer) { return new CFloatingDockContainer(Widget); } @@ -312,8 +312,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState) ADS_PRINT("startFloating"); DragState = DraggingState; IFloatingWidget* FloatingWidget = nullptr; - bool OpaqueUndocking = CDockManager::testConfigFlag(CDockManager::OpaqueUndocking) || - (DraggingFloatingWidget != DraggingState); + bool CreateContainer = (DraggingFloatingWidget != DraggingState); // If section widget has multiple tabs, we take only one tab // If it has only one single tab, we can move the complete @@ -321,12 +320,12 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState) QSize Size; if (DockArea->dockWidgetsCount() > 1) { - FloatingWidget = createFloatingWidget(DockWidget, OpaqueUndocking); + FloatingWidget = createFloatingWidget(DockWidget, CreateContainer); Size = DockWidget->size(); } else { - FloatingWidget = createFloatingWidget(DockArea, OpaqueUndocking); + FloatingWidget = createFloatingWidget(DockArea, CreateContainer); Size = DockArea->size(); } @@ -392,10 +391,6 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev) { if (ev->button() == Qt::LeftButton) { - if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)) - { - releaseMouse(); - } auto CurrentDragState = d->DragState; d->GlobalDragStartMousePosition = QPoint(); d->DragStartMousePosition = QPoint(); @@ -481,23 +476,17 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev) // 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. + // We 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 (Features.testFlag(CDockWidget::DockWidgetFloatable) || (Features.testFlag(CDockWidget::DockWidgetMovable))) { // If we undock, we need to restore the initial position of this // tab because it looks strange if it remains on its dragged position - if (d->isDraggingState(DraggingTab) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)) + if (d->isDraggingState(DraggingTab)) { parentWidget()->layout()->update(); } d->startFloating(); - if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)) - { - grabMouse(); - } } return; }