diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index b16ca81..2ec5ff3 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -494,7 +494,8 @@ void CDockAreaWidget::onTabCloseRequested(int Index) auto* DockWidget = dockWidget(Index); if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose)) { - DockWidget->deleteDockWidget(); + //DockWidget->deleteDockWidget(); + DockWidget->closeDockWidget(); } else { diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index ff2cc58..8f0cfd9 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -31,6 +31,8 @@ #include "DockWidgetTab.h" #include "DockWidget.h" +#include + #include #include #include @@ -745,6 +747,42 @@ void CDockWidget::deleteDockWidget() } +//============================================================================ +bool CDockWidget::handleCloseRequest() +{ + std::cout << "CDockWidget::handleCloseRequest()" << std::endl; + return true; +} + + +//============================================================================ +void CDockWidget::closeDockWidget() +{ + closeDockWidgetInternal(); +} + + +//============================================================================ +bool CDockWidget::closeDockWidgetInternal() +{ + if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose)) + { + if (handleCloseRequest()) + { + deleteDockWidget(); + return true; + } + } + else + { + toggleView(false); + return true; + } + + return false; +} + + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockWidget.h b/src/DockWidget.h index cb1ce55..b70c733 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -135,6 +135,12 @@ protected: */ void toggleViewInternal(bool Open); + /** + * Internal close dock widget implementation. + * The function returns true if the dock widget has been closed or hidden + */ + bool closeDockWidgetInternal(); + public: using Super = QFrame; @@ -426,6 +432,12 @@ public slots: */ void deleteDockWidget(); + /** + * Closes the dock widget + */ + void closeDockWidget(); + + signals: /** * This signal is emitted if the dock widget is opened or closed diff --git a/src/DockWidgetTab.h b/src/DockWidgetTab.h index 1d37e1d..934b8ed 100644 --- a/src/DockWidgetTab.h +++ b/src/DockWidgetTab.h @@ -133,7 +133,7 @@ public: void setText(const QString& title); /** - * This function returns true if the assigned dock widget is closeable + * This function returns true if the assigned dock widget is closable */ bool isClosable() const;