diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp index d926902..0acb737 100644 --- a/src/AutoHideTab.cpp +++ b/src/AutoHideTab.cpp @@ -394,6 +394,9 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev) d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu); Action = Menu.addAction(tr("Unpin (Dock)"), this, SLOT(unpinDockWidget())); + Menu.addSeparator(); + Action = Menu.addAction(tr("Close"), this, SLOT(requestCloseDockWidget())); + Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable)); Menu.exec(ev->globalPos()); } @@ -537,4 +540,11 @@ void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev) } +//============================================================================ +void CAutoHideTab::requestCloseDockWidget() +{ + d->DockWidget->requestCloseDockWidget(); +} + + } diff --git a/src/AutoHideTab.h b/src/AutoHideTab.h index 8e94c45..cf0d143 100644 --- a/src/AutoHideTab.h +++ b/src/AutoHideTab.h @@ -150,6 +150,11 @@ public Q_SLOTS: * Unpin and dock the auto hide widget */ void unpinDockWidget(); + + /** + * Calls the requestCloseDockWidget() function for the assigned dock widget + */ + void requestCloseDockWidget(); }; // class AutoHideTab } // namespace ads diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 8b1bdc8..95309c6 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -626,15 +626,7 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent() void CDockAreaWidget::onTabCloseRequested(int Index) { ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index); - auto* DockWidget = dockWidget(Index); - if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling)) - { - DockWidget->closeDockWidgetInternal(); - } - else - { - DockWidget->toggleView(false); - } + dockWidget(Index)->requestCloseDockWidget(); } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index af00a50..a180cf6 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1059,6 +1059,22 @@ void CDockWidget::closeDockWidget() } + +//============================================================================ +void CDockWidget::requestCloseDockWidget() +{ + if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose) + || features().testFlag(CDockWidget::CustomCloseHandling)) + { + closeDockWidgetInternal(false); + } + else + { + toggleView(false); + } +} + + //============================================================================ bool CDockWidget::closeDockWidgetInternal(bool ForceClose) { diff --git a/src/DockWidget.h b/src/DockWidget.h index 4e6b0c7..188c14b 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -584,10 +584,19 @@ public Q_SLOTS: void deleteDockWidget(); /** - * Closes the dock widget + * Closes the dock widget. + * The function forces closing of the dock widget even for CustomCloseHandling. */ void closeDockWidget(); + /** + * Request closing of the dock widget. + * For DockWidget with default close handling, the function does the same + * like clodeDockWidget() but if the flas CustomCloseHandling is set, + * the function only emits the closeRequested() signal. + */ + void requestCloseDockWidget(); + /** * Shows the widget in full-screen mode. * Normally this function only affects windows. To make the interface