Skip to content

Commit faf24cd

Browse files
Implemented issue #694 - added auto hide configuration flag AutoHideCloseOnOutsideMouseClick
1 parent 979d76a commit faf24cd

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

demo/MainWindow.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
769769
// uncomment if you would like to enable dock widget auto hiding
770770
CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig});
771771

772+
// uncomment if you would like to disable closing auto hide widget with mouse click outside of auto hide container
773+
//CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideCloseOnOutsideMouseClick, false);
774+
772775
// uncomment if you would like to enable an equal distribution of the
773776
// available size of a splitter to all contained dock widgets
774777
// CDockManager::setConfigFlag(CDockManager::EqualSplitOnInsertion, true);

doc/user-guide.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
5252
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
5353
- [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
54+
- [`AutoHideCloseOnOutsideMouseClick`](#autohidecloseonoutsidemouseclick)
5455
- [DockWidget Feature Flags](#dockwidget-feature-flags)
5556
- [`DockWidgetClosable`](#dockwidgetclosable)
5657
- [`DockWidgetMovable`](#dockwidgetmovable)
@@ -713,7 +714,6 @@ If this flag is set (disabled by default), then each auto hide widget has a mini
713714
714715
![AutoHideHasMinimizeButton](cfg_flag_AutoHideHasMinimizeButton.png)
715716
716-
717717
### `AutoHideOpenOnDragHover`
718718
719719
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
722722
723723
Said dock must be set to accept drops to hide when cursor leaves its scope. See `AutoHideDragNDropExample` for more details.
724724
725+
### `AutoHideCloseOnOutsideMouseClick`
726+
727+
If this flag is set (default), the auto hide dock container will collapse if the
728+
user clicks outside of the container. If not set, the auto hide container can be
729+
closed only via click on auto hide sidebar tab.
730+
725731
## DockWidget Feature Flags
726732
727733
### `DockWidgetClosable`

src/AutoHideDockContainer.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,12 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
602602
return Super::eventFilter(watched, event);
603603
}
604604

605-
// user clicked into container - collapse the auto hide widget
606-
collapseView(true);
605+
// user clicked outside of autohide container - collapse the auto hide widget
606+
if (CDockManager::testAutoHideConfigFlag(
607+
CDockManager::AutoHideCloseOnOutsideMouseClick))
608+
{
609+
collapseView(true);
610+
}
607611
}
608612
else if (event->type() == internal::FloatingWidgetDragStartEvent)
609613
{

src/DockManager.h

+2
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,12 @@ public Q_SLOTS:
258258
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
259259
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
260260
AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock
261+
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
261262

262263
DefaultAutoHideConfig = AutoHideFeatureEnabled
263264
| DockAreaHasAutoHideButton
264265
| AutoHideHasMinimizeButton
266+
| AutoHideCloseOnOutsideMouseClick
265267

266268
};
267269
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)

0 commit comments

Comments
 (0)