Add flag to DockWidget to force dw to be closed with the area that contains it

This commit is contained in:
Nicolas ELIE 2020-08-04 11:41:20 +02:00
parent edc799bc54
commit 40636d1e05
3 changed files with 12 additions and 7 deletions

View File

@ -32,6 +32,7 @@ public:
DockWidgetDeleteOnClose,
CustomCloseHandling,
DockWidgetFocusable,
DockWidgetForceCloseWithArea,
DefaultDockWidgetFeatures,
AllDockWidgetFeatures,
NoDockWidgetFeatures

View File

@ -885,17 +885,20 @@ void CDockAreaWidget::closeArea()
// If there is only one single dock widget and this widget has the
// DeleteOnClose feature, then we delete the dock widget now
auto OpenDockWidgets = openedDockWidgets();
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{
OpenDockWidgets[0]->closeDockWidgetInternal();
}
else
else
{
for (auto DockWidget : openedDockWidgets())
{
DockWidget->toggleView(false);
}
}
for (auto DockWidget : openedDockWidgets())
{
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea))
DockWidget->closeDockWidgetInternal();
else
DockWidget->toggleView(false);
}
}
}

View File

@ -153,6 +153,7 @@ public:
DockWidgetDeleteOnClose = 0x08, ///< deletes the dock widget when it is closed
CustomCloseHandling = 0x10,
DockWidgetFocusable = 0x20,
DockWidgetForceCloseWithArea = 0x40,
DefaultDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetFocusable,
AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
NoDockWidgetFeatures = 0x00