Added support for delete on close to overlayed widgets

This commit is contained in:
Syarif Fakhri 2022-09-09 13:57:43 +08:00
parent 54b9a8dc50
commit 22402e79f5
3 changed files with 15 additions and 2 deletions

View File

@ -46,6 +46,7 @@ CMainWindow::CMainWindow(QWidget *parent)
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
TableDockWidget->resize(250, 150); TableDockWidget->resize(250, 150);
TableDockWidget->setMinimumSize(200,150); TableDockWidget->setMinimumSize(200,150);
TableDockWidget->setFeature(CDockWidget::DockWidgetDeleteOnClose, true);
DockManager->addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget); DockManager->addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget);
ui->menuView->addAction(TableDockWidget->toggleViewAction()); ui->menuView->addAction(TableDockWidget->toggleViewAction());

View File

@ -1050,12 +1050,20 @@ void CDockAreaWidget::closeArea()
for (auto DockWidget : openedDockWidgets()) for (auto DockWidget : openedDockWidgets())
{ {
if ((DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea)) || if ((DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea)) ||
DockWidget->features().testFlag(CDockWidget::CustomCloseHandling) && !isOverlayed()) DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
{
DockWidget->closeDockWidgetInternal(); DockWidget->closeDockWidgetInternal();
}
else if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && isOverlayed())
{
DockWidget->closeDockWidgetInternal();
}
else else
{
DockWidget->toggleView(false); DockWidget->toggleView(false);
} }
} }
}
} }
//============================================================================ //============================================================================

View File

@ -1015,6 +1015,10 @@ bool CDockWidget::closeDockWidgetInternal(bool ForceClose)
FloatingWidget->hide(); FloatingWidget->hide();
} }
} }
if (d->DockArea && d->DockArea->isOverlayed())
{
d->DockArea->overlayDockContainer()->cleanupAndDelete();
}
deleteDockWidget(); deleteDockWidget();
Q_EMIT closed(); Q_EMIT closed();
} }