Skip to content
Permalink
Browse files
Partially revert #42365, and make
the new panel sizing behavior opt-in
  • Loading branch information
nyalldawson committed Jun 9, 2021
1 parent 3a4d437 commit 84669887b647f27fff4f467dc1d4a53b108359c0
@@ -66,6 +66,16 @@ Set the widget in dock mode which tells the widget to emit panel
widgets and not open dialogs

:param dockMode: ``True`` to enable dock mode.
%End

virtual bool applySizeConstraintsToStack() const;
%Docstring
Returns ``True`` if the size constraints and hints for the panel widget should be
applied to the parent :py:class:`QgsPanelWidgetStack` which this panel is shown in.

The default behavior is to return ``False``.

.. versionadded:: 3.20
%End

bool dockMode();
@@ -36,6 +36,9 @@ Returns the temporal controller object used by this object in navigation.
The dock widget retains ownership of the returned object.
%End

virtual bool applySizeConstraintsToStack() const;



protected:

@@ -46,6 +46,11 @@ void QgsPanelWidget::setDockMode( bool dockMode )
mDockMode = dockMode;
}

bool QgsPanelWidget::applySizeConstraintsToStack() const
{
return false;
}

QgsPanelWidget *QgsPanelWidget::findParentPanel( QWidget *widget )
{
QWidget *p = widget;
@@ -74,6 +74,16 @@ class GUI_EXPORT QgsPanelWidget : public QWidget
*/
virtual void setDockMode( bool dockMode );

/**
* Returns TRUE if the size constraints and hints for the panel widget should be
* applied to the parent QgsPanelWidgetStack which this panel is shown in.
*
* The default behavior is to return FALSE.
*
* \since QGIS 3.20
*/
virtual bool applySizeConstraintsToStack() const;

/**
* Returns the dock mode state.
* \returns TRUE if in dock mode. If in dock mode the widget
@@ -92,15 +92,22 @@ QgsPanelWidget *QgsPanelWidgetStack::currentPanel()

QSize QgsPanelWidgetStack::sizeHint() const
{
if ( QWidget *widget = mStackedWidget->currentWidget() )
return widget->sizeHint();
if ( const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
{
if ( widget->applySizeConstraintsToStack() )
return widget->sizeHint();
}
return QWidget::sizeHint();
}

QSize QgsPanelWidgetStack::minimumSizeHint() const
{
if ( QWidget *widget = mStackedWidget->currentWidget() )
return widget->minimumSizeHint();
if ( const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
{
if ( widget->applySizeConstraintsToStack() )
return widget->minimumSizeHint();
}

return QWidget::minimumSizeHint();
}

@@ -176,6 +176,11 @@ QgsTemporalControllerWidget::QgsTemporalControllerWidget( QWidget *parent )
connect( QgsProject::instance(), &QgsProject::cleared, this, &QgsTemporalControllerWidget::onProjectCleared );
}

bool QgsTemporalControllerWidget::applySizeConstraintsToStack() const
{
return true;
}

void QgsTemporalControllerWidget::keyPressEvent( QKeyEvent *e )
{
if ( mSlider->hasFocus() && e->key() == Qt::Key_Space )
@@ -53,6 +53,8 @@ class GUI_EXPORT QgsTemporalControllerWidget : public QgsPanelWidget, private Ui
*/
QgsTemporalNavigationObject *temporalController();

bool applySizeConstraintsToStack() const override;

#ifndef SIP_RUN

signals:

0 comments on commit 8466988

Please sign in to comment.