summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-22 16:43:21 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-22 12:01:09 -0700
commiteb55ffde16f0f3c1df4c97c5229165acfda5637d (patch)
treeab19de3aaadbb1a8b14d80519eb3b894a1f384eb /core/qthelper.cpp
parent2dca7d0ce5ba4045732f3fcd6c8a1170b4ad902f (diff)
downloadsubsurface-eb55ffde16f0f3c1df4c97c5229165acfda5637d.tar.gz
cleanup: split uiLanguage() in two functions
The uiLanguage() function was used for two purposes: to initialize the language related preferences and to read the current language. To make things more easy to follow, split this function in two: one for initializing, one for getting the current language. Moreover, don't return the current locale in an out-parameter as there is already a function to do that [getLocale()]. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 85914767c..3321a3387 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -426,7 +426,7 @@ QString getUserAgent()
userAgent.append(arch);
if (arch == "i386")
userAgent.append("/" + SubsurfaceSysInfo::currentCpuArchitecture());
- userAgent.append(":" + uiLanguage(NULL));
+ userAgent.append(":" + getUiLanguage());
return userAgent;
}
@@ -438,21 +438,20 @@ extern "C" const char *subsurface_user_agent()
return copy_qstring(uA);
}
+QString getUiLanguage()
+{
+ return prefs.locale.lang_locale;
+}
+
/* TOOD: Move this to SettingsObjectWrapper, and also fix this complexity.
* gezus.
*/
-QString uiLanguage(QLocale *callerLoc)
+void initUiLanguage()
{
QString shortDateFormat;
QString dateFormat;
QString timeFormat;
- // Language settings are already loaded, see qPref::load()
- // so no need to reload them
-
- // remark this method used "useSystemLanguage", which is not set
- // instead use_system_language is loaded from disk
-
// set loc as system language or selected language
if (!qPrefLanguage::use_system_language()) {
loc = QLocale(qPrefLanguage::lang_locale());
@@ -483,8 +482,6 @@ QString uiLanguage(QLocale *callerLoc)
else if (languages.count() > 2 && languages[2].contains('-'))
uiLang = languages[2];
}
- if (callerLoc)
- *callerLoc = loc;
prefs.locale.lang_locale = copy_qstring(uiLang);
@@ -515,7 +512,6 @@ QString uiLanguage(QLocale *callerLoc)
free((void *)prefs.time_format);
prefs.time_format = copy_qstring(timeFormat);
}
- return uiLang;
}
QLocale getLocale()