mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Updated CFloatingDockContainer::closeEvent() function to delete all dock widgets with DockWidgetDeleteOnClose flag set
This commit is contained in:
parent
3d3b694040
commit
78a4166e42
@ -1625,6 +1625,22 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
|
||||
{
|
||||
QList<CDockWidget*> DockWidgetList;
|
||||
for (auto DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea->isHidden())
|
||||
{
|
||||
DockWidgetList.append(DockArea->openedDockWidgets());
|
||||
}
|
||||
}
|
||||
|
||||
return DockWidgetList;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CDockContainerWidget::hasOpenDockAreas() const
|
||||
{
|
||||
|
@ -216,6 +216,11 @@ public:
|
||||
*/
|
||||
QList<CDockAreaWidget*> openedDockAreas() const;
|
||||
|
||||
/**
|
||||
* Returns a list for all open dock widgets in all open dock areas
|
||||
*/
|
||||
QList<CDockWidget*> openedDockWidgets() const;
|
||||
|
||||
/**
|
||||
* This function returns true, if the container has open dock areas.
|
||||
* This functions is a little bit faster than calling openedDockAreas().isEmpty()
|
||||
|
@ -802,16 +802,21 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
ADS_PRINT("CFloatingDockContainer closeEvent");
|
||||
d->setState(DraggingInactive);
|
||||
event->ignore();
|
||||
|
||||
if (isClosable())
|
||||
{
|
||||
auto TopLevelDockWidget = topLevelDockWidget();
|
||||
if (TopLevelDockWidget && TopLevelDockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
|
||||
{
|
||||
if (!TopLevelDockWidget->closeDockWidgetInternal())
|
||||
if (!isClosable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto DockWidget : d->DockContainer->openedDockWidgets())
|
||||
{
|
||||
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
|
||||
{
|
||||
DockWidget->closeDockWidgetInternal();
|
||||
}
|
||||
else
|
||||
{
|
||||
DockWidget->toggleView(false);
|
||||
}
|
||||
}
|
||||
|
||||
// In Qt version after 5.9.2 there seems to be a bug that causes the
|
||||
@ -824,7 +829,6 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
// now the QEvent::NonClientAreaMouseButtonPress function returns always
|
||||
// Qt::RightButton even if the left button was pressed
|
||||
this->hide();
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user