From 9c14c62637d275fd6ddfb3b758752e3af3616ea8 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 2 Nov 2022 08:27:23 +0100 Subject: [PATCH] Added setAutoHide() and toggleAutoHide() function to CDockWidget --- src/DockAreaWidget.cpp | 10 ++-------- src/DockWidget.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/DockWidget.h | 12 ++++++++++++ 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 651b674..8ec5e0e 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -1304,11 +1304,10 @@ void CDockAreaWidget::setAutoHide(bool Enable) return; } - const auto area = calculateSideTabBarArea(); - if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea) && features().testFlag(CDockWidget::DockWidgetPinnable)) { + auto area = calculateSideTabBarArea(); for (const auto DockWidget : openedDockWidgets()) { if (Enable == isAutoHide()) @@ -1321,12 +1320,7 @@ void CDockAreaWidget::setAutoHide(bool Enable) } else { - const auto DockWidget = currentDockWidget(); - if (Enable == isAutoHide()) - { - return; - } - dockContainer()->createAndSetupAutoHideContainer(area, DockWidget); + currentDockWidget()->setAutoHide(true); } } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index ca3f55b..31f3cb9 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1156,6 +1156,45 @@ void CDockWidget::raise() } +//============================================================================ +void CDockWidget::setAutoHide(bool Enable) +{ + if (!CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled)) + { + return; + } + + // Do nothing if nothing changes + if (Enable == isAutoHide()) + { + return; + } + + auto DockArea = dockAreaWidget(); + if (!Enable) + { + DockArea->setAutoHide(false); + } + else + { + auto area = DockArea->calculateSideTabBarArea(); + dockContainer()->createAndSetupAutoHideContainer(area, this); + } +} + + +//============================================================================ +void CDockWidget::toggleAutoHide() +{ + if (!CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled)) + { + return; + } + + setAutoHide(!isAutoHide()); +} + + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockWidget.h b/src/DockWidget.h index b0d9f54..115c02c 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -592,6 +592,18 @@ public Q_SLOTS: */ void showNormal(); + /** + * Sets the dock widget into auto hide mode if this feature is enabled + * via CDockManager::setAutoHideFlags(CDockManager::AutoHideFeatureEnabled) + */ + void setAutoHide(bool Enable); + + /** + * Switches the dock widget to auto hide mode or vice versa depending on its + * current state. + */ + void toggleAutoHide(); + Q_SIGNALS: /**