1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1879 remove openpilot hardcoding: use Utils::PathUtils.GetDataPath() instead of hardcoding in main.cpp

This commit is contained in:
James Duley 2015-05-09 19:49:21 +12:00 committed by LibrePilot Packager
parent fc791e87dc
commit 64dc5717f1

View File

@ -79,6 +79,7 @@
#include "qtsingleapplication.h"
#include "utils/xmlconfig.h"
#include "utils/pathutils.h"
#include "gcssplashscreen.h"
#include <extensionsystem/pluginmanager.h>
@ -117,12 +118,6 @@ const QLatin1String CORE_PLUGIN_NAME("Core");
const QLatin1String SETTINGS_ORG_NAME("OpenPilot");
const QLatin1String SETTINGS_APP_NAME("OpenPilotGCS_config");
#ifdef Q_OS_MAC
const QLatin1String SHARE_PATH("/../Resources");
#else
const QLatin1String SHARE_PATH("/../share/openpilotgcs");
#endif
const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
const char *fixedOptionsC = " [OPTION]... [FILE]...\n"
@ -349,7 +344,7 @@ AppOptionValues parseCommandLine(SharedTools::QtSingleApplication &app,
void loadFactoryDefaults(QSettings &settings, AppOptionValues &appOptionValues)
{
QDir directory(QCoreApplication::applicationDirPath() + SHARE_PATH + QString("/default_configurations"));
QDir directory(Utils::PathUtils().GetDataPath() + QString("default_configurations"));
qDebug() << "Looking for factory defaults configuration files in:" << directory.absolutePath();
@ -421,8 +416,7 @@ void overrideSettings(QSettings &settings, int argc, char * *argv)
void loadTranslators(QString language, QTranslator &translator, QTranslator &qtTranslator)
{
const QString &creatorTrPath = QCoreApplication::applicationDirPath() + SHARE_PATH
+ QLatin1String("/translations");
const QString &creatorTrPath = Utils::PathUtils().GetDataPath() + QLatin1String("translations");
if (translator.load(QLatin1String("openpilotgcs_") + language, creatorTrPath)) {
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
@ -476,7 +470,7 @@ int main(int argc, char * *argv)
// load user settings
// Must be done before any QSettings class is created
// keep this in sync with the MainWindow ctor in coreplugin/mainwindow.cpp
QString settingsPath = QCoreApplication::applicationDirPath() + SHARE_PATH;
QString settingsPath = Utils::PathUtils().GetDataPath();
qDebug() << "Loading system settings from" << settingsPath;
QSettings::setPath(XmlConfig::XmlSettingsFormat, QSettings::SystemScope, settingsPath);
qDebug() << "Loading user settings from" << SETTINGS_ORG_NAME << "/" << SETTINGS_APP_NAME;