diff options
| author | Tannin <devnull@localhost> | 2013-02-19 21:33:58 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-02-19 21:33:58 +0100 |
| commit | cb297d20b616e49803470396c21dd5747370cfaf (patch) | |
| tree | 19d2fe4119f65d23ba7e833a98bebd5cf854fe4d /src/settings.cpp | |
| parent | efe42430777fe187c042d30e3496448fd12c9a82 (diff) | |
- proper detection of user-preferred language
- resume and removal of failed download fixed
Diffstat (limited to 'src/settings.cpp')
| -rw-r--r-- | src/settings.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index e7553676..3ee916c0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -238,6 +238,22 @@ QVariant Settings::pluginSetting(const QString &pluginName, const QString &key) return *iterSetting; } +QString Settings::language() +{ + QString result = m_Settings.value("Settings/language", "").toString(); + if (result.isEmpty()) { + QStringList languagePreferences = QLocale::system().uiLanguages(); + if (languagePreferences.length() > 0) { + // the users most favoritest language + result = languagePreferences.at(0); + } else { + // fallback system locale + result = QLocale::system().name(); + } + } + return result; +} + void Settings::addLanguages(QComboBox *languageBox) { @@ -260,7 +276,6 @@ void Settings::addLanguages(QComboBox *languageBox) languageString = "Chinese (simplified)"; } } - languageBox->addItem(QString("%1").arg(languageString), exp.cap(1)); } } @@ -387,7 +402,13 @@ void Settings::query(QWidget *parent) { addLanguages(languageBox); - int currentID = languageBox->findData(m_Settings.value("Settings/language", QLocale::system().name()).toString()); + QString languageCode = language(); + int currentID = languageBox->findData(languageCode); + // I made a mess. :( Most languages are stored with only the iso country code (2 characters like "de") but chinese + // with the exact language variant (zh_TW) so I have to search for both variants + if (currentID == -1) { + currentID = languageBox->findData(languageCode.mid(0, 2)); + } if (currentID != -1) { languageBox->setCurrentIndex(currentID); } |
