From 5e230d88744503b62a0cba4748abd734e72af470 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 11 Dec 2019 16:06:07 +0100 Subject: [PATCH] Closing a dock area with only one single dock widget that has the DockWidgetDeleteOnCloseFeature will delete the dock widget and the area now --- src/DockAreaWidget.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index fbc8bbb..b16ca81 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -799,9 +799,19 @@ QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const //============================================================================ void CDockAreaWidget::closeArea() { - for (auto DockWidget : openedDockWidgets()) + // 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)) { - DockWidget->toggleView(false); + OpenDockWidgets[0]->deleteDockWidget(); + } + else + { + for (auto DockWidget : openedDockWidgets()) + { + DockWidget->toggleView(false); + } } }