Implemented issue #694 - added auto hide configuration flag AutoHideCloseOnOutsideMouseClick

This commit is contained in:
Uwe Kindler 2025-01-15 08:37:43 +01:00
parent 979d76aa47
commit faf24cd531
4 changed files with 18 additions and 3 deletions

View File

@ -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);

View File

@ -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`

View File

@ -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)
{

View File

@ -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)