mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Added support for runtime switching of CAutoHideDockContainer sidebar location
This commit is contained in:
parent
ac1a0962d3
commit
0b5840309f
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user