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;
}
//============================================================================
ads::CDockWidget::eMinimumSizeHintMode CDockWidget::getMinimumSizeHintMode() const
{
return d->MinimumSizeHintMode;
}
//============================================================================
bool CDockWidget::isCentralWidget() const
@ -990,14 +995,15 @@ void CDockWidget::setClosedState(bool Closed)
//============================================================================
QSize CDockWidget::minimumSizeHint() const
{
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
{
return QSize(60, 40);
}
else
{
return d->Widget->minimumSizeHint();
}
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
return QSize(60, 40);
else if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidgetMinimumSize)
return minimumSize();
else if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromContentMinimumSize)
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
* content widget, then set the minimumSizeHintMode() to
* MinimumSizeHintFromContent.
* Set minimumSizeHint to the docks or widgets minimumSize for special control.
*/
enum eMinimumSizeHintMode
{
MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent
MinimumSizeHintFromContent,
MinimumSizeHintFromDockWidgetMinimumSize,
MinimumSizeHintFromContentMinimumSize,
};
@ -411,6 +414,11 @@ public:
*/
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
*/