diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index c3de16c74..f276f60a2 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -59,8 +59,8 @@ static const char *fixedOptionsC = " -client Attempt to connect to already running instance\n" " -clean-config Delete all existing configuration settings\n" " -exit-after-config Exit GCS after manipulating configuration settings\n" -" -D key=value Override configuration settings e.g: -D General/OverrideLanguage=de\n"; - +" -D key=value Override configuration settings e.g: -D General/OverrideLanguage=de\n" +" -config=value Default configuration file to load if settings file is empty\n"; static const char *HELP_OPTION1 = "-h"; static const char *HELP_OPTION2 = "-help"; static const char *HELP_OPTION3 = "/h"; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 7f2cf4e44..bc7d79dab 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -269,26 +269,52 @@ void MainWindow::extensionsInitialized() QSettings* qs = m_settings; QSettings * settings; + QString commandLine; if ( ! qs->allKeys().count() ){ - importSettings * dialog=new importSettings(this); + foreach(QString str,qApp->arguments()) + { + if(str.contains("config")) + { + qDebug()<<"ass"; + commandLine=str.split("=").at(1); + qDebug()<loadFiles(directory.absolutePath()); - dialog->exec(); - settings=new QSettings(dialog->choosenConfig(), XmlConfig::XmlSettingsFormat); + qDebug() << "Looking for default config files in: " + directory.absolutePath(); + bool showDialog=true; + QString filename; + if(!commandLine.isEmpty()) + { + if(QFile::exists(directory.absolutePath()+QDir::separator()+commandLine)) + { + filename=directory.absolutePath()+QDir::separator()+commandLine; + qDebug()<<"Load configuration from command line"; + settings=new QSettings(filename, XmlConfig::XmlSettingsFormat); + showDialog=false; + } + } + if(showDialog) + { + importSettings * dialog=new importSettings(this); + dialog->loadFiles(directory.absolutePath()); + dialog->exec(); + filename=dialog->choosenConfig(); + settings=new QSettings(filename, XmlConfig::XmlSettingsFormat); + delete dialog; + } qs=settings; - qDebug() << "Load default config from resource "<choosenConfig(); - delete dialog; + qDebug() << "Load default config from resource "<beginGroup("General"); loadStyleSheet(qs->value("StyleSheet","none").toString());