Skip to content

Commit 40636d1

Browse files
committed
Add flag to DockWidget to force dw to be closed with the area that contains it
1 parent edc799b commit 40636d1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

sip/DockWidget.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public:
3232
DockWidgetDeleteOnClose,
3333
CustomCloseHandling,
3434
DockWidgetFocusable,
35+
DockWidgetForceCloseWithArea,
3536
DefaultDockWidgetFeatures,
3637
AllDockWidgetFeatures,
3738
NoDockWidgetFeatures

src/DockAreaWidget.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -885,17 +885,20 @@ void CDockAreaWidget::closeArea()
885885
// If there is only one single dock widget and this widget has the
886886
// DeleteOnClose feature, then we delete the dock widget now
887887
auto OpenDockWidgets = openedDockWidgets();
888-
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
888+
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
889889
{
890890
OpenDockWidgets[0]->closeDockWidgetInternal();
891891
}
892-
else
892+
else
893893
{
894-
for (auto DockWidget : openedDockWidgets())
895-
{
896-
DockWidget->toggleView(false);
897-
}
898-
}
894+
for (auto DockWidget : openedDockWidgets())
895+
{
896+
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) && DockWidget->features().testFlag(CDockWidget::DockWidgetForceCloseWithArea))
897+
DockWidget->closeDockWidgetInternal();
898+
else
899+
DockWidget->toggleView(false);
900+
}
901+
}
899902
}
900903

901904

src/DockWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ private slots:
153153
DockWidgetDeleteOnClose = 0x08, ///< deletes the dock widget when it is closed
154154
CustomCloseHandling = 0x10,
155155
DockWidgetFocusable = 0x20,
156+
DockWidgetForceCloseWithArea = 0x40,
156157
DefaultDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetFocusable,
157158
AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
158159
NoDockWidgetFeatures = 0x00

0 commit comments

Comments
 (0)