Skip to content

Commit

Permalink
Implemented issue #694 - added auto hide configuration flag AutoHideC…
Browse files Browse the repository at this point in the history
…loseOnOutsideMouseClick
  • Loading branch information
githubuser0xFFFF committed Jan 15, 2025
1 parent 979d76a commit faf24cd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions demo/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
- [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
- [`AutoHideCloseOnOutsideMouseClick`](#autohidecloseonoutsidemouseclick)
- [DockWidget Feature Flags](#dockwidget-feature-flags)
- [`DockWidgetClosable`](#dockwidgetclosable)
- [`DockWidgetMovable`](#dockwidgetmovable)
Expand Down Expand Up @@ -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:
Expand All @@ -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`
Expand Down
8 changes: 6 additions & 2 deletions src/AutoHideDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/DockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,12 @@ public Q_SLOTS:
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)
Expand Down

0 comments on commit faf24cd

Please sign in to comment.