From ae5a75bc3f9ab77a559e037dd75d366b1bbaebb8 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 28 Oct 2022 13:19:38 +0200 Subject: [PATCH] Removed DockWidget->sideTabWidget()->setProperty("focused", Focused), DockWidget->sideTabWidget()->updateStyle() because it is not required --- src/AutoHideDockContainer.cpp | 31 +++++++++++++++++++------------ src/AutoHideDockContainer.h | 5 +++++ src/DockContainerWidget.cpp | 1 - src/DockFocusController.cpp | 2 -- src/DockWidget.h | 4 +++- src/DockWidgetSideTab.cpp | 2 +- src/DockWidgetSideTab.h | 2 +- src/SideTabBar.cpp | 3 ++- 8 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 954f2a5..d3ba068 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -268,6 +268,14 @@ CSideTabBar* CAutoHideDockContainer::sideTabBar() const return parentContainer()->sideTabBar(d->SideTabBarArea); } + +//============================================================================ +CDockWidgetSideTab* CAutoHideDockContainer::sideTab() const +{ + return d->SideTab; +} + + //============================================================================ CDockWidget* CAutoHideDockContainer::dockWidget() const { @@ -284,13 +292,13 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget) } d->DockWidget = DockWidget; + d->SideTab = DockWidget->sideTabWidget(); CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget(); if (OldDockArea) { OldDockArea->removeDockWidget(DockWidget); } d->DockArea->addDockWidget(DockWidget); - d->DockWidget->sideTabWidget()->updateOrientationAndSpacing(d->SideTabBarArea); // Prevent overriding of d->Size parameter when this function is called during // state restoring @@ -336,9 +344,10 @@ void CAutoHideDockContainer::cleanupAndDelete() const auto dockWidget = d->DockWidget; if (dockWidget) { - dockWidget->sideTabWidget()->removeFromSideTabBar(); - dockWidget->sideTabWidget()->setParent(dockWidget); - dockWidget->sideTabWidget()->hide(); + auto SideTab = d->SideTab; + SideTab->removeFromSideTabBar(); + SideTab->setParent(dockWidget); + SideTab->hide(); } hide(); @@ -391,18 +400,16 @@ void CAutoHideDockContainer::toggleView(bool Enable) { if (Enable) { - const auto dockWidget = d->DockWidget; - if (dockWidget) + if (d->SideTab) { - dockWidget->sideTabWidget()->show(); + d->SideTab->show(); } } else { - const auto dockWidget = d->DockWidget; - if (dockWidget) + if (d->SideTab) { - dockWidget->sideTabWidget()->hide(); + d->SideTab->hide(); } hide(); qApp->removeEventFilter(this); @@ -429,7 +436,7 @@ void CAutoHideDockContainer::collapseView(bool Enable) } ADS_PRINT("CAutoHideDockContainer::collapseView " << Enable); - d->DockWidget->sideTabWidget()->updateStyle(); + d->SideTab->updateStyle(); } @@ -494,7 +501,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) // because the side tab click handler will call collapseView(). If we // do not ignore this here, then we will collapse the container and the side tab // click handler will uncollapse it - auto SideTab = d->DockWidget->sideTabWidget(); + auto SideTab = d->SideTab; pos = SideTab->mapFromGlobal(me->globalPos()); if (SideTab->rect().contains(pos)) { diff --git a/src/AutoHideDockContainer.h b/src/AutoHideDockContainer.h index c55f9cc..2c0538e 100644 --- a/src/AutoHideDockContainer.h +++ b/src/AutoHideDockContainer.h @@ -89,6 +89,11 @@ public: */ CSideTabBar* sideTabBar() const; + /** + * Returns the side tab + */ + CDockWidgetSideTab* sideTab() const; + /** * Get's the dock widget in this dock container */ diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index f6b15ed..d628ab3 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1546,7 +1546,6 @@ CAutoHideDockContainer* CDockContainerWidget::createAndSetupAutoHideContainer( return nullptr; } - DockWidget->sideTabWidget()->updateOrientationAndSpacing(area); sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget()); DockWidget->sideTabWidget()->show(); diff --git a/src/DockFocusController.cpp b/src/DockFocusController.cpp index f1d3435..3056c07 100644 --- a/src/DockFocusController.cpp +++ b/src/DockFocusController.cpp @@ -70,8 +70,6 @@ static void updateDockWidgetFocusStyle(CDockWidget* DockWidget, bool Focused) DockWidget->setProperty("focused", Focused); DockWidget->tabWidget()->setProperty("focused", Focused); DockWidget->tabWidget()->updateStyle(); - DockWidget->sideTabWidget()->setProperty("focused", Focused); - DockWidget->sideTabWidget()->updateStyle(); internal::repolishStyle(DockWidget); } diff --git a/src/DockWidget.h b/src/DockWidget.h index 60df0e3..52d87b2 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -365,7 +365,9 @@ public: CDockAreaWidget* dockAreaWidget() const; /** - * Returns the side tab widget for this dock + * Returns the side tab widget for this dock, if this dock widget is in + * a auto hide container. If it is not in a auto hide container, then this + * function returns a nullptr, */ CDockWidgetSideTab* sideTabWidget() const; diff --git a/src/DockWidgetSideTab.cpp b/src/DockWidgetSideTab.cpp index e4e6423..3eb2845 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/DockWidgetSideTab.cpp @@ -142,7 +142,7 @@ Qt::Orientation CDockWidgetSideTab::orientation() const //============================================================================ -void CDockWidgetSideTab::updateOrientationAndSpacing(SideBarLocation area) +void CDockWidgetSideTab::updateOrientationForArea(SideBarLocation area) { setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical); diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index f9c2bc6..f01e8b8 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -106,7 +106,7 @@ public: /** * Update the orientation, visibility and spacing based on the area and the config */ - void updateOrientationAndSpacing(SideBarLocation area); + void updateOrientationForArea(SideBarLocation area); /** * Returns true, if this is the active tab. The tab is active if the auto hide widget is visible diff --git a/src/SideTabBar.cpp b/src/SideTabBar.cpp index 5cd1d4e..cf380e4 100644 --- a/src/SideTabBar.cpp +++ b/src/SideTabBar.cpp @@ -128,6 +128,7 @@ CSideTabBar::~CSideTabBar() //============================================================================ void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab) { + SideTab->updateOrientationForArea(d->SideTabArea); SideTab->installEventFilter(this); d->TabsLayout->insertWidget(Index, SideTab); SideTab->setSideTabBar(this); @@ -142,7 +143,7 @@ CAutoHideDockContainer* CSideTabBar::insertDockWidget(int Index, CDockWidget* Do auto area = sideTabBarArea(); qDebug() << "area " << area; Tab->setSideTabBar(this); - Tab->updateOrientationAndSpacing(area); + Tab->updateOrientationForArea(area); d->TabsLayout->insertWidget(Index, Tab); Tab->show();