Skip to content

Commit

Permalink
Allow specifying default WMS image format in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro authored and nyalldawson committed Jun 21, 2021
1 parent bbf5d11 commit a8c1be6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions resources/qgis_global_settings.ini
Expand Up @@ -45,6 +45,9 @@ connections-xyz\OpenStreetMap\username=
connections-xyz\OpenStreetMap\zmax=19
connections-xyz\OpenStreetMap\zmin=0

# The image format selected by default when adding a WMS, i.e. image/png. If empty, the first available format is used
WMSDefaultFormat=""

# application stylesheet

# Padding (in pixels) to add to toolbar icons, if blank then default padding will be used
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -291,6 +291,8 @@ bool QgsWMSSourceSelect::populateLayerList( const QgsWmsCapabilities &capabiliti
const QVector<QgsWmsLayerProperty> layers = capabilities.supportedLayers();
mLayerProperties = layers;

QString defaultEncoding = QgsSettings().value( "qgis/WMSDefaultFormat", "" ).toString();

bool first = true;
QSet<QString> alreadyAddedLabels;
const auto supportedImageEncodings = capabilities.supportedImageEncodings();
Expand All @@ -311,7 +313,7 @@ bool QgsWMSSourceSelect::populateLayerList( const QgsWmsCapabilities &capabiliti
alreadyAddedLabels.insert( mFormats[id].label );

mImageFormatGroup->button( id )->setVisible( true );
if ( first )
if ( first || encoding == defaultEncoding )
{
mImageFormatGroup->button( id )->setChecked( true );
first = false;
Expand Down

0 comments on commit a8c1be6

Please sign in to comment.