Skip to content

Commit 78a4166

Browse files
Updated CFloatingDockContainer::closeEvent() function to delete all dock widgets with DockWidgetDeleteOnClose flag set
1 parent 3d3b694 commit 78a4166

File tree

3 files changed

+43
-18
lines changed

3 files changed

+43
-18
lines changed

src/DockContainerWidget.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,22 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
16251625
}
16261626

16271627

1628+
//============================================================================
1629+
QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
1630+
{
1631+
QList<CDockWidget*> DockWidgetList;
1632+
for (auto DockArea : d->DockAreas)
1633+
{
1634+
if (!DockArea->isHidden())
1635+
{
1636+
DockWidgetList.append(DockArea->openedDockWidgets());
1637+
}
1638+
}
1639+
1640+
return DockWidgetList;
1641+
}
1642+
1643+
16281644
//============================================================================
16291645
bool CDockContainerWidget::hasOpenDockAreas() const
16301646
{

src/DockContainerWidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
216216
*/
217217
QList<CDockAreaWidget*> openedDockAreas() const;
218218

219+
/**
220+
* Returns a list for all open dock widgets in all open dock areas
221+
*/
222+
QList<CDockWidget*> openedDockWidgets() const;
223+
219224
/**
220225
* This function returns true, if the container has open dock areas.
221226
* This functions is a little bit faster than calling openedDockAreas().isEmpty()

src/FloatingDockContainer.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -802,29 +802,33 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
802802
ADS_PRINT("CFloatingDockContainer closeEvent");
803803
d->setState(DraggingInactive);
804804
event->ignore();
805+
if (!isClosable())
806+
{
807+
return;
808+
}
805809

806-
if (isClosable())
810+
for (auto DockWidget : d->DockContainer->openedDockWidgets())
807811
{
808-
auto TopLevelDockWidget = topLevelDockWidget();
809-
if (TopLevelDockWidget && TopLevelDockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
812+
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
810813
{
811-
if (!TopLevelDockWidget->closeDockWidgetInternal())
812-
{
813-
return;
814-
}
814+
DockWidget->closeDockWidgetInternal();
815+
}
816+
else
817+
{
818+
DockWidget->toggleView(false);
815819
}
816-
817-
// In Qt version after 5.9.2 there seems to be a bug that causes the
818-
// QWidget::event() function to not receive any NonClientArea mouse
819-
// events anymore after a close/show cycle. The bug is reported here:
820-
// https://bugreports.qt.io/browse/QTBUG-73295
821-
// The following code is a workaround for Qt versions > 5.9.2 that seems
822-
// to work
823-
// Starting from Qt version 5.12.2 this seems to work again. But
824-
// now the QEvent::NonClientAreaMouseButtonPress function returns always
825-
// Qt::RightButton even if the left button was pressed
826-
this->hide();
827820
}
821+
822+
// In Qt version after 5.9.2 there seems to be a bug that causes the
823+
// QWidget::event() function to not receive any NonClientArea mouse
824+
// events anymore after a close/show cycle. The bug is reported here:
825+
// https://bugreports.qt.io/browse/QTBUG-73295
826+
// The following code is a workaround for Qt versions > 5.9.2 that seems
827+
// to work
828+
// Starting from Qt version 5.12.2 this seems to work again. But
829+
// now the QEvent::NonClientAreaMouseButtonPress function returns always
830+
// Qt::RightButton even if the left button was pressed
831+
this->hide();
828832
}
829833

830834
//============================================================================

0 commit comments

Comments
 (0)