Skip to content
Permalink
Browse files
Enable loading .qlr files as command line parameters
  • Loading branch information
uclaros authored and nyalldawson committed Oct 14, 2021
1 parent 8f37bba commit f401ec2c221f2711e8042e750c0560debb48e34e
Showing with 13 additions and 5 deletions.
  1. +13 −5 src/app/main.cpp
@@ -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" )
@@ -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 );
}

0 comments on commit f401ec2

Please sign in to comment.