From 060e230040147728a8ce6287e06851a426021a82 Mon Sep 17 00:00:00 2001 From: con Date: Mon, 25 Oct 2010 18:02:27 +0200 Subject: [PATCH] Add a -settingspath command line option. Useful for testing. --- doc/qtcreator.qdoc | 6 +++++- src/app/main.cpp | 30 +++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 5df9f00feb8..1bf052446b1 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -8202,7 +8202,11 @@ \row \o -profile - \o Load profile plugin. + \o Output plugin start up and shut down profiling data. + + \row + \o -settingspath + \o Override the default path where user settings are stored. \row \o -color diff --git a/src/app/main.cpp b/src/app/main.cpp index e3205cbebf9..e17d76aa302 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -55,16 +55,17 @@ #include #endif -enum { OptionIndent = 4, DescriptionIndent = 24 }; +enum { OptionIndent = 4, DescriptionIndent = 34 }; static const char *appNameC = "Qt Creator"; static const char *corePluginNameC = "Core"; static const char *fixedOptionsC = " [OPTION]... [FILE]...\n" "Options:\n" -" -help Display this help\n" -" -version Display program version\n" -" -client Attempt to connect to already running instance\n"; +" -help Display this help\n" +" -version Display program version\n" +" -client Attempt to connect to already running instance\n" +" -settingspath Override the default path where user settings are stored.\n"; static const char *HELP_OPTION1 = "-h"; static const char *HELP_OPTION2 = "-help"; @@ -72,6 +73,7 @@ static const char *HELP_OPTION3 = "/h"; static const char *HELP_OPTION4 = "--help"; static const char *VERSION_OPTION = "-version"; static const char *CLIENT_OPTION = "-client"; +static const char *SETTINGS_OPTION = "-settingspath"; typedef QList PluginSpecSet; @@ -198,6 +200,25 @@ int main(int argc, char **argv) QTranslator qtTranslator; QString locale = QLocale::system().name(); + // Manually determine -settingspath command line option + // We can't use the regular way of the plugin manager, because that needs to parse pluginspecs + // but the settings path can influence which plugins are enabled + QString settingsPath; + QStringList arguments = app.arguments(); /* adapted arguments list is passed to plugin manager later */ + QMutableStringListIterator it(arguments); + while (it.hasNext()) { + const QString &arg = it.next(); + if (arg == QLatin1String(SETTINGS_OPTION)) { + it.remove(); + if (it.hasNext()) { + settingsPath = QDir::fromNativeSeparators(it.next()); + it.remove(); + } + } + } + if (!settingsPath.isEmpty()) + QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath); + // Must be done before any QSettings class is created QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QCoreApplication::applicationDirPath()+QLatin1String(SHARE_PATH)); @@ -240,7 +261,6 @@ int main(int argc, char **argv) const QStringList pluginPaths = getPluginPaths(); pluginManager.setPluginPaths(pluginPaths); - const QStringList arguments = app.arguments(); QMap foundAppOptions; if (arguments.size() > 1) { QMap appOptions;