Skip to content

Commit e239cdb

Browse files
Improved sizing of AutoHideWidgets when dragging between side bars
1 parent 7140e5e commit e239cdb

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

src/AutoHideDockContainer.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct AutoHideDockContainerPrivate
117117
CResizeHandle* ResizeHandle = nullptr;
118118
QSize Size; // creates invalid size
119119
QPointer<CAutoHideTab> SideTab;
120-
QSize InitialDockWidgetSize;
120+
QSize SizeCache;
121121

122122
/**
123123
* Private data constructor
@@ -216,7 +216,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
216216
bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
217217
d->ResizeHandle->setOpaqueResize(OpaqueResize);
218218
d->Size = d->DockArea->size();
219-
d->InitialDockWidgetSize = DockWidget->size();
219+
d->SizeCache = DockWidget->size();
220220

221221
addDockWidget(DockWidget);
222222
parent->registerAutoHideWidget(this);
@@ -239,12 +239,6 @@ void CAutoHideDockContainer::updateSize()
239239
}
240240

241241
auto rect = dockContainerParent->contentRect();
242-
qDebug() << "dockContainerParent->contentRect() " << rect;
243-
qDebug() << "dockWidget()->rect()" << dockWidget()->rect();
244-
qDebug() << "dockAreaWidget()->rect(): " << dockAreaWidget()->rect();
245-
qDebug() << "CAutoHideDockContainer::isVisible " << this->isVisible();
246-
qDebug() << "CAutoHideDockContainer::rect " << this->rect();
247-
248242
switch (sideBarLocation())
249243
{
250244
case SideBarLocation::SideBarTop:
@@ -279,8 +273,14 @@ void CAutoHideDockContainer::updateSize()
279273
break;
280274
}
281275

282-
qDebug() << "CAutoHideDockContainer::rect (after): " << this->rect();
283-
qDebug() << "dockAreaWidget()->rect(): " << dockAreaWidget()->rect();
276+
if (orientation() == Qt::Horizontal)
277+
{
278+
d->SizeCache.setHeight(this->height());
279+
}
280+
else
281+
{
282+
d->SizeCache.setWidth(this->width());
283+
}
284284
}
285285

286286
//============================================================================
@@ -658,31 +658,24 @@ bool CAutoHideDockContainer::event(QEvent* event)
658658
}
659659

660660

661-
//============================================================================
662-
QSize CAutoHideDockContainer::initialDockWidgetSize() const
663-
{
664-
return d->InitialDockWidgetSize;
665-
}
666-
667-
668661
//============================================================================
669662
Qt::Orientation CAutoHideDockContainer::orientation() const
670663
{
671-
return autoHideSideBar()->orientation();
664+
return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea)
665+
? Qt::Horizontal : Qt::Vertical;
672666
}
673667

674668

675669
//============================================================================
676670
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
677671
{
678-
auto OriginalSize = initialDockWidgetSize();
679672
if (orientation() == Qt::Horizontal)
680673
{
681-
setSize(OriginalSize.height());
674+
setSize(d->SizeCache.height());
682675
}
683676
else
684677
{
685-
setSize(OriginalSize.width());
678+
setSize(d->SizeCache.width());
686679
}
687680
}
688681

@@ -691,8 +684,6 @@ void CAutoHideDockContainer::resetToInitialDockWidgetSize()
691684
void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation,
692685
int TabIndex)
693686
{
694-
qDebug() << "CAutoHideDockContainer::moveToNewSideBarLocation TabIndex " <<
695-
TabIndex << " this->tabIndex: " << this->tabIndex();
696687
if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
697688
{
698689
return;

src/AutoHideDockContainer.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
172172
*/
173173
void setSize(int Size);
174174

175-
/**
176-
* Returns the original size of the dock widget at the time it has been
177-
* added to this auto hide widget
178-
*/
179-
QSize initialDockWidgetSize() const;
180-
181175
/**
182176
* Resets the with or hight to the initial dock widget size dependinng on
183177
* the orientation.

0 commit comments

Comments
 (0)