1
0
Fork 0
forked from len0rd/rockbox

Replace list of languages with map.

- Use ISO codes as keys for voice languages instead of enumeration.
- Instead of trying to select a suitable voicefile language from the UI
  language use the ISO codes stored as UI language and match against the
  mapping.
- Always store the selected UI language. Fixes the voicefile creation
  language lookup to fail if the language used is the system language.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29207 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2011-02-04 23:28:34 +00:00
parent 3419422c23
commit 988b3083df
6 changed files with 60 additions and 56 deletions

View file

@ -71,24 +71,28 @@ void CreateVoiceWindow::accept()
void CreateVoiceWindow::updateSettings(void)
{
// fill in language combobox
QStringList languages = SystemInfo::languages();
languages.sort();
ui.comboLanguage->addItems(languages);
QMap<QString, QString> languages = SystemInfo::languages();
for(int i = 0; i < languages.keys().size(); i++) {
QString key = languages.keys().at(i);
ui.comboLanguage->addItem(languages.value(key), key);
}
// set saved lang
int sel = ui.comboLanguage->findText(RbSettings::value(RbSettings::VoiceLanguage).toString());
int sel = ui.comboLanguage->findText(
RbSettings::value(RbSettings::VoiceLanguage).toString());
// if no saved language is found try to figure the language from the UI lang
if(sel == -1) {
QString f = RbSettings::value(RbSettings::Language).toString();
// if no language is set default to english. Make sure not to check an empty string.
if(f.isEmpty()) f = "english";
sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith);
sel = ui.comboLanguage->findData(f);
qDebug() << "sel =" << sel;
// still nothing found?
if(sel == -1)
sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith);
}
ui.comboLanguage->setCurrentIndex(sel);
QString ttsName = RbSettings::value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(this,ttsName);
if(tts->configOk())