From c2bd56e2e9a9c6cb26dc88e3049b7f2520c8ae45 Mon Sep 17 00:00:00 2001 From: Syarif Fakhri Date: Fri, 28 Oct 2022 14:20:30 +0800 Subject: [PATCH] add set size to allow the user to set a size for the pinned widget manually --- src/AutoHideDockContainer.cpp | 10 ++++++++-- src/AutoHideDockContainer.h | 9 ++++++++- src/DockWidget.cpp | 15 --------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index efc2774..16544bb 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -322,7 +322,7 @@ CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const void CAutoHideDockContainer::moveContentsToParent() { cleanupAndDelete(); - // If we unpin the auto hide tock widget, then we insert it into the same + // If we unpin the auto hide dock widget, then we insert it into the same // location like it had as a auto hide widget. This brings the least surprise // to the user and he does not have to search where the widget was inserted. parentContainer()->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget); @@ -439,6 +439,12 @@ void CAutoHideDockContainer::toggleCollapseState() collapseView(isVisible()); } +void CAutoHideDockContainer::setSize(int width, int height) +{ + d->Size = QSize(width, height); + updateSize(); +} + //============================================================================ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) @@ -511,7 +517,7 @@ void CAutoHideDockContainer::resizeEvent(QResizeEvent* event) Super::resizeEvent(event); if (d->ResizeHandle->isResizing()) { - d->Size = this->size(); + d->Size = this->size(); d->updateResizeHandleSizeLimitMax(); } } diff --git a/src/AutoHideDockContainer.h b/src/AutoHideDockContainer.h index 047290f..a26f545 100644 --- a/src/AutoHideDockContainer.h +++ b/src/AutoHideDockContainer.h @@ -97,7 +97,7 @@ public: */ void addDockWidget(CDockWidget* DockWidget); - /** + /** * Returns the side tab bar area of this Auto Hide dock container */ SideBarLocation sideTabBarArea() const; @@ -144,6 +144,13 @@ public: * Toggles the current collapse state */ void toggleCollapseState(); + + /** + * Use this instead of resize. This will ensure the size is consistent internally. + * E.g. If you set a height less than the parent height when it's vertical + * It will simply be rescaled to the parent height while the width will be resized + */ + void setSize(int width, int height); }; } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 745a6fe..d3d63b4 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -95,7 +95,6 @@ struct DockWidgetPrivate QList TitleBarActions; CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget; WidgetFactory* Factory = nullptr; - double DefaultAutoHideDockProportion = 0.25; CDockWidget::eAutoHideInsertOrder AutoHideInsertOrder = CDockWidget::Last; /** @@ -1131,20 +1130,6 @@ bool CDockWidget::isCurrentTab() const } -//============================================================================ -void CDockWidget::setDefaultAutoHideDockProportion(float Proportion) -{ - d->DefaultAutoHideDockProportion = Proportion; -} - - -//============================================================================ -float CDockWidget::DefaultAutoHideDockProportion() const -{ - return d->DefaultAutoHideDockProportion; -} - - //============================================================================ void CDockWidget::setAutoHideInsertOrder(eAutoHideInsertOrder insertOrder) {