diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-02-04 23:28:34 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-02-04 23:28:34 +0000 |
commit | 988b3083df91d88848ec637664e2d8b9ed26a489 (patch) | |
tree | 07186d46e09da918d246ecbe2d86f3e49440f9e5 | |
parent | 3419422c239758fc6002e56e6be3c034bc8dbe8e (diff) | |
download | rockbox-988b3083df91d88848ec637664e2d8b9ed26a489.tar.gz rockbox-988b3083df91d88848ec637664e2d8b9ed26a489.zip |
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
-rw-r--r-- | rbutil/rbutilqt/base/systeminfo.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/systeminfo.h | 8 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttssapi.cpp | 5 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 5 | ||||
-rw-r--r-- | rbutil/rbutilqt/createvoicewindow.cpp | 16 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 76 |
6 files changed, 60 insertions, 56 deletions
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp index b493168699..4a9c471951 100644 --- a/rbutil/rbutilqt/base/systeminfo.cpp +++ b/rbutil/rbutilqt/base/systeminfo.cpp | |||
@@ -143,16 +143,16 @@ QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString va | |||
143 | return result; | 143 | return result; |
144 | } | 144 | } |
145 | 145 | ||
146 | QStringList SystemInfo::languages() | 146 | QMap<QString, QString> SystemInfo::languages(void) |
147 | { | 147 | { |
148 | ensureSystemInfoExists(); | 148 | ensureSystemInfoExists(); |
149 | 149 | ||
150 | QStringList result; | 150 | QMap<QString, QString> result; |
151 | systemInfos->beginGroup("languages"); | 151 | systemInfos->beginGroup("languages"); |
152 | QStringList a = systemInfos->childKeys(); | 152 | QStringList a = systemInfos->childKeys(); |
153 | for(int i = 0; i < a.size(); i++) | 153 | for(int i = 0; i < a.size(); i++) |
154 | { | 154 | { |
155 | result.append(systemInfos->value(a.at(i), "null").toString()); | 155 | result.insert(a.at(i), systemInfos->value(a.at(i), "null").toString()); |
156 | } | 156 | } |
157 | systemInfos->endGroup(); | 157 | systemInfos->endGroup(); |
158 | return result; | 158 | return result; |
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h index 214e423a51..f5e0eae6ef 100644 --- a/rbutil/rbutilqt/base/systeminfo.h +++ b/rbutil/rbutilqt/base/systeminfo.h | |||
@@ -34,7 +34,7 @@ class SystemInfo : public QObject | |||
34 | MapError, | 34 | MapError, |
35 | MapIncompatible, | 35 | MapIncompatible, |
36 | }; | 36 | }; |
37 | 37 | ||
38 | //! All system settings | 38 | //! All system settings |
39 | enum SystemInfos { | 39 | enum SystemInfos { |
40 | ManualUrl, | 40 | ManualUrl, |
@@ -78,14 +78,14 @@ class SystemInfo : public QObject | |||
78 | //! return a list of all platforms (rbutil internal names) | 78 | //! return a list of all platforms (rbutil internal names) |
79 | static QStringList platforms(enum PlatformType type = PlatformAll, | 79 | static QStringList platforms(enum PlatformType type = PlatformAll, |
80 | QString variant=""); | 80 | QString variant=""); |
81 | //! returns a list of all languages | 81 | //! returns a map of all languages |
82 | static QStringList languages(void); | 82 | static QMap<QString, QString> languages(void); |
83 | //! returns a map of usb-ids and their targets | 83 | //! returns a map of usb-ids and their targets |
84 | static QMap<int, QString> usbIdMap(enum MapType); | 84 | static QMap<int, QString> usbIdMap(enum MapType); |
85 | //! get a value from system settings | 85 | //! get a value from system settings |
86 | static QVariant value(enum SystemInfos info); | 86 | static QVariant value(enum SystemInfos info); |
87 | //! get a value from system settings for a named platform. | 87 | //! get a value from system settings for a named platform. |
88 | static QVariant platformValue(QString platform, enum SystemInfos info); | 88 | static QVariant platformValue(QString platform, enum SystemInfos info); |
89 | 89 | ||
90 | private: | 90 | private: |
91 | //! you shouldnt call this, its a fully static calls | 91 | //! you shouldnt call this, its a fully static calls |
diff --git a/rbutil/rbutilqt/base/ttssapi.cpp b/rbutil/rbutilqt/base/ttssapi.cpp index b149e1d786..2cc95cd4aa 100644 --- a/rbutil/rbutilqt/base/ttssapi.cpp +++ b/rbutil/rbutilqt/base/ttssapi.cpp | |||
@@ -38,11 +38,10 @@ TTSBase::Capabilities TTSSapi::capabilities() | |||
38 | void TTSSapi::generateSettings() | 38 | void TTSSapi::generateSettings() |
39 | { | 39 | { |
40 | // language | 40 | // language |
41 | QStringList languages = SystemInfo::languages(); | 41 | QMap<QString, QString> languages = SystemInfo::languages(); |
42 | languages.sort(); | ||
43 | EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, | 42 | EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, |
44 | tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage), | 43 | tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage), |
45 | languages); | 44 | languages.values()); |
46 | connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList())); | 45 | connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList())); |
47 | insertSetting(eLANGUAGE,setting); | 46 | insertSetting(eLANGUAGE,setting); |
48 | // voice | 47 | // voice |
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 7ed74f1b9e..e5ea699257 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -131,9 +131,10 @@ void Config::accept() | |||
131 | if(RbSettings::value(RbSettings::Language).toString() != language | 131 | if(RbSettings::value(RbSettings::Language).toString() != language |
132 | && !language.isEmpty()) { | 132 | && !language.isEmpty()) { |
133 | QMessageBox::information(this, tr("Language changed"), | 133 | QMessageBox::information(this, tr("Language changed"), |
134 | tr("You need to restart the application for the changed language to take effect.")); | 134 | tr("You need to restart the application for the changed language " |
135 | RbSettings::setValue(RbSettings::Language, language); | 135 | "to take effect.")); |
136 | } | 136 | } |
137 | RbSettings::setValue(RbSettings::Language, language); | ||
137 | 138 | ||
138 | // mountpoint | 139 | // mountpoint |
139 | QString mp = ui.mountPoint->text(); | 140 | QString mp = ui.mountPoint->text(); |
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp index 7c2ff732c4..95df4b1b0c 100644 --- a/rbutil/rbutilqt/createvoicewindow.cpp +++ b/rbutil/rbutilqt/createvoicewindow.cpp | |||
@@ -71,24 +71,28 @@ void CreateVoiceWindow::accept() | |||
71 | void CreateVoiceWindow::updateSettings(void) | 71 | void CreateVoiceWindow::updateSettings(void) |
72 | { | 72 | { |
73 | // fill in language combobox | 73 | // fill in language combobox |
74 | QStringList languages = SystemInfo::languages(); | 74 | QMap<QString, QString> languages = SystemInfo::languages(); |
75 | languages.sort(); | 75 | |
76 | ui.comboLanguage->addItems(languages); | 76 | for(int i = 0; i < languages.keys().size(); i++) { |
77 | QString key = languages.keys().at(i); | ||
78 | ui.comboLanguage->addItem(languages.value(key), key); | ||
79 | } | ||
77 | // set saved lang | 80 | // set saved lang |
78 | int sel = ui.comboLanguage->findText(RbSettings::value(RbSettings::VoiceLanguage).toString()); | 81 | int sel = ui.comboLanguage->findText( |
82 | RbSettings::value(RbSettings::VoiceLanguage).toString()); | ||
79 | // if no saved language is found try to figure the language from the UI lang | 83 | // if no saved language is found try to figure the language from the UI lang |
80 | if(sel == -1) { | 84 | if(sel == -1) { |
81 | QString f = RbSettings::value(RbSettings::Language).toString(); | 85 | QString f = RbSettings::value(RbSettings::Language).toString(); |
82 | // if no language is set default to english. Make sure not to check an empty string. | 86 | // if no language is set default to english. Make sure not to check an empty string. |
83 | if(f.isEmpty()) f = "english"; | 87 | if(f.isEmpty()) f = "english"; |
84 | sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith); | 88 | sel = ui.comboLanguage->findData(f); |
85 | qDebug() << "sel =" << sel; | 89 | qDebug() << "sel =" << sel; |
86 | // still nothing found? | 90 | // still nothing found? |
87 | if(sel == -1) | 91 | if(sel == -1) |
88 | sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith); | 92 | sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith); |
89 | } | 93 | } |
90 | ui.comboLanguage->setCurrentIndex(sel); | 94 | ui.comboLanguage->setCurrentIndex(sel); |
91 | 95 | ||
92 | QString ttsName = RbSettings::value(RbSettings::Tts).toString(); | 96 | QString ttsName = RbSettings::value(RbSettings::Tts).toString(); |
93 | TTSBase* tts = TTSBase::getTTS(this,ttsName); | 97 | TTSBase* tts = TTSBase::getTTS(this,ttsName); |
94 | if(tts->configOk()) | 98 | if(tts->configOk()) |
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 2eb429eaf7..7fa25deb7d 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini | |||
@@ -755,42 +755,42 @@ name="Sansa View" | |||
755 | 755 | ||
756 | 756 | ||
757 | [languages] | 757 | [languages] |
758 | lang1=afrikaans | 758 | af=afrikaans |
759 | lang2=bulgarian | 759 | bg=bulgarian |
760 | lang3=catala | 760 | ca=catala |
761 | lang4=chinese-simp | 761 | cs=czech |
762 | lang5=chinese-trad | 762 | da=dansk |
763 | lang6=czech | 763 | de=deutsch |
764 | lang7=dansk | 764 | el=greek |
765 | lang8=deutsch | 765 | en=english |
766 | lang9=eesti | 766 | eo=esperanto |
767 | lang10=english | 767 | es=espanol |
768 | lang11=espanol | 768 | et=eesti |
769 | lang12=esperanto | 769 | fi=finnish |
770 | lang13=finnish | 770 | fr=francais |
771 | lang14=francais | 771 | gl=galego |
772 | lang15=galego | 772 | he=hebrew |
773 | lang16=greek | 773 | hi=hindi |
774 | lang17=hebrew | 774 | hu=magyar |
775 | lang18=islenska | 775 | is=islenska |
776 | lang19=italiano | 776 | it=italiano |
777 | lang20=japanese | 777 | ja=japanese |
778 | lang21=korean | 778 | ko=korean |
779 | lang22=magyar | 779 | lt=lietuviu |
780 | lang23=nederlands | 780 | nb=norsk |
781 | lang24=norsk | 781 | nl=nederlands |
782 | lang25=norsk-nynorsk | 782 | nn=norsk-nynorsk |
783 | lang26=polski | 783 | pl=polski |
784 | lang27=portugues | 784 | pt=portugues |
785 | lang28=portugues-brasileiro | 785 | pt_BR=portugues-brasileiro |
786 | lang29=romaneste | 786 | ro=romaneste |
787 | lang30=russian | 787 | ru=russian |
788 | lang31=slovenscina | 788 | sk=slovenscina |
789 | lang32=svenska | 789 | sv=svenska |
790 | lang33=thai | 790 | th=thai |
791 | lang34=turkce | 791 | tl=tagalog |
792 | lang35=wallisertitsch | 792 | tr=turkce |
793 | lang36=hindi | 793 | wa=wallisertitsch |
794 | lang37=tagalog | 794 | zh_CN=chinese-simp |
795 | lang38=lietuviu | 795 | zh_TW=chinese-trad |
796 | 796 | ||