From 052d3cecb9cc5bb16ed528e7634dd6aa0385490e Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Tue, 6 Sep 2022 17:59:56 +0800 Subject: [PATCH] Fix check state of the auto hide button when dragging the container into a floating window --- src/DockAreaWidget.cpp | 9 +++++++++ src/DockAreaWidget.h | 5 +++++ src/DockContainerWidget.cpp | 7 ++----- src/OverlayDockContainer.cpp | 5 +---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 245efc0..c6c3f79 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -800,6 +800,15 @@ void CDockAreaWidget::markTitleBarMenuOutdated() } +//============================================================================ +void CDockAreaWidget::updateAutoHidebuttonCheckState() +{ + auto autoHideButton = titleBarButton(TitleBarButtonAutoHide); + autoHideButton->blockSignals(true); + autoHideButton->setChecked(isOverlayed()); + autoHideButton->blockSignals(false); +} + //============================================================================ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index b92e34d..9c39c2a 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -150,6 +150,11 @@ protected: */ void markTitleBarMenuOutdated(); + /* + * Update the auto hide button checked state based on if it's overlayed or not + */ + void updateAutoHidebuttonCheckState(); + protected Q_SLOTS: void toggleView(bool Open); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 7f970b2..2e4c25c 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1063,9 +1063,7 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s, dockContainer->hide(); DockArea = dockContainer->dockAreaWidget(); - const auto titleBar = DockArea->titleBar(); - QSignalBlocker blocker(titleBar); - titleBar->button(TitleBarButtonAutoHide)->setChecked(true); + DockArea->updateAutoHidebuttonCheckState(); } while (s.readNextStartElement()) @@ -1655,6 +1653,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) dumpLayout(); d->emitDockAreasRemoved(); area->setOverlayDockContainer(nullptr); + area->updateAutoHidebuttonCheckState(); return; } @@ -1783,8 +1782,6 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor(); bool Dropped = false; - // Handle any overlay widgets - // todo: cleanup - move into own func? auto overlayWidgets = FloatingWidget->dockContainer()->overlayWidgets(); for (const auto overlayWidget : overlayWidgets) { diff --git a/src/OverlayDockContainer.cpp b/src/OverlayDockContainer.cpp index 812c969..ecf3945 100644 --- a/src/OverlayDockContainer.cpp +++ b/src/OverlayDockContainer.cpp @@ -82,10 +82,7 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, SideTabB d->DockArea = new CDockAreaWidget(DockManager, parent); d->DockArea->setObjectName("OverlayDockArea"); d->DockArea->setOverlayDockContainer(this); - auto autoHideButton = d->DockArea->titleBar()->button(TitleBarButtonAutoHide); - autoHideButton->blockSignals(true); - autoHideButton->setChecked(true); - autoHideButton->blockSignals(false); + d->DockArea->updateAutoHidebuttonCheckState(); QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight); d->Splitter = new QSplitter(Qt::Orientation::Horizontal);