Skip to content

Commit e5dae02

Browse files
committed
[FEATURE] Add CLI option for customization file
1 parent d582f85 commit e5dae02

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/app/main.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void usage( std::string const & appName )
105105
<< "\t[--nologo]\thide splash screen\n"
106106
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
107107
<< "\t[--nocustomization]\tdon't apply GUI customization\n"
108+
<< "\t[--customizationfile]\tuse the given ini file as GUI customization\n"
108109
<< "\t[--optionspath path]\tuse the given QSettings path\n"
109110
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
110111
<< "\t[--code path]\tRun the given python file on load. \n"
@@ -270,6 +271,8 @@ int main( int argc, char *argv[] )
270271

271272
QString pythonfile;
272273

274+
QString customizationfile;
275+
273276
#if defined(ANDROID)
274277
QgsDebugMsg( QString( "Android: All params stripped" ) );// Param %1" ).arg( argv[0] ) );
275278
//put all QGIS settings in the same place
@@ -333,6 +336,10 @@ int main( int argc, char *argv[] )
333336
{
334337
pythonfile = argv[++i];
335338
}
339+
else if ( i + 1 < argc && ( arg == "--customizationfile" || arg == "-z" ) )
340+
{
341+
customizationfile = argv[++i];
342+
}
336343
else
337344
{
338345
myFileList.append( QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[i] ) ).absoluteFilePath() ) );
@@ -366,6 +373,7 @@ int main( int argc, char *argv[] )
366373
{"extent", required_argument, 0, 'e'},
367374
{"optionspath", required_argument, 0, 'o'},
368375
{"configpath", required_argument, 0, 'c'},
376+
{"customizationfile", required_argument, 0, 'z'},
369377
{"code", required_argument, 0, 'f'},
370378
{"android", required_argument, 0, 'a'},
371379
{0, 0, 0, 0}
@@ -441,6 +449,10 @@ int main( int argc, char *argv[] )
441449
pythonfile = optarg;
442450
break;
443451

452+
case 'z':
453+
customizationfile = optarg;
454+
break;
455+
444456
case '?':
445457
usage( argv[0] );
446458
return 2; // XXX need standard exit codes
@@ -531,6 +543,12 @@ int main( int argc, char *argv[] )
531543
customizationsettings = new QSettings( "QuantumGIS", "QGISCUSTOMIZATION" );
532544
}
533545

546+
// Using the customizationfile option always overrides the option and config path options.
547+
if ( !customizationfile.isEmpty() )
548+
{
549+
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat);
550+
}
551+
534552
// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
535553
QgsCustomization::instance()->setSettings( customizationsettings );
536554
QgsCustomization::instance()->loadDefault();

0 commit comments

Comments
 (0)