1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

GCS-Created new command line option to allow choosing the config file

to use. This is a last resort option to mac problems displaying the
initial dialog.
This commit is contained in:
PT_Dreamer 2012-08-21 14:41:53 +01:00
parent f9f3d6d98c
commit e7a7a30e19
2 changed files with 41 additions and 15 deletions

View File

@ -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";

View File

@ -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()<<commandLine;
}
}
QDir directory(QCoreApplication::applicationDirPath());
#ifdef Q_OS_MAC
directory.cdUp();
directory.cd("Resources");
directory.cdUp();
directory.cd("Resources");
#else
directory.cdUp();
directory.cd("share");
directory.cd("openpilotgcs");
directory.cdUp();
directory.cd("share");
directory.cd("openpilotgcs");
#endif
directory.cd("default_configurations");
directory.cd("default_configurations");
qDebug() << "Looking for default config files in: " + directory.absolutePath();
dialog->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 "<<dialog->choosenConfig();
delete dialog;
qDebug() << "Load default config from resource "<<filename;
}
qs->beginGroup("General");
loadStyleSheet(qs->value("StyleSheet","none").toString());