Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make form combo box widgets shrinkable
When a form widget contains long values it takes by default the length
of the longest item.

This can result in very wide forms that cannot be shrinked.

With this PR the combo box can be shrinked and the form itself can be
also shrinked.
  • Loading branch information
elpaso committed Jan 24, 2023
1 parent 0523c66 commit 593c5c5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsclassificationwidgetwrapper.cpp
Expand Up @@ -36,7 +36,10 @@ void QgsClassificationWidgetWrapper::showIndeterminateState()

QWidget *QgsClassificationWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsClassificationWidgetWrapper::initWidget( QWidget *editor )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsenumerationwidgetwrapper.cpp
Expand Up @@ -45,7 +45,10 @@ void QgsEnumerationWidgetWrapper::showIndeterminateState()

QWidget *QgsEnumerationWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsEnumerationWidgetWrapper::initWidget( QWidget *editor )
Expand Down
7 changes: 6 additions & 1 deletion src/gui/editorwidgets/qgsuniquevaluewidgetwrapper.cpp
Expand Up @@ -51,7 +51,12 @@ QWidget *QgsUniqueValuesWidgetWrapper::createWidget( QWidget *parent )
if ( config( QStringLiteral( "Editable" ) ).toBool() )
return new QgsFilterLineEdit( parent );
else
return new QComboBox( parent );
{
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

void QgsUniqueValuesWidgetWrapper::initWidget( QWidget *editor )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.cpp
Expand Up @@ -32,7 +32,10 @@ QgsValueMapSearchWidgetWrapper::QgsValueMapSearchWidgetWrapper( QgsVectorLayer *

QWidget *QgsValueMapSearchWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
auto combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged( int idx )
Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Expand Up @@ -52,7 +52,10 @@ void QgsValueMapWidgetWrapper::showIndeterminateState()

QWidget *QgsValueMapWidgetWrapper::createWidget( QWidget *parent )
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}

void QgsValueMapWidgetWrapper::initWidget( QWidget *editor )
Expand Down
3 changes: 2 additions & 1 deletion src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h
Expand Up @@ -23,7 +23,6 @@

SIP_NO_FILE


/**
* \ingroup gui
* \brief Wraps a value map widget.
Expand Down Expand Up @@ -71,4 +70,6 @@ class GUI_EXPORT QgsValueMapWidgetWrapper : public QgsEditorWidgetWrapper

};



#endif // QGSVALUEMAPWIDGETWRAPPER_H
Expand Up @@ -202,7 +202,10 @@ QWidget *QgsValueRelationSearchWidgetWrapper::createWidget( QWidget *parent )
}
else
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -291,7 +291,10 @@ QWidget *QgsValueRelationWidgetWrapper::createWidget( QWidget *parent )
}
else
{
return new QComboBox( parent );
QComboBox *combo = new QComboBox( parent );
combo->setMinimumContentsLength( 1 );
combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
return combo;
}
}

Expand Down

0 comments on commit 593c5c5

Please sign in to comment.