aboutsummaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2022-11-07 09:24:32 +0100
committerEike Ziller <eike.ziller@qt.io>2022-11-07 14:50:36 +0000
commita1851c7cf1576a2656c251b193eb692b6caf480d (patch)
treeb9675ae03a624b15bb197c2993f265c9374d020e /src/app
parentfb5093d1407853b1e06ca132fb4998eb2862bb2a (diff)
Add -language command line option for overriding UI language
I run Qt Creator in german, but for responding to questions and generally looking things up I regularly want to run it temporarily in english. A command line option makes that easier than having to start Qt Creator, navigate to the settings, and restarting it, and doing the same again to revert back to german. Change-Id: I7c0d84375ffc97e5c7607307fd3f785f2c315c3d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/main.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 48cdc283cf..e197f17393 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -67,18 +67,20 @@ using namespace ExtensionSystem;
enum { OptionIndent = 4, DescriptionIndent = 34 };
const char corePluginNameC[] = "Core";
-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 first instance\n"
-" -settingspath <path> Override the default path where user settings are stored\n"
-" -installsettingspath <path> Override the default path from where user-independent settings are read\n"
-" -temporarycleansettings, -tcs Use clean settings for debug or testing reasons\n"
-" -pid <pid> Attempt to connect to instance given by pid\n"
-" -block Block until editor is closed\n"
-" -pluginpath <path> Add a custom search path for plugins\n";
+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 first instance\n"
+ " -settingspath <path> Override the default path where user settings are stored\n"
+ " -installsettingspath <path> Override the default path from where user-independent "
+ "settings are read\n"
+ " -temporarycleansettings, -tcs Use clean settings for debug or testing reasons\n"
+ " -pid <pid> Attempt to connect to instance given by pid\n"
+ " -block Block until editor is closed\n"
+ " -pluginpath <path> Add a custom search path for plugins\n"
+ " -language <locale> Set the UI language\n";
const char HELP_OPTION1[] = "-h";
const char HELP_OPTION2[] = "-help";
@@ -95,6 +97,7 @@ const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs";
const char PID_OPTION[] = "-pid";
const char BLOCK_OPTION[] = "-block";
const char PLUGINPATH_OPTION[] = "-pluginpath";
+const char LANGUAGE_OPTION[] = "-language";
const char USER_LIBRARY_PATH_OPTION[] = "-user-library-path"; // hidden option for qtcreator.sh
using PluginSpecSet = QVector<PluginSpec *>;
@@ -305,6 +308,7 @@ struct Options
QString settingsPath;
QString installSettingsPath;
QStringList customPluginPaths;
+ QString uiLanguage;
// list of arguments that were handled and not passed to the application or plugin manager
QStringList preAppArguments;
// list of arguments to be passed to the application or plugin manager
@@ -336,6 +340,10 @@ Options parseCommandLine(int argc, char *argv[])
++it;
options.customPluginPaths += QDir::fromNativeSeparators(nextArg);
options.preAppArguments << arg << nextArg;
+ } else if (arg == LANGUAGE_OPTION && hasNext) {
+ ++it;
+ options.uiLanguage = nextArg;
+ options.preAppArguments << arg << nextArg;
} else if (arg == USER_LIBRARY_PATH_OPTION && hasNext) {
++it;
options.userLibraryPath = nextArg;
@@ -597,6 +605,8 @@ int main(int argc, char **argv)
QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString();
if (!overrideLanguage.isEmpty())
uiLanguages.prepend(overrideLanguage);
+ if (!options.uiLanguage.isEmpty())
+ uiLanguages.prepend(options.uiLanguage);
const QString &creatorTrPath = resourcePath() + "/translations";
for (QString locale : std::as_const(uiLanguages)) {
locale = QLocale(locale).name();