From edc949a91bbaf11fd1375d7a9f84621421f2a8fb Mon Sep 17 00:00:00 2001 From: James Duley Date: Sun, 17 May 2015 00:14:14 +0100 Subject: [PATCH] OP-1879 remove openpilot hardcoding: reworked settings to use default app name --- ground/openpilotgcs/src/app/app.pro | 1 + ground/openpilotgcs/src/app/main.cpp | 14 ++++++++------ .../src/plugins/coreplugin/mainwindow.cpp | 12 +++--------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/app/app.pro b/ground/openpilotgcs/src/app/app.pro index 0de23d965..d8da9cc01 100644 --- a/ground/openpilotgcs/src/app/app.pro +++ b/ground/openpilotgcs/src/app/app.pro @@ -21,6 +21,7 @@ include(../libs/version_info/version_info.pri) LIBS *= -l$$qtLibraryName(ExtensionSystem) -l$$qtLibraryName(Aggregation) DEFINES += PLUGIN_REL_PATH=\\\"$$relative_path($$GCS_PLUGIN_PATH, $$GCS_APP_PATH)\\\" +DEFINES += GCS_NAME=\\\"$$GCS_APP_TARGET\\\" win32 { RC_FILE = openpilotgcs.rc diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index 1cb6207ce..02338ba9e 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -111,13 +111,11 @@ typedef QMap AppOptionValues; const int OptionIndent = 4; const int DescriptionIndent = 24; -const QLatin1String APP_NAME("OpenPilot GCS"); +const QLatin1String APP_NAME(GCS_NAME); +const QLatin1String ORG_NAME("OpenPilot"); const QLatin1String CORE_PLUGIN_NAME("Core"); -const QLatin1String SETTINGS_ORG_NAME("OpenPilot"); -const QLatin1String SETTINGS_APP_NAME("OpenPilotGCS_config"); - const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml"; const char *fixedOptionsC = " [OPTION]... [FILE]...\n" @@ -445,6 +443,10 @@ int main(int argc, char * *argv) // create application SharedTools::QtSingleApplication app(APP_NAME, argc, argv); + QCoreApplication::setApplicationName(APP_NAME); + QCoreApplication::setOrganizationName(ORG_NAME); + QSettings::setDefaultFormat(XmlConfig::XmlSettingsFormat); + // initialize the plugin manager ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QLatin1String("pluginspec")); @@ -473,8 +475,8 @@ int main(int argc, char * *argv) 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; - QSettings settings(XmlConfig::XmlSettingsFormat, QSettings::UserScope, SETTINGS_ORG_NAME, SETTINGS_APP_NAME); + QSettings settings; + qDebug() << "Loading user settings from" << settings.fileName(); // need to reset all user settings? if (appOptionValues.contains(RESET_OPTION)) { diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 3710fadaf..599cb4f6c 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -102,12 +102,11 @@ MainWindow::MainWindow() : m_globalContext(QList() << Constants::C_GLOBAL_ID), m_additionalContexts(m_globalContext), // keep this in sync with main() in app/main.cpp - m_settings(new QSettings(XmlConfig::XmlSettingsFormat, QSettings::UserScope, - QLatin1String("OpenPilot"), QLatin1String("OpenPilotGCS_config"), this)), + m_settings(new QSettings(this)), m_globalSettings(new QSettings(XmlConfig::XmlSettingsFormat, QSettings::SystemScope, - QLatin1String("OpenPilot"), QLatin1String("OpenPilotGCS_config"), this)), + m_settings->organizationName(), m_settings->applicationName(), this)), m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(), - QLatin1String("OpenPilotGCS_config"), + QFileInfo(m_settings->fileName()).baseName(), this)), m_dontSaveSettings(false), m_actionManager(new ActionManagerPrivate(this)), @@ -138,11 +137,6 @@ MainWindow::MainWindow() : #ifndef Q_WS_MAC qApp->setWindowIcon(QIcon(":/core/images/openpilot_logo_128.png")); #endif - QCoreApplication::setApplicationName(QLatin1String("OpenPilotGCS")); - QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::GCS_VERSION_LONG)); - QCoreApplication::setOrganizationName(QLatin1String("OpenPilot")); - QCoreApplication::setOrganizationDomain(QLatin1String("openpilot.org")); - QSettings::setDefaultFormat(XmlConfig::XmlSettingsFormat); qApp->setStyle(QStyleFactory::create("Fusion")); setDockNestingEnabled(true);