Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enable loading .qlr files as command line parameters
  • Loading branch information
uclaros authored and nyalldawson committed Oct 14, 2021
1 parent 8f37bba commit f401ec2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/app/main.cpp
Expand Up @@ -172,8 +172,8 @@ void usage( const QString &appName )
<< QStringLiteral( "\t[--help]\t\tthis text\n" )
<< QStringLiteral( "\t[--]\t\ttreat all following arguments as FILEs\n\n" )
<< QStringLiteral( " FILE:\n" )
<< QStringLiteral( " Files specified on the command line can include rasters,\n" )
<< QStringLiteral( " vectors, and QGIS project files (.qgs and .qgz): \n" )
<< QStringLiteral( " Files specified on the command line can include rasters, vectors,\n" )
<< QStringLiteral( " QGIS layer definition files (.qlr) and QGIS project files (.qgs and .qgz): \n" )
<< QStringLiteral( " 1. Rasters - supported formats include GeoTiff, DEM \n" )
<< QStringLiteral( " and others supported by GDAL\n" )
<< QStringLiteral( " 2. Vectors - supported formats include ESRI Shapefiles\n" )
Expand Down Expand Up @@ -1403,9 +1403,17 @@ int main( int argc, char *argv[] )
{
QgsDebugMsg( QStringLiteral( "Trying to load file : %1" ).arg( layerName ) );
// don't load anything with a .qgs extension - these are project files
if ( !layerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) &&
!layerName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) &&
!QgsZipUtils::isZipFile( layerName ) )
if ( layerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) ||
layerName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ||
QgsZipUtils::isZipFile( layerName ) )
{
continue;
}
else if ( layerName.endsWith( QLatin1String( ".qlr" ), Qt::CaseInsensitive ) )
{
qgis->openLayerDefinition( layerName );
}
else
{
qgis->openLayer( layerName );
}
Expand Down

0 comments on commit f401ec2

Please sign in to comment.