mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Fixed emission of top level event in DockContainerWidget
This commit is contained in:
parent
0073870480
commit
5a9f23a9ad
@ -717,7 +717,6 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
|
||||
// uncomment if you would like to enable dock widget auto hiding
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideShowOnMouseOver, true);
|
||||
|
||||
// uncomment if you would like to enable an equal distribution of the
|
||||
// available size of a splitter to all contained dock widgets
|
||||
|
@ -29,6 +29,10 @@
|
||||
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
|
||||
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
|
||||
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
|
||||
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
|
||||
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
|
||||
- [Setting Auto-Hide Flags](#setting-auto-hide-flags)
|
||||
- [`AutoHideFeatureEnabled`](#autohidefeatureenabled)
|
||||
- [`DockAreaHasAutoHideButton`](#dockareahasautohidebutton)
|
||||
@ -49,10 +53,6 @@
|
||||
- [Central Widget](#central-widget)
|
||||
- [Empty Dock Area](#empty-dock-area)
|
||||
- [Custom Close Handling](#custom-close-handling)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
|
||||
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
|
||||
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
|
||||
- [Styling](#styling)
|
||||
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
|
||||
|
||||
@ -500,16 +500,60 @@ possible in various web browsers.
|
||||
|
||||
## Auto-Hide Configuration Flags
|
||||
|
||||
The Advanced Docking System has a number of global configuration options to
|
||||
configure the Auto-Hide functionality. The "Auto Hide" feature allows to display
|
||||
more information using less screen space by hiding or showing windows pinned to
|
||||
one of the four dock container borders.
|
||||
### Auto Hide Dock Widgets
|
||||
|
||||
The Advanced Docking System supports "Auto-Hide" functionality for **all**
|
||||
dock containers. The "Auto Hide" feature allows to display more information
|
||||
using less screen space by hiding or showing windows pinned to one of the
|
||||
four dock container borders.
|
||||
|
||||
Enabling this feature adds a button with a pin icon to each dock area.
|
||||
|
||||
![DockAreaHasAutoHideButton true](cfg_flag_DockAreaHasAutoHideButton.png)
|
||||
|
||||
By clicking this button, the current dock widget (or the complete area - depending on the
|
||||
configuration flags) will be pinned to a certain border. The border is choosen
|
||||
depending on the location of the dock area. If you click the pin button while
|
||||
holding down the **Ctrl** key, the whole dock area will be pinned to a certain
|
||||
border.
|
||||
|
||||
### Pinning Auto-Hide Widgets to a certain border
|
||||
|
||||
If you would like to pin a dock widget or a dock area to a certain border,
|
||||
then you can right-click into the dock widget tab or into the dock area title bar
|
||||
to show the context menu. Then you can select the location via the **Pin to** menu:
|
||||
|
||||
![Pin to](AutoHide_PinTo.png)
|
||||
|
||||
### Show / Hide Auto-Hide Widgets via Mouse Over
|
||||
|
||||
Normally Auto-Hide widgets are shown by clicking the Auto-Hide tab and hidden by
|
||||
clicking the Auto-Hide tab again or by clicking into any other dock widget in
|
||||
the same container. If the Auto-Hide config flag `AutoHideShowOnMouseOver` is set,
|
||||
the Auto-Hide widget is shown, if the user hovers over the Auto-Hide tab and is
|
||||
collapsed if the mouse cursor leaves the Auto-Hide widget. Showing and hiding
|
||||
by mouse click still works if this feature is enabled.
|
||||
|
||||
### Adding Auto Hide Widgets
|
||||
|
||||
Adding an auto hide widget is similar to adding a dock widget, simply call
|
||||
`dockManager->addAutoHideDockWidget()`.
|
||||
|
||||
```c++
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
d->DockManager = new CDockManager(this);
|
||||
CDockWidget* TableDockWidget = new CDockWidget("Table 1");
|
||||
DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
|
||||
```
|
||||
|
||||
See `autohide` example or the demo application to learn how it works.
|
||||
|
||||
### Setting Auto-Hide Flags
|
||||
|
||||
You should set the Auto-Hide flags before creating the dock manager
|
||||
instance. That means, you should set the Auto-Hide flags after setting the
|
||||
configuration flags.
|
||||
The Advanced Docking System has a number of global configuration flags to
|
||||
configure the Auto-Hide functionality. You should set the Auto-Hide flags before
|
||||
creating the dock manager instance. That means, you should set the Auto-Hide
|
||||
flags after setting the configuration flags.
|
||||
|
||||
```c++
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
@ -701,51 +745,6 @@ Normally clicking the close button of a dock widget will just hide the widget an
|
||||
|
||||
When an entire area is closed, the default behavior is to hide the dock widgets it contains regardless of the `DockWidgetDeleteOnClose` flag except if there is only one dock widget. In this special case, the `DockWidgetDeleteOnClose` flag is followed. This behavior can be changed by setting the `DockWidgetForceCloseWithArea` flag to all the dock widgets that needs to be closed with their area.
|
||||
|
||||
## Auto Hide Dock Widgets
|
||||
|
||||
The Advanced Docking System supports "Auto-Hide" functionality for **all** dock containers. The "Auto Hide" feature allows to display more information using less screen space by hiding or showing windows pinned to one of the four dock container borders.
|
||||
|
||||
Enabling this feature adds a button with a pin icon to each dock area.
|
||||
|
||||
![DockAreaHasAutoHideButton true](cfg_flag_DockAreaHasAutoHideButton.png)
|
||||
|
||||
By clicking this button, the current dock widget (or the complete area - depending on the
|
||||
configuration flags) will be pinned to a certain border. The border is choosen
|
||||
depending on the location of the dock area. If you click the pin button while
|
||||
holding down the **Ctrl** key, the whole dock area will be pinned to a certain
|
||||
border.
|
||||
|
||||
### Pinning Auto-Hide Widgets to a certain border
|
||||
|
||||
If you would like to pin a dock widget or a dock area to a certain border,
|
||||
then you can right-click into the dock widget tab or into the dock area title bar
|
||||
to show the context menu. Then you can select the location via the **Pin to** menu:
|
||||
|
||||
![Pin to](AutoHide_PinTo.png)
|
||||
|
||||
### Show / Hide Auto-Hide Widgets via Mouse Over
|
||||
|
||||
Normally Auto-Hide widgets are shown by clicking the Auto-Hide tab and hidden by
|
||||
clicking the Auto-Hide tab again or by clicking into any other dock widget in
|
||||
the same container. If the Auto-Hide config flag `AutoHideShowOnMouseOver` is set,
|
||||
the Auto-Hide widget is shown, if the user hovers over the Auto-Hide tab and is
|
||||
collapsed if the mouse cursor leaves the Auto-Hide widget. Showing and hiding
|
||||
my mouse click still works if this feature is enabled.
|
||||
|
||||
### Adding Auto Hide Widgets
|
||||
|
||||
Adding an auto hide widget is similar to adding a dock widget, simply call
|
||||
`dockManager->addAutoHideDockWidget()`.
|
||||
|
||||
```c++
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
d->DockManager = new CDockManager(this);
|
||||
CDockWidget* TableDockWidget = new CDockWidget("Table 1");
|
||||
DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
|
||||
```
|
||||
|
||||
See `autohide` example or the demo application to learn how it works.
|
||||
|
||||
## Styling
|
||||
|
||||
The Advanced Docking System supports styling via [Qt Style Sheets](https://doc.qt.io/qt-5/stylesheet.html). All components like splitters, tabs, buttons, titlebar and
|
||||
|
@ -380,16 +380,7 @@ void CAutoHideDockContainer::moveContentsToParent()
|
||||
// to the user and he does not have to search where the widget was inserted.
|
||||
d->DockWidget->setDockArea(nullptr);
|
||||
auto DockContainer = dockContainer();
|
||||
|
||||
// If the container contained only one visible dock widget, the we need
|
||||
// to emit a top level event for this widget because it is not the one and
|
||||
// only visible docked widget anymore
|
||||
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
||||
DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget);
|
||||
if (TopLevelDockWidget)
|
||||
{
|
||||
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1360,6 +1360,7 @@ CDockContainerWidget::~CDockContainerWidget()
|
||||
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget)
|
||||
{
|
||||
auto TopLevelDockWidget = topLevelDockWidget();
|
||||
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||
if (OldDockArea)
|
||||
{
|
||||
@ -1367,14 +1368,28 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
||||
}
|
||||
|
||||
Dockwidget->setDockManager(d->DockManager);
|
||||
CDockAreaWidget* DockArea;
|
||||
if (DockAreaWidget)
|
||||
{
|
||||
return d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
|
||||
DockArea = d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
return d->addDockWidgetToContainer(area, Dockwidget);
|
||||
DockArea = d->addDockWidgetToContainer(area, Dockwidget);
|
||||
}
|
||||
|
||||
if (TopLevelDockWidget)
|
||||
{
|
||||
auto NewTopLevelDockWidget = topLevelDockWidget();
|
||||
// If the container contained only one visible dock widget, the we need
|
||||
// to emit a top level event for this widget because it is not the one and
|
||||
// only visible docked widget anymore
|
||||
if (!NewTopLevelDockWidget)
|
||||
{
|
||||
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, false);
|
||||
}
|
||||
}
|
||||
return DockArea;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user