From bfab7e495a67a68d2383d89713ed8d6d9a6855b9 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Tue, 6 Sep 2022 13:49:11 +0800 Subject: [PATCH] Move logic for enabling auto hide into the public toggle method --- src/DockAreaTitleBar.cpp | 7 +++---- src/DockAreaWidget.cpp | 7 ++++++- src/DockAreaWidget.h | 12 ++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 13021e3..8795e0b 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -457,12 +457,11 @@ void CDockAreaTitleBar::onCurrentTabChanged(int Index) updateDockWidgetActionsButtons(); } + +//============================================================================ void CDockAreaTitleBar::onAutoHideButtonClicked(bool Checked) { - if (Checked != d->DockArea->isOverlayed()) - { - d->DockArea->toggleAutoHideArea(); - } + d->DockArea->toggleAutoHideArea(Checked); } diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 508fb7c..dba2568 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -1009,11 +1009,16 @@ void CDockAreaWidget::closeArea() } //============================================================================ -void CDockAreaWidget::toggleAutoHideArea() +void CDockAreaWidget::toggleAutoHideArea(bool Enable) { const auto area = dockContainer()->getDockAreaPosition(this); for (const auto DockWidget : openedDockWidgets()) { + if (Enable == isOverlayed()) + { + continue; + } + onAutoHideToggleRequested(DockWidget, !isOverlayed(), area); } } diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index d34c352..b92e34d 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -153,6 +153,11 @@ protected: protected Q_SLOTS: void toggleView(bool Open); + /** + * Auto hides the dock area and all dock widgets in this area + */ + void onAutoHideToggleRequested(CDockWidget* DockWidget, bool Enable, SideTabBarArea area); + public: using Super = QFrame; @@ -357,12 +362,7 @@ public Q_SLOTS: /** * Toggles the Auto hides behaviour of the dock area and all dock widgets in this area */ - void toggleAutoHideArea(); - - /** - * Auto hides the dock area and all dock widgets in this area - */ - void onAutoHideToggleRequested(CDockWidget* DockWidget, bool Enable, SideTabBarArea area); + void toggleAutoHideArea(bool Enable); /** * This function closes all other areas except of this area