Added support to adhere the minimumSizeHint() of the content widget of a dock widget

This commit is contained in:
Uwe Kindler 2020-03-26 07:09:01 +01:00
parent 661d0c4356
commit d0f4ce3248
2 changed files with 40 additions and 1 deletions

View File

@ -82,6 +82,7 @@ struct DockWidgetPrivate
QSize ToolBarIconSizeFloating = QSize(24, 24); QSize ToolBarIconSizeFloating = QSize(24, 24);
bool IsFloatingTopLevel = false; bool IsFloatingTopLevel = false;
QList<QAction*> TitleBarActions; QList<QAction*> TitleBarActions;
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
/** /**
* Private data constructor * Private data constructor
@ -424,6 +425,13 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
} }
//============================================================================
void CDockWidget::setMinimumSizeHintMode(eMinimumSizeHintMode Mode)
{
d->MinimumSizeHintMode = Mode;
}
//============================================================================ //============================================================================
void CDockWidget::toggleView(bool Open) void CDockWidget::toggleView(bool Open)
{ {
@ -752,9 +760,16 @@ void CDockWidget::setClosedState(bool Closed)
//============================================================================ //============================================================================
QSize CDockWidget::minimumSizeHint() const QSize CDockWidget::minimumSizeHint() const
{
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
{ {
return QSize(60, 40); return QSize(60, 40);
} }
else
{
return d->Widget->minimumSizeHint();
}
}
//============================================================================ //============================================================================

View File

@ -189,6 +189,23 @@ public:
ForceNoScrollArea ForceNoScrollArea
}; };
/**
* The mode of the minimumSizeHint() that is returned by the DockWidget
* minimumSizeHint() function.
* To ensure, that a dock widget does not block resizing, the dock widget
* reimplements minimumSizeHint() function to return a very small minimum
* size hint. If you would like to adhere the minimumSizeHint() from the
* content widget, the set the minimumSizeHintMode() to
* MinimumSizeHintFromContent.
*/
enum eMinimumSizeHintMode
{
MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent
};
/** /**
* This mode configures the behavior of the toggle view action. * This mode configures the behavior of the toggle view action.
* If the mode if ActionModeToggle, then the toggle view action is * If the mode if ActionModeToggle, then the toggle view action is
@ -334,6 +351,13 @@ public:
*/ */
void setToggleViewActionMode(eToggleViewActionMode Mode); void setToggleViewActionMode(eToggleViewActionMode Mode);
/**
* Configures the minimum size hint that is returned by the
* minimumSizeHint() function.
* \see eMinimumSizeHintMode for a detailed description
*/
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
/** /**
* Sets the dock widget icon that is shown in tabs and in toggle view * Sets the dock widget icon that is shown in tabs and in toggle view
* actions * actions