Skip to content

Commit

Permalink
Allow source widgets to specify the group name for layer source
Browse files Browse the repository at this point in the history
properties

Allows overriding the default "Layer Source" group box title
  • Loading branch information
nyalldawson committed Dec 22, 2023
1 parent 1dacfbc commit 4c00af5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ Sets the source ``uri`` to show in the widget.
Returns the source URI as currently defined by the widget.

.. seealso:: :py:func:`setSourceUri`
%End

virtual QString groupTitle() const;
%Docstring
Returns an optional group title for the source settings, for use in layer properties dialogs.

If not specified, a default title will be used.

.. versionadded:: 3.36
%End

virtual void setMapCanvas( QgsMapCanvas *mapCanvas );
Expand Down
9 changes: 9 additions & 0 deletions python/gui/auto_generated/qgsprovidersourcewidget.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ Sets the source ``uri`` to show in the widget.
Returns the source URI as currently defined by the widget.

.. seealso:: :py:func:`setSourceUri`
%End

virtual QString groupTitle() const;
%Docstring
Returns an optional group title for the source settings, for use in layer properties dialogs.

If not specified, a default title will be used.

.. versionadded:: 3.36
%End

virtual void setMapCanvas( QgsMapCanvas *mapCanvas );
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsprovidersourcewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ class GUI_EXPORT QgsProviderSourceWidget : public QWidget
*/
virtual QString sourceUri() const = 0;

/**
* Returns an optional group title for the source settings, for use in layer properties dialogs.
*
* If not specified, a default title will be used.
*
* \since QGIS 3.36
*/
virtual QString groupTitle() const { return QString(); }

/**
* Sets a map \a canvas associated with the widget.
*
Expand Down
2 changes: 2 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ void QgsRasterLayerProperties::sync()
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( mSourceWidget );
mSourceGroupBox->setLayout( layout );
if ( !mSourceWidget->groupTitle().isEmpty() )
mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
mSourceGroupBox->show();

connect( mSourceWidget, &QgsProviderSourceWidget::validChanged, this, [ = ]( bool isValid )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/vector/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ void QgsVectorLayerProperties::syncToLayer()
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( mSourceWidget );
mSourceGroupBox->setLayout( layout );
if ( !mSourceWidget->groupTitle().isEmpty() )
mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );

mSourceGroupBox->show();

connect( mSourceWidget, &QgsProviderSourceWidget::validChanged, this, [ = ]( bool isValid )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/vectortile/qgsvectortilelayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ void QgsVectorTileLayerProperties::syncToLayer()
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( mSourceWidget );
mSourceGroupBox->setLayout( layout );
if ( !mSourceWidget->groupTitle().isEmpty() )
mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
mSourceGroupBox->show();

connect( mSourceWidget, &QgsProviderSourceWidget::validChanged, this, [ = ]( bool isValid )
Expand Down

0 comments on commit 4c00af5

Please sign in to comment.