From 87f5b6127b6331bdf72514ded13087745c09f465 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 11 Nov 2022 16:33:12 +0100 Subject: [PATCH] Fixed restoreSideBar() function to prevent multiple side tabs for the same dock widget --- src/AutoHideTab.h | 6 ++++-- src/DockContainerWidget.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/AutoHideTab.h b/src/AutoHideTab.h index fec49cd..9b5c94a 100644 --- a/src/AutoHideTab.h +++ b/src/AutoHideTab.h @@ -40,6 +40,7 @@ class CDockWidget; class CAutoHideSideBar; class CDockWidgetTab; struct SideTabIconLabelPrivate; +struct DockContainerWidgetPrivate; /** * A dock widget Side tab that shows a title or an icon. @@ -60,12 +61,13 @@ private: friend struct AutoHideTabPrivate; friend class CDockWidget; friend class CAutoHideDockContainer; - -protected: friend class CAutoHideSideBar; friend class CDockAreaWidget; friend class CDockContainerWidget; + friend DockContainerWidgetPrivate; + +protected: void setSideBar(CAutoHideSideBar *SideTabBar); void removeFromSideBar(); virtual bool event(QEvent* event) override; diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 3876ff5..d3ece1e 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1104,7 +1104,20 @@ bool DockContainerWidgetPrivate::restoreSideBar(CDockingStateReader& s, } auto SideBar = _this->sideTabBar(Area); - auto AutoHideContainer = SideBar->insertDockWidget(-1, DockWidget); + CAutoHideDockContainer* AutoHideContainer; + if (DockWidget->isAutoHide()) + { + AutoHideContainer = DockWidget->autoHideDockContainer(); + if (AutoHideContainer->sideBar() != SideBar) + { + AutoHideContainer->autoHideTab()->removeFromSideBar(); + SideBar->insertTab(-1, AutoHideContainer->autoHideTab()); + } + } + else + { + AutoHideContainer = SideBar->insertDockWidget(-1, DockWidget); + } AutoHideContainer->setSize(Size); DockWidget->setProperty(internal::ClosedProperty, Closed); DockWidget->setProperty(internal::DirtyProperty, false);