diff options
author | jan Iversen <jani@apache.org> | 2018-08-08 16:34:17 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-13 11:49:32 -0700 |
commit | 72d87364c018c61f2127b7293fff11b83e97b82c (patch) | |
tree | b2d2eff7326964fddbb4a8fc82798d616ef69d0e /core/subsurface-qt | |
parent | 63fa532b1520bb18eff98c10ff708834939d8e59 (diff) | |
download | subsurface-72d87364c018c61f2127b7293fff11b83e97b82c.tar.gz |
core: activate qPrefLanguage
remove Language from SettingsObjectWrapper and reference qPrefLanguage
update files using SettingsObjectWrapper/Language to use qPrefLanguage
this activated qPrefLanguage and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 155 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 49 |
2 files changed, 4 insertions, 200 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 84ffc5a26..1fb770c56 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -390,148 +390,6 @@ void GeneralSettingsObjectWrapper::setFfmpegExecutable(const QString &value) emit ffmpegExecutableChanged(value); } -LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) : - QObject(parent) -{ -} - -QString LanguageSettingsObjectWrapper::language() const -{ - return prefs.locale.language; -} - -QString LanguageSettingsObjectWrapper::timeFormat() const -{ - return prefs.time_format; -} - -QString LanguageSettingsObjectWrapper::dateFormat() const -{ - return prefs.date_format; -} - -QString LanguageSettingsObjectWrapper::dateFormatShort() const -{ - return prefs.date_format_short; -} - -bool LanguageSettingsObjectWrapper::timeFormatOverride() const -{ - return prefs.time_format_override; -} - -bool LanguageSettingsObjectWrapper::dateFormatOverride() const -{ - return prefs.date_format_override; -} - -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) - return; - QSettings s; - s.beginGroup(group); - s.setValue("UseSystemLanguage", value); - prefs.locale.use_system_language = value; - emit useSystemLanguageChanged(value); -} - -void LanguageSettingsObjectWrapper::setLangLocale(const QString &value) -{ - if (value == prefs.locale.lang_locale) - return; - QSettings s; - s.beginGroup(group); - s.setValue("UiLangLocale", value); - free((void *)prefs.locale.lang_locale); - prefs.locale.lang_locale = copy_qstring(value); - emit langLocaleChanged(value); -} - -void LanguageSettingsObjectWrapper::setLanguage(const QString& value) -{ - if (value == prefs.locale.language) - return; - QSettings s; - s.beginGroup(group); - s.setValue("UiLanguage", value); - free((void *)prefs.locale.language); - prefs.locale.language = copy_qstring(value); - emit languageChanged(value); -} - -void LanguageSettingsObjectWrapper::setTimeFormat(const QString& value) -{ - if (value == prefs.time_format) - return; - QSettings s; - s.beginGroup(group); - s.setValue("time_format", value); - free((void *)prefs.time_format); - prefs.time_format = copy_qstring(value); - emit timeFormatChanged(value); -} - -void LanguageSettingsObjectWrapper::setDateFormat(const QString& value) -{ - if (value == prefs.date_format) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("date_format", value); - free((void *)prefs.date_format); - prefs.date_format = copy_qstring(value); - emit dateFormatChanged(value); -} - -void LanguageSettingsObjectWrapper::setDateFormatShort(const QString& value) -{ - if (value == prefs.date_format_short) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("date_format_short", value); - free((void *)prefs.date_format_short); - prefs.date_format_short = copy_qstring(value); - emit dateFormatShortChanged(value); -} - -void LanguageSettingsObjectWrapper::setTimeFormatOverride(bool value) -{ - if (value == prefs.time_format_override) - return; - QSettings s; - s.beginGroup(group); - s.setValue("time_format_override", value); - prefs.time_format_override = value; - emit timeFormatOverrideChanged(value); -} - -void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value) -{ - if (value == prefs.date_format_override) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("date_format_override", value); - prefs.date_format_override = value; - emit dateFormatOverrideChanged(value); -} - - SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent): QObject(parent), techDetails(new qPrefTechnicalDetails(this)), @@ -544,7 +402,7 @@ QObject(parent), unit_settings(new qPrefUnits(this)), general_settings(new GeneralSettingsObjectWrapper(this)), display_settings(new qPrefDisplay(this)), - language_settings(new LanguageSettingsObjectWrapper(this)), + language_settings(new qPrefLanguage(this)), animation_settings(new qPrefAnimations(this)), location_settings(new qPrefLocationService(this)), update_manager_settings(new qPrefUpdateManager(this)), @@ -601,16 +459,7 @@ void SettingsObjectWrapper::load() qPrefDiveComputer::instance()->load(); qPrefUpdateManager::instance()->load(); - s.beginGroup("Language"); - GET_BOOL("UseSystemLanguage", locale.use_system_language); - GET_TXT("UiLanguage", locale.language); - GET_TXT("UiLangLocale", locale.lang_locale); - GET_TXT("time_format", time_format); - GET_TXT("date_format", date_format); - GET_TXT("date_format_short", date_format_short); - GET_BOOL("time_format_override", time_format_override); - GET_BOOL("date_format_override", date_format_override); - s.endGroup(); + qPrefLanguage::instance()->load(); } void SettingsObjectWrapper::sync() diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index 3af79404e..2fe2a7b5a 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -138,51 +138,6 @@ private: const QString group = QStringLiteral("GeneralSettings"); }; -class LanguageSettingsObjectWrapper : public QObject { - Q_OBJECT - Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) - 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) - -public: - LanguageSettingsObjectWrapper(QObject *parent); - QString language() const; - QString langLocale() const; - QString timeFormat() const; - QString dateFormat() const; - QString dateFormatShort() const; - bool timeFormatOverride() const; - bool dateFormatOverride() const; - bool useSystemLanguage() const; - -public slots: - void setLangLocale (const QString& value); - void setLanguage (const QString& value); - void setTimeFormat (const QString& value); - void setDateFormat (const QString& value); - void setDateFormatShort (const QString& value); - void setTimeFormatOverride (bool value); - void setDateFormatOverride (bool value); - 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); - void timeFormatOverrideChanged(bool value); - void dateFormatOverrideChanged(bool value); - void useSystemLanguageChanged(bool value); - -private: - const QString group = QStringLiteral("Language"); -}; - class SettingsObjectWrapper : public QObject { Q_OBJECT @@ -196,7 +151,7 @@ class SettingsObjectWrapper : public QObject { Q_PROPERTY(qPrefUnits* units MEMBER unit_settings CONSTANT) Q_PROPERTY(GeneralSettingsObjectWrapper* general MEMBER general_settings CONSTANT) Q_PROPERTY(qPrefDisplay* display MEMBER display_settings CONSTANT) - Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT) + Q_PROPERTY(qPrefLanguage* language MEMBER language_settings CONSTANT) Q_PROPERTY(qPrefAnimations* animation MEMBER animation_settings CONSTANT) Q_PROPERTY(qPrefLocationService* Location MEMBER location_settings CONSTANT) @@ -215,7 +170,7 @@ public: qPrefUnits *unit_settings; GeneralSettingsObjectWrapper *general_settings; qPrefDisplay *display_settings; - LanguageSettingsObjectWrapper *language_settings; + qPrefLanguage *language_settings; qPrefAnimations *animation_settings; qPrefLocationService *location_settings; qPrefUpdateManager *update_manager_settings; |