summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_language.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 13:14:06 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 13:14:06 -0700
commit9eed778c68f72862b27695bee8b4dd1ba553bdc2 (patch)
treeaef5166c1829cfee83a9f57f5eeeea5ad39b62e3 /desktop-widgets/preferences/preferences_language.cpp
parent8dad3457ef1f412517c4d81f08ebd14680788ec3 (diff)
downloadsubsurface-9eed778c68f72862b27695bee8b4dd1ba553bdc2.tar.gz
Preferences: switch language preference to be a dropdown
The list widget takes too much space and isn't really any better. The dropdown plus fliter is actually rather neat. Also added back the connections so the dropdown and filter get disabled when system default is selected (just as it was in the old preferences dialog). 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.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp
index 07b60c3a3..ec4eed471 100644
--- a/desktop-widgets/preferences/preferences_language.cpp
+++ b/desktop-widgets/preferences/preferences_language.cpp
@@ -16,7 +16,7 @@ PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Langu
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
filterModel->setSourceModel(LanguageModel::instance());
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
- ui->languageView->setModel(filterModel);
+ ui->languageDropdown->setModel(filterModel);
filterModel->sort(0);
connect(ui->languageFilter, &QLineEdit::textChanged,
filterModel, &QSortFilterProxyModel::setFilterFixedString);
@@ -32,10 +32,10 @@ void PreferencesLanguage::refreshSettings()
QSettings s;
s.beginGroup("Language");
ui->languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
- QAbstractItemModel *m = ui->languageView->model();
+ QAbstractItemModel *m = ui->languageDropdown->model();
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
if (languages.count())
- ui->languageView->setCurrentIndex(languages.first());
+ ui->languageDropdown->setCurrentIndex(languages.first().row());
s.endGroup();
}
@@ -44,12 +44,14 @@ void PreferencesLanguage::syncSettings()
QSettings s;
s.beginGroup("Language");
bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
+ 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() != ui->languageView->currentIndex().data(Qt::UserRole))) {
+ (!useSystemLang && s.value("UiLanguage").toString() != currentText)) {
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.setValue("UiLanguage", currentText);
s.endGroup();
-} \ No newline at end of file
+}