mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-14 00:52:05 +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;
|
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
|
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,6 @@ protected:
|
|||||||
virtual void leaveEvent(QEvent *event) override;
|
virtual void leaveEvent(QEvent *event) override;
|
||||||
virtual bool event(QEvent* event) override;
|
virtual bool event(QEvent* event) override;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the size considering the size limits and the resize margins
|
* Updates the size considering the size limits and the resize margins
|
||||||
*/
|
*/
|
||||||
@ -116,6 +115,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
SideBarLocation sideBarLocation() const;
|
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
|
* 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)
|
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
|
||||||
{
|
{
|
||||||
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
|
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
|
||||||
|
if (SideBar == this)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (SideBar)
|
if (SideBar)
|
||||||
{
|
{
|
||||||
SideBar->removeAutoHideWidget(AutoHideWidget);
|
SideBar->removeAutoHideWidget(AutoHideWidget);
|
||||||
}
|
}
|
||||||
AutoHideWidget->setParent(d->ContainerWidget);
|
AutoHideWidget->setParent(d->ContainerWidget);
|
||||||
|
AutoHideWidget->setSideBarLocation(d->SideTabArea);
|
||||||
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
|
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
|
||||||
insertTab(-1, AutoHideWidget->autoHideTab());
|
insertTab(-1, AutoHideWidget->autoHideTab());
|
||||||
}
|
}
|
||||||
|
@ -167,18 +167,8 @@ CResizeHandle::CResizeHandle(Qt::Edge HandlePosition, QWidget* parent) :
|
|||||||
d(new ResizeHandlePrivate(this))
|
d(new ResizeHandlePrivate(this))
|
||||||
{
|
{
|
||||||
d->Target = parent;
|
d->Target = parent;
|
||||||
setHandlePosition(HandlePosition);
|
|
||||||
setMinResizeSize(48);
|
setMinResizeSize(48);
|
||||||
setMaxResizeSize(d->isHorizontal() ? parent->height() : parent->width());
|
setHandlePosition(HandlePosition);
|
||||||
|
|
||||||
if (!d->isHorizontal())
|
|
||||||
{
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,6 +234,16 @@ void CResizeHandle::setHandlePosition(Qt::Edge HandlePosition)
|
|||||||
case Qt::TopEdge: // fall through
|
case Qt::TopEdge: // fall through
|
||||||
case Qt::BottomEdge: setCursor(Qt::SizeVerCursor); break;
|
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