From 2cd451c53c2f45159f9108d988e5bec1dc9de4d1 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 9 Dec 2022 08:50:41 +0100 Subject: [PATCH] Added dockContainer() function to AutoHideSideBar.cpp --- src/AutoHideSideBar.cpp | 8 ++++++++ src/AutoHideSideBar.h | 5 +++++ src/DockWidget.cpp | 32 +++++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/AutoHideSideBar.cpp b/src/AutoHideSideBar.cpp index 6a1ebe2..c64b079 100644 --- a/src/AutoHideSideBar.cpp +++ b/src/AutoHideSideBar.cpp @@ -378,11 +378,19 @@ int CAutoHideSideBar::spacing() const return d->TabsLayout->spacing(); } + //=========================================================================== void CAutoHideSideBar::setSpacing(int Spacing) { d->TabsLayout->setSpacing(Spacing); } + +//=========================================================================== +CDockContainerWidget* CAutoHideSideBar::dockContainer() const +{ + return d->ContainerWidget; +} + } // namespace ads diff --git a/src/AutoHideSideBar.h b/src/AutoHideSideBar.h index 6ec816a..3575357 100644 --- a/src/AutoHideSideBar.h +++ b/src/AutoHideSideBar.h @@ -163,6 +163,11 @@ public: * Setter for spacing property - sets the spacing */ void setSpacing(int Spacing); + + /** + * Returns the dock container that hosts this sideBar() + */ + CDockContainerWidget* dockContainer() const; }; } // namespace ads //----------------------------------------------------------------------------- diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index e519880..569f77b 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -248,17 +248,31 @@ void DockWidgetPrivate::updateParentDockArea() //============================================================================ void DockWidgetPrivate::closeAutoHideDockWidgetsIfNeeded() { - if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty() && !_this->dockManager()->isRestoringState()) + auto DockContainer = _this->dockContainer(); + if (!DockContainer) { - for (auto autoHideWidget : _this->dockContainer()->autoHideWidgets()) - { - if (autoHideWidget->dockWidget() == _this) - { - continue; - } + return; + } - autoHideWidget->dockWidget()->toggleView(false); - } + if (_this->dockManager()->isRestoringState()) + { + return; + } + + if (!DockContainer->openedDockWidgets().isEmpty()) + { + return; + } + + for (auto autoHideWidget : DockContainer->autoHideWidgets()) + { + auto DockWidget = autoHideWidget->dockWidget(); + if (DockWidget == _this) + { + continue; + } + + DockWidget->toggleView(false); } }