From 28745fa2f88bd6efbdb147d1ceef54cc96c2ab1a Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 1 Nov 2022 17:17:58 +0100 Subject: [PATCH] Some small improvements and execute auto hide code only if config is enabled --- src/AutoHideDockContainer.cpp | 2 -- src/DockAreaWidget.cpp | 27 +++++++++++++++++++-------- src/DockAreaWidget.h | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 6256b78..d84d605 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -190,8 +190,6 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa d->DockArea = new CDockAreaWidget(DockManager, parent); d->DockArea->setObjectName("autoHideDockArea"); d->DockArea->setAutoHideDockContainer(this); - d->DockArea->updateAutoHideButtonCheckState(); - d->DockArea->updateTitleBarButtonToolTip(); setObjectName("autoHideDockContainer"); diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 8b7dc24..5f43698 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -455,6 +455,8 @@ bool CDockAreaWidget::isAutoHide() const void CDockAreaWidget::setAutoHideDockContainer(CAutoHideDockContainer* AutoHideDockContainer) { d->AutoHideDockContainer = AutoHideDockContainer; + updateAutoHideButtonCheckState(); + updateTitleBarButtonToolTip(); } @@ -812,16 +814,24 @@ void CDockAreaWidget::updateTitleBarVisibility() return; } - if (d->TitleBar) + if (!d->TitleBar) + { + return; + } + + bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating() + || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar)); + Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1); + bool IsAutoHide = isAutoHide(); + Hidden &= !IsAutoHide; // Titlebar must always be visible when auto hidden so it can be dragged + d->TitleBar->setVisible(!Hidden); + + if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled)) { - bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating() - || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar)); - Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1); - d->TitleBar->setVisible(isAutoHide() ? true : !Hidden); // Titlebar must always be visible when auto hidden so it can be dragged auto tabBar = d->TitleBar->tabBar(); - tabBar->setVisible(isAutoHide() ? false : !Hidden); // Never show tab bar when auto hidden - d->TitleBar->autoHideTitleLabel()->setVisible(isAutoHide()); // Always show when auto hidden, never otherwise - updateTitleBarButtonVisibility(Container->topLevelDockArea() == this); + tabBar->setVisible(!IsAutoHide); // Never show tab bar when auto hidden + d->TitleBar->autoHideTitleLabel()->setVisible(IsAutoHide); // Always show when auto hidden, never otherwise + updateTitleBarButtonVisibility(Container->topLevelDockArea() == this); } } @@ -849,6 +859,7 @@ void CDockAreaWidget::updateAutoHideButtonCheckState() //============================================================================ void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const { + qDebug() << "CDockAreaWidget::updateTitleBarButtonVisibility IsTopLevel " << IsTopLevel; d->updateTitleBarButtonVisibility(IsTopLevel); } diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index 4059a83..d177fb8 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -79,6 +79,16 @@ private Q_SLOTS: */ void reorderDockWidget(int fromIndex, int toIndex); + /* + * Update the auto hide button checked state based on if it's contained in an auto hide container or not + */ + void updateAutoHideButtonCheckState(); + + /* + * Update the title bar button tooltips + */ + void updateTitleBarButtonToolTip(); + protected: #ifdef Q_OS_WIN @@ -152,21 +162,11 @@ protected: */ void markTitleBarMenuOutdated(); - /* - * Update the auto hide button checked state based on if it's contained in an auto hide container or not - */ - void updateAutoHideButtonCheckState(); - /* * Update the title bar button visibility based on if it's top level or not */ void updateTitleBarButtonVisibility(bool IsTopLevel) const; - /* - * Update the title bar button tooltips - */ - void updateTitleBarButtonToolTip(); - protected Q_SLOTS: void toggleView(bool Open);