Skip to content

Commit

Permalink
[FEATURE] Add CLI option for customization file
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Nov 23, 2012
1 parent d582f85 commit e5dae02
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/app/main.cpp
Expand Up @@ -105,6 +105,7 @@ void usage( std::string const & appName )
<< "\t[--nologo]\thide splash screen\n"
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
<< "\t[--nocustomization]\tdon't apply GUI customization\n"
<< "\t[--customizationfile]\tuse the given ini file as GUI customization\n"
<< "\t[--optionspath path]\tuse the given QSettings path\n"
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
<< "\t[--code path]\tRun the given python file on load. \n"
Expand Down Expand Up @@ -270,6 +271,8 @@ int main( int argc, char *argv[] )

QString pythonfile;

QString customizationfile;

#if defined(ANDROID)
QgsDebugMsg( QString( "Android: All params stripped" ) );// Param %1" ).arg( argv[0] ) );
//put all QGIS settings in the same place
Expand Down Expand Up @@ -333,6 +336,10 @@ int main( int argc, char *argv[] )
{
pythonfile = argv[++i];
}
else if ( i + 1 < argc && ( arg == "--customizationfile" || arg == "-z" ) )
{
customizationfile = argv[++i];
}
else
{
myFileList.append( QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[i] ) ).absoluteFilePath() ) );
Expand Down Expand Up @@ -366,6 +373,7 @@ int main( int argc, char *argv[] )
{"extent", required_argument, 0, 'e'},
{"optionspath", required_argument, 0, 'o'},
{"configpath", required_argument, 0, 'c'},
{"customizationfile", required_argument, 0, 'z'},
{"code", required_argument, 0, 'f'},
{"android", required_argument, 0, 'a'},
{0, 0, 0, 0}
Expand Down Expand Up @@ -441,6 +449,10 @@ int main( int argc, char *argv[] )
pythonfile = optarg;
break;

case 'z':
customizationfile = optarg;
break;

case '?':
usage( argv[0] );
return 2; // XXX need standard exit codes
Expand Down Expand Up @@ -531,6 +543,12 @@ int main( int argc, char *argv[] )
customizationsettings = new QSettings( "QuantumGIS", "QGISCUSTOMIZATION" );
}

// Using the customizationfile option always overrides the option and config path options.
if ( !customizationfile.isEmpty() )
{
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat);
}

// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
QgsCustomization::instance()->setSettings( customizationsettings );
QgsCustomization::instance()->loadDefault();
Expand Down

0 comments on commit e5dae02

Please sign in to comment.