From 407af06a4a89bc9622e3012a0e029705283eb20c Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 14 Jan 2020 12:43:42 +0100 Subject: [PATCH] Fixed some issues with custom close handling --- src/DockContainerWidget.cpp | 1 - src/DockWidget.cpp | 15 +++++++++++++++ src/FloatingDockContainer.cpp | 7 +------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index b809948..a3bc785 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1726,7 +1726,6 @@ void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea) // We do not close areas with widgets with custom close handling if (DockArea->features(BitwiseOr).testFlag(CDockWidget::CustomCloseHandling)) { - std::cout << "CDockWidget::CustomCloseHandling" << std::endl; continue; } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 28713b8..398f727 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -770,6 +770,21 @@ bool CDockWidget::closeDockWidgetInternal(bool ForceClose) if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose)) { + // If the dock widget is floating, then we check if we also need to + // delete the floating widget + if (isFloating()) + { + CFloatingDockContainer* FloatingWidget = internal::findParent< + CFloatingDockContainer*>(this); + if (FloatingWidget->dockWidgets().count() == 1) + { + FloatingWidget->deleteLater(); + } + else + { + FloatingWidget->hide(); + } + } deleteDockWidget(); } else diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 400f12d..2e1bcbb 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -361,13 +361,8 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event) auto TopLevelDockWidget = topLevelDockWidget(); if (TopLevelDockWidget && TopLevelDockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose)) { - if (TopLevelDockWidget->closeDockWidgetInternal()) + if (!TopLevelDockWidget->closeDockWidgetInternal()) { - this->deleteLater(); - } - else - { - event->ignore(); return; } }