Merged #518 - Add more options to determine the minimum size of a dock widget

This commit is contained in:
Uwe Kindler 2023-06-06 15:25:49 +02:00
parent f9b5ef8d89
commit 87954e4459
2 changed files with 28 additions and 5 deletions

View File

@ -622,6 +622,13 @@ void CDockWidget::setMinimumSizeHintMode(eMinimumSizeHintMode Mode)
}
//============================================================================
CDockWidget::eMinimumSizeHintMode CDockWidget::minimumSizeHintMode() const
{
return d->MinimumSizeHintMode;
}
//============================================================================
bool CDockWidget::isCentralWidget() const
{
@ -990,14 +997,20 @@ void CDockWidget::setClosedState(bool Closed)
//============================================================================
QSize CDockWidget::minimumSizeHint() const
{
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
if (!d->Widget)
{
return QSize(60, 40);
}
else
switch (d->MinimumSizeHintMode)
{
return d->Widget->minimumSizeHint();
case MinimumSizeHintFromDockWidget: return QSize(60, 40);
case MinimumSizeHintFromContent: return d->Widget->minimumSizeHint();
case MinimumSizeHintFromDockWidgetMinimumSize: return minimumSize();
case MinimumSizeHintFromContentMinimumSize: return d->Widget->minimumSize();
}
return d->Widget->minimumSizeHint();
}

View File

@ -208,12 +208,17 @@ public:
* reimplements minimumSizeHint() function to return a very small minimum
* size hint. If you would like to adhere the minimumSizeHint() from the
* content widget, then set the minimumSizeHintMode() to
* MinimumSizeHintFromContent.
* MinimumSizeHintFromContent. If you would like to use the minimumSize()
* value of the content widget or the dock widget, then you can use the
* MinimumSizeHintFromDockWidgetMinimumSize or
* MinimumSizeHintFromContentMinimumSize modes.
*/
enum eMinimumSizeHintMode
{
MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent
MinimumSizeHintFromContent,
MinimumSizeHintFromDockWidgetMinimumSize,
MinimumSizeHintFromContentMinimumSize,
};
@ -411,6 +416,11 @@ public:
*/
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
/**
* Get the minimum size hint mode configured by setMinimumSizeHintMode
*/
eMinimumSizeHintMode minimumSizeHintMode() const;
/**
* Returns true if the dock widget is set as central widget of it's dock manager
*/