diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-10-30 13:14:06 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-10-30 13:14:06 -0700 |
commit | 9eed778c68f72862b27695bee8b4dd1ba553bdc2 (patch) | |
tree | aef5166c1829cfee83a9f57f5eeeea5ad39b62e3 | |
parent | 8dad3457ef1f412517c4d81f08ebd14680788ec3 (diff) | |
download | subsurface-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>
-rw-r--r-- | desktop-widgets/preferences/preferences_language.cpp | 14 | ||||
-rw-r--r-- | desktop-widgets/preferences/prefs_language.ui | 65 |
2 files changed, 60 insertions, 19 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 +} diff --git a/desktop-widgets/preferences/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui index 80671fca8..650d543f6 100644 --- a/desktop-widgets/preferences/prefs_language.ui +++ b/desktop-widgets/preferences/prefs_language.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>576</width> + <width>621</width> <height>523</height> </rect> </property> @@ -17,7 +17,7 @@ <item> <widget class="QGroupBox" name="language_group"> <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -34,6 +34,9 @@ </widget> </item> <item> + <widget class="QComboBox" name="languageDropdown"/> + </item> + <item> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -59,18 +62,54 @@ </layout> </widget> </item> - <item> - <widget class="QListView" name="languageView"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <resources/> - <connections/> + <connections> + <connection> + <sender>languageSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>languageDropdown</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>73</x> + <y>273</y> + </hint> + <hint type="destinationlabel"> + <x>179</x> + <y>273</y> + </hint> + </hints> + </connection> + <connection> + <sender>languageSystemDefault</sender> + <signal>toggled(bool)</signal> + <receiver>languageFilter</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>73</x> + <y>273</y> + </hint> + <hint type="destinationlabel"> + <x>539</x> + <y>273</y> + </hint> + </hints> + </connection> + </connections> </ui> |