Added support for runtime switching of CAutoHideDockContainer sidebar location

This commit is contained in:
Uwe Kindler 2022-11-15 15:08:52 +01:00
parent ac1a0962d3
commit 0b5840309f
4 changed files with 42 additions and 12 deletions

View File

@ -353,6 +353,24 @@ SideBarLocation CAutoHideDockContainer::sideBarLocation() const
return d->SideTabBarArea;
}
//============================================================================
void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
{
if (d->SideTabBarArea == SideBarLocation)
{
return;
}
d->SideTabBarArea = SideBarLocation;
d->Layout->removeWidget(d->ResizeHandle);
d->Layout->setDirection(isHorizontalArea(SideBarLocation) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation), d->ResizeHandle);
d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
internal::repolishStyle(this, internal::RepolishDirectChildren);
}
//============================================================================
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
{

View File

@ -66,7 +66,6 @@ protected:
virtual void leaveEvent(QEvent *event) override;
virtual bool event(QEvent* event) override;
/**
* Updates the size considering the size limits and the resize margins
*/
@ -116,6 +115,13 @@ public:
*/
SideBarLocation sideBarLocation() const;
/**
* Sets a new SideBarLocation.
* If a new side bar location is set, the auto hide dock container needs
* to update its resize handle position
*/
void setSideBarLocation(SideBarLocation SideBarLocation);
/**
* Returns the dock area widget of this Auto Hide dock container
*/

View File

@ -257,11 +257,17 @@ void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidg
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
{
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
if (SideBar == this)
{
return;
}
if (SideBar)
{
SideBar->removeAutoHideWidget(AutoHideWidget);
}
AutoHideWidget->setParent(d->ContainerWidget);
AutoHideWidget->setSideBarLocation(d->SideTabArea);
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
insertTab(-1, AutoHideWidget->autoHideTab());
}

View File

@ -167,18 +167,8 @@ CResizeHandle::CResizeHandle(Qt::Edge HandlePosition, QWidget* parent) :
d(new ResizeHandlePrivate(this))
{
d->Target = parent;
setHandlePosition(HandlePosition);
setMinResizeSize(48);
setMaxResizeSize(d->isHorizontal() ? parent->height() : parent->width());
if (!d->isHorizontal())
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
else
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
}
setHandlePosition(HandlePosition);
}
@ -244,6 +234,16 @@ void CResizeHandle::setHandlePosition(Qt::Edge HandlePosition)
case Qt::TopEdge: // fall through
case Qt::BottomEdge: setCursor(Qt::SizeVerCursor); break;
}
setMaxResizeSize(d->isHorizontal() ? parentWidget()->height() : parentWidget()->width());
if (!d->isHorizontal())
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
else
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
}
}