diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index b75276a..77c3af2 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -769,6 +769,9 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment if you would like to enable dock widget auto hiding CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig}); + // uncomment if you would like to disable closing auto hide widget with mouse click outside of auto hide container + //CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideCloseOnOutsideMouseClick, false); + // uncomment if you would like to enable an equal distribution of the // available size of a splitter to all contained dock widgets // CDockManager::setConfigFlag(CDockManager::EqualSplitOnInsertion, true); diff --git a/doc/user-guide.md b/doc/user-guide.md index 482bbf3..66bada3 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -51,6 +51,7 @@ - [`AutoHideHasCloseButton`](#autohidehasclosebutton) - [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton) - [`AutoHideOpenOnDragHover`](#autohideopenondraghover) + - [`AutoHideCloseOnOutsideMouseClick`](#autohidecloseonoutsidemouseclick) - [DockWidget Feature Flags](#dockwidget-feature-flags) - [`DockWidgetClosable`](#dockwidgetclosable) - [`DockWidgetMovable`](#dockwidgetmovable) @@ -713,7 +714,6 @@ If this flag is set (disabled by default), then each auto hide widget has a mini ![AutoHideHasMinimizeButton](cfg_flag_AutoHideHasMinimizeButton.png) - ### `AutoHideOpenOnDragHover` If this flag is set (disabled by default), then holding a dragging cursor hover an auto-hide collapsed dock's tab will open said dock: @@ -722,6 +722,12 @@ If this flag is set (disabled by default), then holding a dragging cursor hover Said dock must be set to accept drops to hide when cursor leaves its scope. See `AutoHideDragNDropExample` for more details. +### `AutoHideCloseOnOutsideMouseClick` + +If this flag is set (default), the auto hide dock container will collapse if the +user clicks outside of the container. If not set, the auto hide container can be +closed only via click on auto hide sidebar tab. + ## DockWidget Feature Flags ### `DockWidgetClosable` diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 7cb20b2..75c1409 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -602,8 +602,12 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) return Super::eventFilter(watched, event); } - // user clicked into container - collapse the auto hide widget - collapseView(true); + // user clicked outside of autohide container - collapse the auto hide widget + if (CDockManager::testAutoHideConfigFlag( + CDockManager::AutoHideCloseOnOutsideMouseClick)) + { + collapseView(true); + } } else if (event->type() == internal::FloatingWidgetDragStartEvent) { diff --git a/src/DockManager.h b/src/DockManager.h index 3eab946..08897bd 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -258,10 +258,12 @@ public: AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock + AutoHideCloseOnOutsideMouseClick = 0x400, ///< if this flag is set, the auto hide dock container will collapse if the user clicks outside of the container, if not set, the auto hide container can be closed only via click on sidebar tab DefaultAutoHideConfig = AutoHideFeatureEnabled | DockAreaHasAutoHideButton | AutoHideHasMinimizeButton + | AutoHideCloseOnOutsideMouseClick }; Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)