diff --git a/qt-gui.cpp b/qt-gui.cpp
index a65621314..04c5bc17a 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -89,7 +89,12 @@ void init_ui(int *argcp, char ***argvp)
QSettings s;
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();
s.endGroup();
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 985d213f6..e57ececd4 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1772,24 +1772,24 @@ LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent)
if ( !s.endsWith(".qm") ){
continue;
}
- languages.push_back(s);
+ languages.push_back( (s == "subsurface_source.qm") ? "English" : s);
}
}
QVariant LanguageModel::data(const QModelIndex& index, int role) const
{
QLocale loc;
+ QString currentString = languages.at(index.row());
if(!index.isValid())
return QVariant();
switch(role){
case Qt::DisplayRole:{
- QString currentString = languages.at(index.row());
QLocale l( currentString.remove("subsurface_"));
- return l.countryToString(l.country());
+ return currentString == "English" ? currentString : l.countryToString(l.country());
}break;
case Qt::UserRole:{
QString currentString = languages.at(index.row());
- return currentString.remove("subsurface_");
+ return currentString == "English" ? "en_US" : currentString.remove("subsurface_");
}break;
}
return QVariant();
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 45777d320..930a263a1 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -114,10 +114,11 @@ void PreferencesDialog::setUiFromPrefs()
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());
+ ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage").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());
}
void PreferencesDialog::restorePrefs()
@@ -187,10 +188,12 @@ void PreferencesDialog::syncSettings()
QLocale loc;
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"),
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));
emit settingsChanged();
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 50a0f7ab0..bdd37acca 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -943,12 +943,12 @@
setEnabled(bool)
- 187
- 77
+ 195
+ 39
- 581
- 80
+ 195
+ 39
@@ -959,12 +959,12 @@
setEnabled(bool)
- 187
- 77
+ 195
+ 39
- 668
- 80
+ 195
+ 39
@@ -975,12 +975,12 @@
setEnabled(bool)
- 186
- 121
+ 195
+ 39
- 581
- 124
+ 195
+ 39
@@ -991,12 +991,12 @@
setEnabled(bool)
- 186
- 121
+ 195
+ 39
- 668
- 124
+ 195
+ 39
@@ -1007,12 +1007,12 @@
setEnabled(bool)
- 184
- 165
+ 195
+ 39
- 581
- 168
+ 195
+ 39
@@ -1023,12 +1023,12 @@
setEnabled(bool)
- 184
- 165
+ 195
+ 39
- 668
- 168
+ 195
+ 39
@@ -1040,11 +1040,11 @@
195
- 209
+ 39
- 591
- 212
+ 195
+ 39
@@ -1056,11 +1056,11 @@
195
- 209
+ 39
- 668
- 212
+ 195
+ 39
@@ -1071,12 +1071,12 @@
setEnabled(bool)
- 298
- 327
+ 195
+ 39
- 512
- 327
+ 195
+ 39
@@ -1087,12 +1087,12 @@
setEnabled(bool)
- 298
- 327
+ 195
+ 39
- 668
- 327
+ 195
+ 39
@@ -1103,12 +1103,12 @@
setEnabled(bool)
- 298
- 327
+ 195
+ 39
- 668
- 327
+ 195
+ 39
@@ -1119,12 +1119,12 @@
setEnabled(bool)
- 362
- 275
+ 195
+ 39
- 586
- 270
+ 195
+ 39
@@ -1135,23 +1135,55 @@
setEnabled(bool)
- 613
- 41
+ 195
+ 39
- 634
- 72
+ 195
+ 39
+
+
+
+
+ languageSystemDefault
+ toggled(bool)
+ languageView
+ setDisabled(bool)
+
+
+ 176
+ 30
+
+
+ 171
+ 79
+
+
+
+
+ languageSystemDefault
+ toggled(bool)
+ languageFilter
+ setDisabled(bool)
+
+
+ 209
+ 34
+
+
+ 599
+ 33
-
+