Skip to content

Commit 5a9f23a

Browse files
Fixed emission of top level event in DockContainerWidget
1 parent 0073870 commit 5a9f23a

File tree

4 files changed

+72
-68
lines changed

4 files changed

+72
-68
lines changed

demo/MainWindow.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ CMainWindow::CMainWindow(QWidget *parent) :
717717

718718
// uncomment if you would like to enable dock widget auto hiding
719719
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
720-
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideShowOnMouseOver, true);
721720

722721
// uncomment if you would like to enable an equal distribution of the
723722
// available size of a splitter to all contained dock widgets

doc/user-guide.md

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
3030
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
3131
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
32+
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
33+
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
34+
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
35+
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
3236
- [Setting Auto-Hide Flags](#setting-auto-hide-flags)
3337
- [`AutoHideFeatureEnabled`](#autohidefeatureenabled)
3438
- [`DockAreaHasAutoHideButton`](#dockareahasautohidebutton)
@@ -49,10 +53,6 @@
4953
- [Central Widget](#central-widget)
5054
- [Empty Dock Area](#empty-dock-area)
5155
- [Custom Close Handling](#custom-close-handling)
52-
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
53-
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
54-
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
55-
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
5656
- [Styling](#styling)
5757
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
5858

@@ -500,16 +500,60 @@ possible in various web browsers.
500500
501501
## Auto-Hide Configuration Flags
502502
503-
The Advanced Docking System has a number of global configuration options to
504-
configure the Auto-Hide functionality. The "Auto Hide" feature allows to display
505-
more information using less screen space by hiding or showing windows pinned to
506-
one of the four dock container borders.
503+
### Auto Hide Dock Widgets
504+
505+
The Advanced Docking System supports "Auto-Hide" functionality for **all**
506+
dock containers. The "Auto Hide" feature allows to display more information
507+
using less screen space by hiding or showing windows pinned to one of the
508+
four dock container borders.
509+
510+
Enabling this feature adds a button with a pin icon to each dock area.
511+
512+
![DockAreaHasAutoHideButton true](cfg_flag_DockAreaHasAutoHideButton.png)
513+
514+
By clicking this button, the current dock widget (or the complete area - depending on the
515+
configuration flags) will be pinned to a certain border. The border is choosen
516+
depending on the location of the dock area. If you click the pin button while
517+
holding down the **Ctrl** key, the whole dock area will be pinned to a certain
518+
border.
519+
520+
### Pinning Auto-Hide Widgets to a certain border
521+
522+
If you would like to pin a dock widget or a dock area to a certain border,
523+
then you can right-click into the dock widget tab or into the dock area title bar
524+
to show the context menu. Then you can select the location via the **Pin to** menu:
525+
526+
![Pin to](AutoHide_PinTo.png)
527+
528+
### Show / Hide Auto-Hide Widgets via Mouse Over
529+
530+
Normally Auto-Hide widgets are shown by clicking the Auto-Hide tab and hidden by
531+
clicking the Auto-Hide tab again or by clicking into any other dock widget in
532+
the same container. If the Auto-Hide config flag `AutoHideShowOnMouseOver` is set,
533+
the Auto-Hide widget is shown, if the user hovers over the Auto-Hide tab and is
534+
collapsed if the mouse cursor leaves the Auto-Hide widget. Showing and hiding
535+
by mouse click still works if this feature is enabled.
536+
537+
### Adding Auto Hide Widgets
538+
539+
Adding an auto hide widget is similar to adding a dock widget, simply call
540+
`dockManager->addAutoHideDockWidget()`.
541+
542+
```c++
543+
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
544+
d->DockManager = new CDockManager(this);
545+
CDockWidget* TableDockWidget = new CDockWidget("Table 1");
546+
DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
547+
```
548+
549+
See `autohide` example or the demo application to learn how it works.
507550

508551
### Setting Auto-Hide Flags
509552

510-
You should set the Auto-Hide flags before creating the dock manager
511-
instance. That means, you should set the Auto-Hide flags after setting the
512-
configuration flags.
553+
The Advanced Docking System has a number of global configuration flags to
554+
configure the Auto-Hide functionality. You should set the Auto-Hide flags before
555+
creating the dock manager instance. That means, you should set the Auto-Hide
556+
flags after setting the configuration flags.
513557

514558
```c++
515559
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
@@ -701,51 +745,6 @@ Normally clicking the close button of a dock widget will just hide the widget an
701745
702746
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.
703747
704-
## Auto Hide Dock Widgets
705-
706-
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.
707-
708-
Enabling this feature adds a button with a pin icon to each dock area.
709-
710-
![DockAreaHasAutoHideButton true](cfg_flag_DockAreaHasAutoHideButton.png)
711-
712-
By clicking this button, the current dock widget (or the complete area - depending on the
713-
configuration flags) will be pinned to a certain border. The border is choosen
714-
depending on the location of the dock area. If you click the pin button while
715-
holding down the **Ctrl** key, the whole dock area will be pinned to a certain
716-
border.
717-
718-
### Pinning Auto-Hide Widgets to a certain border
719-
720-
If you would like to pin a dock widget or a dock area to a certain border,
721-
then you can right-click into the dock widget tab or into the dock area title bar
722-
to show the context menu. Then you can select the location via the **Pin to** menu:
723-
724-
![Pin to](AutoHide_PinTo.png)
725-
726-
### Show / Hide Auto-Hide Widgets via Mouse Over
727-
728-
Normally Auto-Hide widgets are shown by clicking the Auto-Hide tab and hidden by
729-
clicking the Auto-Hide tab again or by clicking into any other dock widget in
730-
the same container. If the Auto-Hide config flag `AutoHideShowOnMouseOver` is set,
731-
the Auto-Hide widget is shown, if the user hovers over the Auto-Hide tab and is
732-
collapsed if the mouse cursor leaves the Auto-Hide widget. Showing and hiding
733-
my mouse click still works if this feature is enabled.
734-
735-
### Adding Auto Hide Widgets
736-
737-
Adding an auto hide widget is similar to adding a dock widget, simply call
738-
`dockManager->addAutoHideDockWidget()`.
739-
740-
```c++
741-
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
742-
d->DockManager = new CDockManager(this);
743-
CDockWidget* TableDockWidget = new CDockWidget("Table 1");
744-
DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
745-
```
746-
747-
See `autohide` example or the demo application to learn how it works.
748-
749748
## Styling
750749
751750
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

src/AutoHideDockContainer.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,7 @@ void CAutoHideDockContainer::moveContentsToParent()
380380
// to the user and he does not have to search where the widget was inserted.
381381
d->DockWidget->setDockArea(nullptr);
382382
auto DockContainer = dockContainer();
383-
384-
// If the container contained only one visible dock widget, the we need
385-
// to emit a top level event for this widget because it is not the one and
386-
// only visible docked widget anymore
387-
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
388383
DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget);
389-
if (TopLevelDockWidget)
390-
{
391-
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, false);
392-
}
393384
}
394385

395386

src/DockContainerWidget.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,21 +1360,36 @@ CDockContainerWidget::~CDockContainerWidget()
13601360
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
13611361
CDockAreaWidget* DockAreaWidget)
13621362
{
1363+
auto TopLevelDockWidget = topLevelDockWidget();
13631364
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
13641365
if (OldDockArea)
13651366
{
13661367
OldDockArea->removeDockWidget(Dockwidget);
13671368
}
13681369

13691370
Dockwidget->setDockManager(d->DockManager);
1371+
CDockAreaWidget* DockArea;
13701372
if (DockAreaWidget)
13711373
{
1372-
return d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
1374+
DockArea = d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
13731375
}
13741376
else
13751377
{
1376-
return d->addDockWidgetToContainer(area, Dockwidget);
1378+
DockArea = d->addDockWidgetToContainer(area, Dockwidget);
13771379
}
1380+
1381+
if (TopLevelDockWidget)
1382+
{
1383+
auto NewTopLevelDockWidget = topLevelDockWidget();
1384+
// If the container contained only one visible dock widget, the we need
1385+
// to emit a top level event for this widget because it is not the one and
1386+
// only visible docked widget anymore
1387+
if (!NewTopLevelDockWidget)
1388+
{
1389+
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, false);
1390+
}
1391+
}
1392+
return DockArea;
13781393
}
13791394

13801395

0 commit comments

Comments
 (0)