diff options
author | Tomaz Canabrava <tomaz.canabrava@gmail.com> | 2016-08-27 22:13:33 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-08-27 22:37:15 -0700 |
commit | 0a6f6b4382a35402cdfd792487a82c4e83b3a3b0 (patch) | |
tree | 21519e278df6586976900e10f37bb060a1d6f1f2 | |
parent | 270864d073359f783fbb9cbe17c583d6b88cb8ae (diff) | |
download | subsurface-0a6f6b4382a35402cdfd792487a82c4e83b3a3b0.tar.gz |
Settings update: Fix missing groups and Language initialization
There's one function named uiLanguage() that should return
the current uiLanguage() that subsurface is running, but
it actually sets a whole lot of preferences, I think
that the general idea of that function is okay, but it seems
broken for me.
still, I used it to load the correct language from the preferences
since it's what this function is currently doing right now.
Also, a lot of missing groups where added.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/qthelper.cpp | 4 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 14 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_language.cpp | 7 |
3 files changed, 21 insertions, 4 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp index a986a68c6..f34547882 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -481,6 +481,9 @@ extern "C" const char *subsurface_user_agent() return strdup(qPrintable(uA)); } +/* TOOD: Move this to SettingsObjectWrapper, and also fix this complexity. + * gezus. + */ QString uiLanguage(QLocale *callerLoc) { QString shortDateFormat; @@ -489,6 +492,7 @@ QString uiLanguage(QLocale *callerLoc) QSettings s; QVariant v; s.beginGroup("Language"); + GET_BOOL("UseSystemLanguage", locale.use_system_language); if (!s.value("UseSystemLanguage", true).toBool()) { loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString()); diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index f3b156a27..64d4e27a6 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1618,6 +1618,7 @@ void UnitsSettings::setCoordinatesTraditional(bool value) if (value == prefs.coordinates_traditional) return; QSettings s; + s.beginGroup(group); s.setValue("coordinates", value); prefs.coordinates_traditional = value; emit coordinatesTraditionalChanged(value); @@ -1633,6 +1634,7 @@ void UnitsSettings::setUnitSystem(const QString& value) return; QSettings s; + s.setValue("unit_system", value); if (value == QStringLiteral("metric")) { @@ -1893,6 +1895,7 @@ 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 = copy_string(qPrintable(value)); emit useSystemLanguageChanged(value); @@ -1903,6 +1906,7 @@ void LanguageSettingsObjectWrapper::setLanguage(const QString& value) if (value == prefs.locale.language) return; QSettings s; + s.beginGroup(group); s.setValue("UiLanguage", value); prefs.locale.language = copy_string(qPrintable(value)); emit languageChanged(value); @@ -1913,6 +1917,7 @@ void LanguageSettingsObjectWrapper::setTimeFormat(const QString& value) if (value == prefs.time_format) return; QSettings s; + s.beginGroup(group); s.setValue("time_format", value); prefs.time_format = copy_string(qPrintable(value));; emit timeFormatChanged(value); @@ -1924,6 +1929,7 @@ void LanguageSettingsObjectWrapper::setDateFormat(const QString& value) return; QSettings s; + s.beginGroup(group); s.setValue("date_format", value); prefs.date_format = copy_string(qPrintable(value));; emit dateFormatChanged(value); @@ -1935,6 +1941,7 @@ void LanguageSettingsObjectWrapper::setDateFormatShort(const QString& value) return; QSettings s; + s.beginGroup(group); s.setValue("date_format_short", value); prefs.date_format_short = copy_string(qPrintable(value));; emit dateFormatShortChanged(value); @@ -1945,6 +1952,7 @@ 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); @@ -1956,6 +1964,7 @@ void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value) return; QSettings s; + s.beginGroup(group); s.setValue("date_format_override", value); prefs.date_format_override = value; emit dateFormatOverrideChanged(value); @@ -1979,6 +1988,7 @@ void AnimationsSettingsObjectWrapper::setAnimationSpeed(int value) return; QSettings s; + s.beginGroup(group); s.setValue("animation_speed", value); prefs.animation_speed = value; emit animationSpeedChanged(value); @@ -2005,6 +2015,7 @@ void LocationServiceSettingsObjectWrapper::setDistanceThreshold(int value) if (value == prefs.distance_threshold) return; QSettings s; + s.beginGroup(group); s.setValue("distance_threshold", value); prefs.distance_threshold = value; emit distanceThresholdChanged(value); @@ -2016,9 +2027,10 @@ void LocationServiceSettingsObjectWrapper::setTimeThreshold(int value) return; QSettings s; + s.beginGroup(group); s.setValue("time_threshold", value); prefs.time_threshold = value; - emit timeThresholdChanged( value); + emit timeThresholdChanged(value); } SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent): diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 75297a8ff..64e937aef 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -42,18 +42,19 @@ void PreferencesLanguage::refreshSettings() ui->languageDropdown->setCurrentIndex(languages.first().row()); } +#include <QDebug> void PreferencesLanguage::syncSettings() { - auto lang = SettingsObjectWrapper::instance()->language_settings; bool useSystemLang = prefs.locale.use_system_language; + QString currentText = ui->languageDropdown->currentText(); - QAbstractItemModel *m = ui->languageDropdown->model(); - QString currentText = m->data(m->index(ui->languageDropdown->currentIndex(),0), Qt::UserRole).toString(); if (useSystemLang != ui->languageSystemDefault->isChecked() || (!useSystemLang && currentText != prefs.locale.language)) { QMessageBox::warning(this, tr("Restart required"), tr("To correctly load a new language you must restart Subsurface.")); } + + auto lang = SettingsObjectWrapper::instance()->language_settings; lang->setLanguage(currentText); lang->setUseSystemLanguage(ui->languageSystemDefault->isChecked()); lang->setTimeFormatOverride(!ui->timeFormatSystemDefault->isChecked()); |