diff options
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 7 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 3 | ||||
-rw-r--r-- | tests/testpreferences.cpp | 37 |
3 files changed, 45 insertions, 2 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 101e6650c..0e8c8ee67 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1908,6 +1908,11 @@ bool LanguageSettingsObjectWrapper::useSystemLanguage() const return prefs.locale.use_system_language; } +QString LanguageSettingsObjectWrapper::langLocale() const +{ + return prefs.locale.lang_locale; +} + void LanguageSettingsObjectWrapper::setUseSystemLanguage(bool value) { if (value == prefs.locale.use_system_language) @@ -1927,7 +1932,7 @@ void LanguageSettingsObjectWrapper::setLangLocale(const QString &value) s.beginGroup(group); s.setValue("UiLangLocale", value); prefs.locale.lang_locale = copy_string(qPrintable(value)); - // no need to emit languageChanged since we already do this for setLanguage + emit langLocaleChanged(value); } void LanguageSettingsObjectWrapper::setLanguage(const QString& value) diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index 64e6a5a8a..d9b8196d4 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -597,6 +597,7 @@ class LanguageSettingsObjectWrapper : public QObject { Q_PROPERTY(QString time_format READ timeFormat WRITE setTimeFormat NOTIFY timeFormatChanged) Q_PROPERTY(QString date_format READ dateFormat WRITE setDateFormat NOTIFY dateFormatChanged) Q_PROPERTY(QString date_format_short READ dateFormatShort WRITE setDateFormatShort NOTIFY dateFormatShortChanged) + Q_PROPERTY(QString lang_locale READ langLocale WRITE setLangLocale NOTIFY langLocaleChanged) Q_PROPERTY(bool time_format_override READ timeFormatOverride WRITE setTimeFormatOverride NOTIFY timeFormatOverrideChanged) Q_PROPERTY(bool date_format_override READ dateFormatOverride WRITE setDateFormatOverride NOTIFY dateFormatOverrideChanged) Q_PROPERTY(bool use_system_language READ useSystemLanguage WRITE setUseSystemLanguage NOTIFY useSystemLanguageChanged) @@ -604,6 +605,7 @@ class LanguageSettingsObjectWrapper : public QObject { public: LanguageSettingsObjectWrapper(QObject *parent); QString language() const; + QString langLocale() const; QString timeFormat() const; QString dateFormat() const; QString dateFormatShort() const; @@ -622,6 +624,7 @@ public slots: void setUseSystemLanguage (bool value); signals: void languageChanged(const QString& value); + void langLocaleChanged(const QString& value); void timeFormatChanged(const QString& value); void dateFormatChanged(const QString& value); void dateFormatShortChanged(const QString& value); diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index e8e3f0995..7ba25625a 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -502,7 +502,42 @@ void TestPreferences::testPreferences() TEST(display->fontSize(), 14.0); TEST(display->displayInvalidDives(),(short) false); - + auto language = pref->language_settings; + language->setLangLocale ("en_US"); + language->setLanguage ("en"); + language->setTimeFormat ("hh:mm"); + language->setDateFormat ("dd/mm/yy"); + language->setDateFormatShort ("dd/mm"); + language->setTimeFormatOverride (false); + language->setDateFormatOverride (false); + language->setUseSystemLanguage (false); + + TEST(language->langLocale(), QStringLiteral("en_US")); + TEST(language->language(), QStringLiteral("en")); + TEST(language->timeFormat(), QStringLiteral("hh:mm")); + TEST(language->dateFormat(), QStringLiteral("dd/mm/yy")); + TEST(language->dateFormatShort(), QStringLiteral("dd/mm")); + TEST(language->timeFormatOverride(), false); + TEST(language->dateFormatOverride(), false); + TEST(language->useSystemLanguage(), false); + + language->setLangLocale ("en_EN"); + language->setLanguage ("br"); + language->setTimeFormat ("mm:hh"); + language->setDateFormat ("yy/mm/dd"); + language->setDateFormatShort ("dd/yy"); + language->setTimeFormatOverride (true); + language->setDateFormatOverride (true); + language->setUseSystemLanguage (true); + + TEST(language->langLocale(), QStringLiteral("en_EN")); + TEST(language->language(), QStringLiteral("br")); + TEST(language->timeFormat(), QStringLiteral("mm:hh")); + TEST(language->dateFormat(), QStringLiteral("yy/mm/dd")); + TEST(language->dateFormatShort(), QStringLiteral("dd/yy")); + TEST(language->timeFormatOverride(),true); + TEST(language->dateFormatOverride(),true); + TEST(language->useSystemLanguage(), true); } QTEST_MAIN(TestPreferences) |