From e239cdb3549354cfdf276b59614364d756d6ab35 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 12 Jul 2023 14:37:45 +0200 Subject: [PATCH] Improved sizing of AutoHideWidgets when dragging between side bars --- src/AutoHideDockContainer.cpp | 37 +++++++++++++---------------------- src/AutoHideDockContainer.h | 6 ------ 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 171a517..4d8cac2 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -117,7 +117,7 @@ struct AutoHideDockContainerPrivate CResizeHandle* ResizeHandle = nullptr; QSize Size; // creates invalid size QPointer SideTab; - QSize InitialDockWidgetSize; + QSize SizeCache; /** * Private data constructor @@ -216,7 +216,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize); d->ResizeHandle->setOpaqueResize(OpaqueResize); d->Size = d->DockArea->size(); - d->InitialDockWidgetSize = DockWidget->size(); + d->SizeCache = DockWidget->size(); addDockWidget(DockWidget); parent->registerAutoHideWidget(this); @@ -239,12 +239,6 @@ void CAutoHideDockContainer::updateSize() } auto rect = dockContainerParent->contentRect(); - qDebug() << "dockContainerParent->contentRect() " << rect; - qDebug() << "dockWidget()->rect()" << dockWidget()->rect(); - qDebug() << "dockAreaWidget()->rect(): " << dockAreaWidget()->rect(); - qDebug() << "CAutoHideDockContainer::isVisible " << this->isVisible(); - qDebug() << "CAutoHideDockContainer::rect " << this->rect(); - switch (sideBarLocation()) { case SideBarLocation::SideBarTop: @@ -279,8 +273,14 @@ void CAutoHideDockContainer::updateSize() break; } - qDebug() << "CAutoHideDockContainer::rect (after): " << this->rect(); - qDebug() << "dockAreaWidget()->rect(): " << dockAreaWidget()->rect(); + if (orientation() == Qt::Horizontal) + { + d->SizeCache.setHeight(this->height()); + } + else + { + d->SizeCache.setWidth(this->width()); + } } //============================================================================ @@ -658,31 +658,24 @@ bool CAutoHideDockContainer::event(QEvent* event) } -//============================================================================ -QSize CAutoHideDockContainer::initialDockWidgetSize() const -{ - return d->InitialDockWidgetSize; -} - - //============================================================================ Qt::Orientation CAutoHideDockContainer::orientation() const { - return autoHideSideBar()->orientation(); + return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea) + ? Qt::Horizontal : Qt::Vertical; } //============================================================================ void CAutoHideDockContainer::resetToInitialDockWidgetSize() { - auto OriginalSize = initialDockWidgetSize(); if (orientation() == Qt::Horizontal) { - setSize(OriginalSize.height()); + setSize(d->SizeCache.height()); } else { - setSize(OriginalSize.width()); + setSize(d->SizeCache.width()); } } @@ -691,8 +684,6 @@ void CAutoHideDockContainer::resetToInitialDockWidgetSize() void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation, int TabIndex) { - qDebug() << "CAutoHideDockContainer::moveToNewSideBarLocation TabIndex " << - TabIndex << " this->tabIndex: " << this->tabIndex(); if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex()) { return; diff --git a/src/AutoHideDockContainer.h b/src/AutoHideDockContainer.h index 469e1e3..fc984a7 100644 --- a/src/AutoHideDockContainer.h +++ b/src/AutoHideDockContainer.h @@ -172,12 +172,6 @@ public: */ void setSize(int Size); - /** - * Returns the original size of the dock widget at the time it has been - * added to this auto hide widget - */ - QSize initialDockWidgetSize() const; - /** * Resets the with or hight to the initial dock widget size dependinng on * the orientation.