From 7245dced8452ad8aa62297b9a00d47ffe43c4a5e Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 12 Dec 2024 15:38:29 +0100 Subject: [PATCH] Added new config flag DoubleClickUndocksWidget to configure if double clicking a DockWidget tab or titlebar undocks the widget --- examples/emptydockarea/mainwindow.cpp | 1 + src/DockAreaTitleBar.cpp | 5 +++++ src/DockManager.h | 5 ++++- src/DockWidgetTab.cpp | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/emptydockarea/mainwindow.cpp b/examples/emptydockarea/mainwindow.cpp index 37994e6..c8b4bf7 100644 --- a/examples/emptydockarea/mainwindow.cpp +++ b/examples/emptydockarea/mainwindow.cpp @@ -37,6 +37,7 @@ CMainWindow::CMainWindow(QWidget *parent) ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasUndockButton, false ); ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true ); ads::CDockManager::setConfigFlag( ads::CDockManager::DisableTabTextEliding, true ); + ads::CDockManager::setConfigFlag( ads::CDockManager::DoubleClickUndocksWidget, false ); DockManager = new CDockManager(this); // Set central widget diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 141c920..ebc0074 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -733,6 +733,11 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event) return; } + if (!CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget)) + { + return; + } + d->makeAreaFloating(event->pos(), DraggingInactive); } diff --git a/src/DockManager.h b/src/DockManager.h index 9edb8e8..291ab68 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -215,6 +215,8 @@ public: MiddleMouseButtonClosesTab = 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs + DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget + DefaultDockAreaButtons = DockAreaHasCloseButton | DockAreaHasUndockButton @@ -223,7 +225,8 @@ public: DefaultBaseConfig = DefaultDockAreaButtons | ActiveTabHasCloseButton | XmlCompressionEnabled - | FloatingContainerHasWidgetTitle, ///< default base configuration settings + | FloatingContainerHasWidgetTitle + | DoubleClickUndocksWidget, ///< default base configuration settings DefaultOpaqueConfig = DefaultBaseConfig | OpaqueSplitterResize diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 1380288..572b781 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -699,7 +699,7 @@ QString CDockWidgetTab::text() const //============================================================================ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton && CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget)) { // If this is the last dock area in a dock container it does not make // sense to move it to a new floating widget and leave this one