From 40636d1e05cc36f2afd420b2a35b4a7534b7b238 Mon Sep 17 00:00:00 2001 From: Nicolas ELIE Date: Tue, 4 Aug 2020 11:41:20 +0200 Subject: [PATCH] Add flag to DockWidget to force dw to be closed with the area that contains it --- sip/DockWidget.sip | 1 + src/DockAreaWidget.cpp | 17 ++++++++++------- src/DockWidget.h | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/sip/DockWidget.sip b/sip/DockWidget.sip index c61853b..471f687 100644 --- a/sip/DockWidget.sip +++ b/sip/DockWidget.sip @@ -32,6 +32,7 @@ public: DockWidgetDeleteOnClose, CustomCloseHandling, DockWidgetFocusable, + DockWidgetForceCloseWithArea, DefaultDockWidgetFeatures, AllDockWidgetFeatures, NoDockWidgetFeatures diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 01acfa6..e45921e 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -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); + } + } } diff --git a/src/DockWidget.h b/src/DockWidget.h index d55a803..ca4360e 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -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