mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-13 02:16:59 +02:00
look for a config.json file by default in resources
This commit is contained in:
parent
6febca3533
commit
9fc545001c
1 changed files with 26 additions and 19 deletions
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QJsonDocument>
|
#include <QtCore/QJsonDocument>
|
||||||
|
@ -68,29 +69,35 @@ QVariantMap HifiConfigVariantMap::mergeCLParametersWithJSONConfig(const QStringL
|
||||||
|
|
||||||
int configIndex = argumentList.indexOf(CONFIG_FILE_OPTION);
|
int configIndex = argumentList.indexOf(CONFIG_FILE_OPTION);
|
||||||
|
|
||||||
|
QString configFilePath;
|
||||||
|
|
||||||
if (configIndex != -1) {
|
if (configIndex != -1) {
|
||||||
// we have a config file - try and read it
|
// we have a config file - try and read it
|
||||||
QString configFilePath = argumentList[configIndex + 1];
|
configFilePath = argumentList[configIndex + 1];
|
||||||
QFile configFile(configFilePath);
|
} else {
|
||||||
|
// no config file - try to read a file at resources/config.json
|
||||||
if (configFile.exists()) {
|
configFilePath = QCoreApplication::applicationDirPath() + "/resources/config.json";
|
||||||
qDebug() << "Reading JSON config file at" << configFilePath;
|
}
|
||||||
configFile.open(QIODevice::ReadOnly);
|
|
||||||
|
QFile configFile(configFilePath);
|
||||||
QJsonDocument configDocument = QJsonDocument::fromJson(configFile.readAll());
|
|
||||||
QJsonObject rootObject = configDocument.object();
|
if (configFile.exists()) {
|
||||||
|
qDebug() << "Reading JSON config file at" << configFilePath;
|
||||||
// enumerate the keys of the configDocument object
|
configFile.open(QIODevice::ReadOnly);
|
||||||
foreach(const QString& key, rootObject.keys()) {
|
|
||||||
|
QJsonDocument configDocument = QJsonDocument::fromJson(configFile.readAll());
|
||||||
if (!mergedMap.contains(key)) {
|
QJsonObject rootObject = configDocument.object();
|
||||||
// no match in existing list, add it
|
|
||||||
mergedMap.insert(key, QVariant(rootObject[key]));
|
// enumerate the keys of the configDocument object
|
||||||
}
|
foreach(const QString& key, rootObject.keys()) {
|
||||||
|
|
||||||
|
if (!mergedMap.contains(key)) {
|
||||||
|
// no match in existing list, add it
|
||||||
|
mergedMap.insert(key, QVariant(rootObject[key]));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
qDebug() << "Could not find JSON config file at" << configFilePath;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Could not find JSON config file at" << configFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergedMap;
|
return mergedMap;
|
||||||
|
|
Loading…
Reference in a new issue