summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_language.cpp
diff options
context:
space:
mode:
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);
}