summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_language.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@gmail.com>2016-08-10 12:48:19 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-08-27 10:55:40 -0700
commit048379cc2b56257be4a435bb707d8a18c9958371 (patch)
treefba230c48af955441dedad1c6c368b90f7f28ab2 /desktop-widgets/preferences/preferences_language.cpp
parentbc95138f96aeb990d3882cd3b8cad5a97fb4f84d (diff)
downloadsubsurface-048379cc2b56257be4a435bb707d8a18c9958371.tar.gz
Settings update: Fix "Language" settings
Save the language settings using the SettingsObjectWrapper. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/preferences/preferences_language.cpp')
-rw-r--r--desktop-widgets/preferences/preferences_language.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp
index a1af676fa..408b48b66 100644
--- a/desktop-widgets/preferences/preferences_language.cpp
+++ b/desktop-widgets/preferences/preferences_language.cpp
@@ -1,6 +1,7 @@
#include "preferences_language.h"
#include "ui_prefs_language.h"
#include "core/helpers.h"
+#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QApplication>
#include <QSettings>
@@ -44,26 +45,22 @@ void PreferencesLanguage::refreshSettings()
void PreferencesLanguage::syncSettings()
{
- QSettings s;
- s.beginGroup("Language");
- bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
+ auto lang = SettingsObjectWrapper::instance()->language_settings;
+ bool useSystemLang = prefs.locale.use_system_language;
+
QAbstractItemModel *m = ui->languageDropdown->model();
QString currentText = m->data(m->index(ui->languageDropdown->currentIndex(),0), Qt::UserRole).toString();
if (useSystemLang != ui->languageSystemDefault->isChecked() ||
- (!useSystemLang && s.value("UiLanguage").toString() != currentText)) {
+ (!useSystemLang && currentText != prefs.locale.language)) {
QMessageBox::warning(this, tr("Restart required"),
tr("To correctly load a new language you must restart Subsurface."));
}
- s.setValue("UiLanguage", currentText);
- s.setValue("UseSystemLanguage", ui->languageSystemDefault->isChecked());
- s.setValue("time_format_override", !ui->timeFormatSystemDefault->isChecked());
- s.setValue("date_format_override", !ui->dateFormatSystemDefault->isChecked());
- if (!ui->timeFormatSystemDefault->isChecked())
- s.setValue("time_format", ui->timeFormatEntry->text());
- if (!ui->dateFormatSystemDefault->isChecked()) {
- s.setValue("date_format", ui->dateFormatEntry->text());
- s.setValue("date_format_short", ui->shortDateFormatEntry->text());
- }
- s.endGroup();
+ lang->setLanguage(currentText);
+ lang->setUseSystemLanguage(ui->languageSystemDefault->isChecked());
+ lang->setTimeFormatOverride(!ui->timeFormatSystemDefault->isChecked());
+ lang->setDateFormatOverride(!ui->dateFormatSystemDefault->isChecked());
+ lang->setTimeFormat(ui->timeFormatEntry->text());
+ lang->setDateFormat(ui->dateFormatEntry->text());
+ lang->setDateFormatShort(ui->shortDateFormatEntry->text());
uiLanguage(NULL);
}