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:
parent
3419422c23
commit
988b3083df
6 changed files with 60 additions and 56 deletions
|
@ -143,16 +143,16 @@ QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString va
|
|||
return result;
|
||||
}
|
||||
|
||||
QStringList SystemInfo::languages()
|
||||
QMap<QString, QString> SystemInfo::languages(void)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
QStringList result;
|
||||
QMap<QString, QString> result;
|
||||
systemInfos->beginGroup("languages");
|
||||
QStringList a = systemInfos->childKeys();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
result.append(systemInfos->value(a.at(i), "null").toString());
|
||||
result.insert(a.at(i), systemInfos->value(a.at(i), "null").toString());
|
||||
}
|
||||
systemInfos->endGroup();
|
||||
return result;
|
||||
|
|
|
@ -34,7 +34,7 @@ class SystemInfo : public QObject
|
|||
MapError,
|
||||
MapIncompatible,
|
||||
};
|
||||
|
||||
|
||||
//! All system settings
|
||||
enum SystemInfos {
|
||||
ManualUrl,
|
||||
|
@ -78,14 +78,14 @@ class SystemInfo : public QObject
|
|||
//! return a list of all platforms (rbutil internal names)
|
||||
static QStringList platforms(enum PlatformType type = PlatformAll,
|
||||
QString variant="");
|
||||
//! returns a list of all languages
|
||||
static QStringList languages(void);
|
||||
//! returns a map of all languages
|
||||
static QMap<QString, QString> languages(void);
|
||||
//! returns a map of usb-ids and their targets
|
||||
static QMap<int, QString> usbIdMap(enum MapType);
|
||||
//! get a value from system settings
|
||||
static QVariant value(enum SystemInfos info);
|
||||
//! get a value from system settings for a named platform.
|
||||
static QVariant platformValue(QString platform, enum SystemInfos info);
|
||||
static QVariant platformValue(QString platform, enum SystemInfos info);
|
||||
|
||||
private:
|
||||
//! you shouldnt call this, its a fully static calls
|
||||
|
|
|
@ -38,11 +38,10 @@ TTSBase::Capabilities TTSSapi::capabilities()
|
|||
void TTSSapi::generateSettings()
|
||||
{
|
||||
// language
|
||||
QStringList languages = SystemInfo::languages();
|
||||
languages.sort();
|
||||
QMap<QString, QString> languages = SystemInfo::languages();
|
||||
EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,
|
||||
tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage),
|
||||
languages);
|
||||
languages.values());
|
||||
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
|
||||
insertSetting(eLANGUAGE,setting);
|
||||
// voice
|
||||
|
|
|
@ -131,9 +131,10 @@ void Config::accept()
|
|||
if(RbSettings::value(RbSettings::Language).toString() != language
|
||||
&& !language.isEmpty()) {
|
||||
QMessageBox::information(this, tr("Language changed"),
|
||||
tr("You need to restart the application for the changed language to take effect."));
|
||||
RbSettings::setValue(RbSettings::Language, language);
|
||||
tr("You need to restart the application for the changed language "
|
||||
"to take effect."));
|
||||
}
|
||||
RbSettings::setValue(RbSettings::Language, language);
|
||||
|
||||
// mountpoint
|
||||
QString mp = ui.mountPoint->text();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -755,42 +755,42 @@ name="Sansa View"
|
|||
|
||||
|
||||
[languages]
|
||||
lang1=afrikaans
|
||||
lang2=bulgarian
|
||||
lang3=catala
|
||||
lang4=chinese-simp
|
||||
lang5=chinese-trad
|
||||
lang6=czech
|
||||
lang7=dansk
|
||||
lang8=deutsch
|
||||
lang9=eesti
|
||||
lang10=english
|
||||
lang11=espanol
|
||||
lang12=esperanto
|
||||
lang13=finnish
|
||||
lang14=francais
|
||||
lang15=galego
|
||||
lang16=greek
|
||||
lang17=hebrew
|
||||
lang18=islenska
|
||||
lang19=italiano
|
||||
lang20=japanese
|
||||
lang21=korean
|
||||
lang22=magyar
|
||||
lang23=nederlands
|
||||
lang24=norsk
|
||||
lang25=norsk-nynorsk
|
||||
lang26=polski
|
||||
lang27=portugues
|
||||
lang28=portugues-brasileiro
|
||||
lang29=romaneste
|
||||
lang30=russian
|
||||
lang31=slovenscina
|
||||
lang32=svenska
|
||||
lang33=thai
|
||||
lang34=turkce
|
||||
lang35=wallisertitsch
|
||||
lang36=hindi
|
||||
lang37=tagalog
|
||||
lang38=lietuviu
|
||||
af=afrikaans
|
||||
bg=bulgarian
|
||||
ca=catala
|
||||
cs=czech
|
||||
da=dansk
|
||||
de=deutsch
|
||||
el=greek
|
||||
en=english
|
||||
eo=esperanto
|
||||
es=espanol
|
||||
et=eesti
|
||||
fi=finnish
|
||||
fr=francais
|
||||
gl=galego
|
||||
he=hebrew
|
||||
hi=hindi
|
||||
hu=magyar
|
||||
is=islenska
|
||||
it=italiano
|
||||
ja=japanese
|
||||
ko=korean
|
||||
lt=lietuviu
|
||||
nb=norsk
|
||||
nl=nederlands
|
||||
nn=norsk-nynorsk
|
||||
pl=polski
|
||||
pt=portugues
|
||||
pt_BR=portugues-brasileiro
|
||||
ro=romaneste
|
||||
ru=russian
|
||||
sk=slovenscina
|
||||
sv=svenska
|
||||
th=thai
|
||||
tl=tagalog
|
||||
tr=turkce
|
||||
wa=wallisertitsch
|
||||
zh_CN=chinese-simp
|
||||
zh_TW=chinese-trad
|
||||
|
||||
|
|
Loading…
Reference in a new issue