summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-12-06 14:29:38 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-06 09:49:05 -0800
commit4e263bae987bcc343497496bcdc962c292977b6a (patch)
tree9cf584fe5c83493356e64a0b17faae4bbb31ad55 /qt-ui/preferences.cpp
parentbfe5ccda1ca50221828255e8f017a5f0180a020a (diff)
downloadsubsurface-4e263bae987bcc343497496bcdc962c292977b6a.tar.gz
Added a language preference to the Settings.
When the user first opens the application the default language is selected; this can be changed to a hardcoded one by going to system preferences and choosing the one you want. Restart required. Fixes #136 [Dirk Hohndel: whitespace fixes, removed qDebug() call, rephrased the message displayed prompting the user to restart.] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index f8b24da42..2155a710d 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -3,11 +3,13 @@
#include <QSettings>
#include <QDebug>
#include <QFileDialog>
+#include <QMessageBox>
PreferencesDialog* PreferencesDialog::instance()
{
static PreferencesDialog *dialog = new PreferencesDialog(mainWindow());
dialog->setAttribute(Qt::WA_QuitOnClose, false);
+ LanguageModel::instance();
return dialog;
}
@@ -107,6 +109,15 @@ void PreferencesDialog::setUiFromPrefs()
ui.show_sac->setChecked(prefs.show_sac);
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
+
+ ui.languageView->setModel( LanguageModel::instance() );
+
+ QSettings s;
+ s.beginGroup("Language");
+ QAbstractItemModel *m = ui.languageView->model();
+ QModelIndexList languages = m->match( m->index(0,0), Qt::DisplayRole, s.value("UiLanguage").toString());
+ if (languages.count())
+ ui.languageView->setCurrentIndex(languages.first());
}
void PreferencesDialog::restorePrefs()
@@ -174,6 +185,14 @@ void PreferencesDialog::syncSettings()
s.endGroup();
s.sync();
+ QLocale loc;
+ s.beginGroup("Language");
+ if (s.value("UiLanguage").toString() != ui.languageView->currentIndex().data(Qt::UserRole)){
+ QMessageBox::warning(mainWindow(), tr("Restart required"),
+ tr("To correctly load a new language you must restart Subsurface."));
+ }
+ s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
+
emit settingsChanged();
}