From 22402e79f5bea18b5098cd51b1bdfac30d3f4ab7 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 9 Sep 2022 13:57:43 +0800 Subject: [PATCH] Added support for delete on close to overlayed widgets --- examples/autohide/mainwindow.cpp | 1 + src/DockAreaWidget.cpp | 12 ++++++++++-- src/DockWidget.cpp | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/autohide/mainwindow.cpp b/examples/autohide/mainwindow.cpp index ff9259a..1e9a448 100644 --- a/examples/autohide/mainwindow.cpp +++ b/examples/autohide/mainwindow.cpp @@ -46,6 +46,7 @@ CMainWindow::CMainWindow(QWidget *parent) TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); TableDockWidget->resize(250, 150); TableDockWidget->setMinimumSize(200,150); + TableDockWidget->setFeature(CDockWidget::DockWidgetDeleteOnClose, true); DockManager->addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget); ui->menuView->addAction(TableDockWidget->toggleViewAction()); diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index fc47706..e471eb0 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -1049,11 +1049,19 @@ void CDockAreaWidget::closeArea() { for (auto DockWidget : openedDockWidgets()) { - if ((DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea)) || - DockWidget->features().testFlag(CDockWidget::CustomCloseHandling) && !isOverlayed()) + if ((DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea)) || + DockWidget->features().testFlag(CDockWidget::CustomCloseHandling)) + { + DockWidget->closeDockWidgetInternal(); + } + else if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && isOverlayed()) + { DockWidget->closeDockWidgetInternal(); + } else + { DockWidget->toggleView(false); + } } } } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index ecc2662..9f7f9bf 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1015,6 +1015,10 @@ bool CDockWidget::closeDockWidgetInternal(bool ForceClose) FloatingWidget->hide(); } } + if (d->DockArea && d->DockArea->isOverlayed()) + { + d->DockArea->overlayDockContainer()->cleanupAndDelete(); + } deleteDockWidget(); Q_EMIT closed(); }