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

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 committed by Jon Jenssen
parent 114f2701c6
commit ebbb7adb7f
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 bool CDockWidget::isCentralWidget() const
{ {
@ -990,14 +997,20 @@ void CDockWidget::setClosedState(bool Closed)
//============================================================================ //============================================================================
QSize CDockWidget::minimumSizeHint() const QSize CDockWidget::minimumSizeHint() const
{ {
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget) if (!d->Widget)
{ {
return QSize(60, 40); 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 * reimplements minimumSizeHint() function to return a very small minimum
* 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. 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 enum eMinimumSizeHintMode
{ {
MinimumSizeHintFromDockWidget, MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent MinimumSizeHintFromContent,
MinimumSizeHintFromDockWidgetMinimumSize,
MinimumSizeHintFromContentMinimumSize,
}; };
@ -411,6 +416,11 @@ public:
*/ */
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode); 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 * Returns true if the dock widget is set as central widget of it's dock manager
*/ */