Skip to content

Commit 0b58403

Browse files
Added support for runtime switching of CAutoHideDockContainer sidebar location
1 parent ac1a096 commit 0b58403

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

src/AutoHideDockContainer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,24 @@ SideBarLocation CAutoHideDockContainer::sideBarLocation() const
353353
return d->SideTabBarArea;
354354
}
355355

356+
357+
//============================================================================
358+
void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
359+
{
360+
if (d->SideTabBarArea == SideBarLocation)
361+
{
362+
return;
363+
}
364+
365+
d->SideTabBarArea = SideBarLocation;
366+
d->Layout->removeWidget(d->ResizeHandle);
367+
d->Layout->setDirection(isHorizontalArea(SideBarLocation) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
368+
d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation), d->ResizeHandle);
369+
d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
370+
internal::repolishStyle(this, internal::RepolishDirectChildren);
371+
}
372+
373+
356374
//============================================================================
357375
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
358376
{

src/AutoHideDockContainer.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
6666
virtual void leaveEvent(QEvent *event) override;
6767
virtual bool event(QEvent* event) override;
6868

69-
7069
/**
7170
* Updates the size considering the size limits and the resize margins
7271
*/
@@ -116,6 +115,13 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
116115
*/
117116
SideBarLocation sideBarLocation() const;
118117

118+
/**
119+
* Sets a new SideBarLocation.
120+
* If a new side bar location is set, the auto hide dock container needs
121+
* to update its resize handle position
122+
*/
123+
void setSideBarLocation(SideBarLocation SideBarLocation);
124+
119125
/**
120126
* Returns the dock area widget of this Auto Hide dock container
121127
*/

src/AutoHideSideBar.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,17 @@ void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidg
257257
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
258258
{
259259
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
260+
if (SideBar == this)
261+
{
262+
return;
263+
}
264+
260265
if (SideBar)
261266
{
262267
SideBar->removeAutoHideWidget(AutoHideWidget);
263268
}
264269
AutoHideWidget->setParent(d->ContainerWidget);
270+
AutoHideWidget->setSideBarLocation(d->SideTabArea);
265271
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
266272
insertTab(-1, AutoHideWidget->autoHideTab());
267273
}

src/ResizeHandle.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,8 @@ CResizeHandle::CResizeHandle(Qt::Edge HandlePosition, QWidget* parent) :
167167
d(new ResizeHandlePrivate(this))
168168
{
169169
d->Target = parent;
170-
setHandlePosition(HandlePosition);
171170
setMinResizeSize(48);
172-
setMaxResizeSize(d->isHorizontal() ? parent->height() : parent->width());
173-
174-
if (!d->isHorizontal())
175-
{
176-
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
177-
}
178-
else
179-
{
180-
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
181-
}
171+
setHandlePosition(HandlePosition);
182172
}
183173

184174

@@ -244,6 +234,16 @@ void CResizeHandle::setHandlePosition(Qt::Edge HandlePosition)
244234
case Qt::TopEdge: // fall through
245235
case Qt::BottomEdge: setCursor(Qt::SizeVerCursor); break;
246236
}
237+
238+
setMaxResizeSize(d->isHorizontal() ? parentWidget()->height() : parentWidget()->width());
239+
if (!d->isHorizontal())
240+
{
241+
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
242+
}
243+
else
244+
{
245+
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
246+
}
247247
}
248248

249249

0 commit comments

Comments
 (0)