aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_language.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-17 15:58:26 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:49 -0700
commit255325e219f7d1922ac7740649fdbc89228a36c1 (patch)
treee395810c5e4b484a8e828ada625d5b0531e25282 /desktop-widgets/preferences/preferences_language.cpp
parentb35ccc3a3533a3fcf9c7434584470537b6d0001e (diff)
downloadsubsurface-255325e219f7d1922ac7740649fdbc89228a36c1.tar.gz
Preferences: add a new page for language
This is not hooked into anything - It's the bare minimum that I need to continue creating the new preferences dialog. But take a look at it... very simple. :) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.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.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp
new file mode 100644
index 000000000..7254482e2
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_language.cpp
@@ -0,0 +1,47 @@
+#include "preferences_language.h"
+#include "ui_prefs_language.h"
+
+#include <QApplication>
+#include <QSettings>
+#include <QMessageBox>
+
+
+PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":/language"), 4)
+{
+ ui = new Ui::PreferencesLanguage();
+ ui->setupUi(this);
+}
+
+PreferencesLanguage::~PreferencesLanguage()
+{
+ delete ui;
+}
+
+void PreferencesLanguage::refreshSettings()
+{
+ QSettings s;
+ s.beginGroup("Language");
+ ui->languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
+ QAbstractItemModel *m = ui->languageView->model();
+ QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
+ if (languages.count())
+ ui->languageView->setCurrentIndex(languages.first());
+ s.endGroup();
+}
+
+void PreferencesLanguage::syncSettings()
+{
+ // Locale
+ QLocale loc;
+ QSettings s;
+ s.beginGroup("Language");
+ bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
+ if (useSystemLang != ui->languageSystemDefault->isChecked() ||
+ (!useSystemLang && s.value("UiLanguage").toString() != ui->languageView->currentIndex().data(Qt::UserRole))) {
+ QMessageBox::warning(this, tr("Restart required"),
+ tr("To correctly load a new language you must restart Subsurface."));
+ }
+ s.setValue("UseSystemLanguage", ui->languageSystemDefault->isChecked());
+ s.setValue("UiLanguage", ui->languageView->currentIndex().data(Qt::UserRole));
+ s.endGroup();
+} \ No newline at end of file