mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added 'English' and 'Use System Default' options.
These complete the ability to select languages from the preferences panel. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7436178fe0
commit
9b7b477d7c
4 changed files with 101 additions and 61 deletions
|
@ -89,7 +89,12 @@ void init_ui(int *argcp, char ***argvp)
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup("Language");
|
s.beginGroup("Language");
|
||||||
QLocale loc(s.value("UiLanguage", QLocale().uiLanguages().first()).toString());
|
QLocale loc;
|
||||||
|
|
||||||
|
if (!s.value("UseSystemLanguage", true).toBool()){
|
||||||
|
loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString());
|
||||||
|
}
|
||||||
|
|
||||||
QString uiLang = loc.uiLanguages().first();
|
QString uiLang = loc.uiLanguages().first();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
|
|
@ -1772,24 +1772,24 @@ LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent)
|
||||||
if ( !s.endsWith(".qm") ){
|
if ( !s.endsWith(".qm") ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
languages.push_back(s);
|
languages.push_back( (s == "subsurface_source.qm") ? "English" : s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LanguageModel::data(const QModelIndex& index, int role) const
|
QVariant LanguageModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
QLocale loc;
|
QLocale loc;
|
||||||
|
QString currentString = languages.at(index.row());
|
||||||
if(!index.isValid())
|
if(!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
switch(role){
|
switch(role){
|
||||||
case Qt::DisplayRole:{
|
case Qt::DisplayRole:{
|
||||||
QString currentString = languages.at(index.row());
|
|
||||||
QLocale l( currentString.remove("subsurface_"));
|
QLocale l( currentString.remove("subsurface_"));
|
||||||
return l.countryToString(l.country());
|
return currentString == "English" ? currentString : l.countryToString(l.country());
|
||||||
}break;
|
}break;
|
||||||
case Qt::UserRole:{
|
case Qt::UserRole:{
|
||||||
QString currentString = languages.at(index.row());
|
QString currentString = languages.at(index.row());
|
||||||
return currentString.remove("subsurface_");
|
return currentString == "English" ? "en_US" : currentString.remove("subsurface_");
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -114,10 +114,11 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup("Language");
|
s.beginGroup("Language");
|
||||||
QAbstractItemModel *m = ui.languageView->model();
|
ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage").toBool());
|
||||||
QModelIndexList languages = m->match( m->index(0,0), Qt::DisplayRole, s.value("UiLanguage").toString());
|
QAbstractItemModel *m = ui.languageView->model();
|
||||||
if (languages.count())
|
QModelIndexList languages = m->match( m->index(0,0), Qt::UserRole, s.value("UiLanguage").toString());
|
||||||
ui.languageView->setCurrentIndex(languages.first());
|
if (languages.count())
|
||||||
|
ui.languageView->setCurrentIndex(languages.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::restorePrefs()
|
void PreferencesDialog::restorePrefs()
|
||||||
|
@ -187,10 +188,12 @@ void PreferencesDialog::syncSettings()
|
||||||
|
|
||||||
QLocale loc;
|
QLocale loc;
|
||||||
s.beginGroup("Language");
|
s.beginGroup("Language");
|
||||||
if (s.value("UiLanguage").toString() != ui.languageView->currentIndex().data(Qt::UserRole)){
|
if (s.value("UiLanguage").toString() != ui.languageView->currentIndex().data(Qt::UserRole) ||
|
||||||
|
s.value("UseSystemLanguage").toBool() != ui.languageSystemDefault->isChecked()) {
|
||||||
QMessageBox::warning(mainWindow(), tr("Restart required"),
|
QMessageBox::warning(mainWindow(), tr("Restart required"),
|
||||||
tr("To correctly load a new language you must restart Subsurface."));
|
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", ui.languageView->currentIndex().data(Qt::UserRole));
|
||||||
|
|
||||||
emit settingsChanged();
|
emit settingsChanged();
|
||||||
|
|
|
@ -943,12 +943,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>187</x>
|
<x>195</x>
|
||||||
<y>77</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>581</x>
|
<x>195</x>
|
||||||
<y>80</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -959,12 +959,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>187</x>
|
<x>195</x>
|
||||||
<y>77</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>80</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -975,12 +975,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>186</x>
|
<x>195</x>
|
||||||
<y>121</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>581</x>
|
<x>195</x>
|
||||||
<y>124</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -991,12 +991,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>186</x>
|
<x>195</x>
|
||||||
<y>121</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>124</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1007,12 +1007,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>184</x>
|
<x>195</x>
|
||||||
<y>165</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>581</x>
|
<x>195</x>
|
||||||
<y>168</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1023,12 +1023,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>184</x>
|
<x>195</x>
|
||||||
<y>165</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>168</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1040,11 +1040,11 @@
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>195</x>
|
<x>195</x>
|
||||||
<y>209</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>591</x>
|
<x>195</x>
|
||||||
<y>212</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1056,11 +1056,11 @@
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>195</x>
|
<x>195</x>
|
||||||
<y>209</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>212</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1071,12 +1071,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>298</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>512</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1087,12 +1087,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>298</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1103,12 +1103,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>298</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>668</x>
|
<x>195</x>
|
||||||
<y>327</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1119,12 +1119,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>362</x>
|
<x>195</x>
|
||||||
<y>275</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>586</x>
|
<x>195</x>
|
||||||
<y>270</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1135,23 +1135,55 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>613</x>
|
<x>195</x>
|
||||||
<y>41</y>
|
<y>39</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>634</x>
|
<x>195</x>
|
||||||
<y>72</y>
|
<y>39</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>languageSystemDefault</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>languageView</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>176</x>
|
||||||
|
<y>30</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>171</x>
|
||||||
|
<y>79</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>languageSystemDefault</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>languageFilter</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>209</x>
|
||||||
|
<y>34</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>599</x>
|
||||||
|
<y>33</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroup"/>
|
<buttongroup name="buttonGroup"/>
|
||||||
<buttongroup name="verticalSpeed"/>
|
|
||||||
<buttongroup name="buttonGroup_2"/>
|
<buttongroup name="buttonGroup_2"/>
|
||||||
<buttongroup name="buttonGroup_3"/>
|
<buttongroup name="buttonGroup_3"/>
|
||||||
<buttongroup name="buttonGroup_4"/>
|
<buttongroup name="buttonGroup_4"/>
|
||||||
<buttongroup name="buttonGroup_5"/>
|
<buttongroup name="buttonGroup_5"/>
|
||||||
<buttongroup name="buttonGroup_6"/>
|
<buttongroup name="buttonGroup_6"/>
|
||||||
|
<buttongroup name="verticalSpeed"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Add table
Reference in a new issue