1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

Add more options to determine the minimum size of a dock widget

This commit is contained in:
Madrich 2023-05-20 23:33:34 +02:00
parent 0301e345b4
commit d21e223280
2 changed files with 23 additions and 9 deletions

View File

@ -621,6 +621,11 @@ void CDockWidget::setMinimumSizeHintMode(eMinimumSizeHintMode Mode)
d->MinimumSizeHintMode = Mode; d->MinimumSizeHintMode = Mode;
} }
//============================================================================
ads::CDockWidget::eMinimumSizeHintMode CDockWidget::getMinimumSizeHintMode() const
{
return d->MinimumSizeHintMode;
}
//============================================================================ //============================================================================
bool CDockWidget::isCentralWidget() const bool CDockWidget::isCentralWidget() const
@ -991,13 +996,14 @@ void CDockWidget::setClosedState(bool Closed)
QSize CDockWidget::minimumSizeHint() const QSize CDockWidget::minimumSizeHint() const
{ {
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget) if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
{
return QSize(60, 40); return QSize(60, 40);
} else if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidgetMinimumSize)
else return minimumSize();
{ else if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromContentMinimumSize)
return d->Widget->minimumSizeHint(); return d->Widget->minimumSize();
}
// default from widget
return d->Widget->minimumSizeHint();
} }

View File

@ -209,11 +209,14 @@ public:
* size hint. If you would like to adhere the minimumSizeHint() from the * size hint. If you would like to adhere the minimumSizeHint() from the
* content widget, then set the minimumSizeHintMode() to * content widget, then set the minimumSizeHintMode() to
* MinimumSizeHintFromContent. * MinimumSizeHintFromContent.
* Set minimumSizeHint to the docks or widgets minimumSize for special control.
*/ */
enum eMinimumSizeHintMode enum eMinimumSizeHintMode
{ {
MinimumSizeHintFromDockWidget, MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent MinimumSizeHintFromContent,
MinimumSizeHintFromDockWidgetMinimumSize,
MinimumSizeHintFromContentMinimumSize,
}; };
@ -411,6 +414,11 @@ public:
*/ */
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode); void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
/**
* Get the minimum size hint mode configured by setMinimumSizeHintMode
*/
eMinimumSizeHintMode getMinimumSizeHintMode() const;
/** /**
* Returns true if the dock widget is set as central widget of it's dock manager * Returns true if the dock widget is set as central widget of it's dock manager
*/ */