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>
This commit is contained in:
Tomaz Canabrava 2016-08-27 22:13:33 -03:00 committed by Dirk Hohndel
parent 270864d073
commit 0a6f6b4382
3 changed files with 21 additions and 4 deletions

View file

@ -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());