rbutil: Rework handling of available voice languages.
- Move Rockbox voice language names handling to PlayerBuildInfo, and handle it similarly to the rest of the device specific values. Rework internal handling to simplify things. - Enable language list from build server for installing prerendered voice files other than english. - Extend unit tests. Change-Id: I1a1a717fa4409fa965dabc86f52d52a4fc516315
This commit is contained in:
parent
ac5fc26085
commit
0e315e848a
9 changed files with 86 additions and 74 deletions
|
@ -66,8 +66,10 @@ const static struct {
|
|||
{ PlayerBuildInfo::Encoder, ":target:/encoder" },
|
||||
{ PlayerBuildInfo::Brand, ":target:/brand" },
|
||||
{ PlayerBuildInfo::PlayerPicture, ":target:/playerpic" },
|
||||
{ PlayerBuildInfo::TargetNamesAll, "" },
|
||||
{ PlayerBuildInfo::TargetNamesEnabled, "" },
|
||||
{ PlayerBuildInfo::TargetNamesAll, "_targets/all" },
|
||||
{ PlayerBuildInfo::TargetNamesEnabled, "_targets/enabled" },
|
||||
{ PlayerBuildInfo::LanguageInfo, "languages/:target:" },
|
||||
{ PlayerBuildInfo::LanguageList, "_languages/list" },
|
||||
};
|
||||
|
||||
const static struct {
|
||||
|
@ -227,6 +229,25 @@ QVariant PlayerBuildInfo::value(DeviceInfo item, QString target)
|
|||
result = targetNames(false);
|
||||
break;
|
||||
|
||||
case LanguageList:
|
||||
// Return a map (language, display string).
|
||||
{
|
||||
// need to use (QString, QVariant) here, so we can put the map into
|
||||
// a QVariant by itself.
|
||||
QMap<QString, QVariant> m;
|
||||
|
||||
playerInfo.beginGroup("languages");
|
||||
QStringList a = playerInfo.childKeys();
|
||||
|
||||
for(int i = 0; i < a.size(); i++) {
|
||||
QStringList v = playerInfo.value(a.at(i)).toStringList();
|
||||
m[v.at(0)] = v.at(1);
|
||||
}
|
||||
playerInfo.endGroup();
|
||||
result = m;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = playerInfo.value(s);
|
||||
break;
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
|
||||
TargetNamesAll,
|
||||
TargetNamesEnabled,
|
||||
LanguageInfo,
|
||||
LanguageList,
|
||||
};
|
||||
|
||||
enum SystemUrl {
|
||||
|
|
|
@ -38,26 +38,6 @@ void SystemInfo::ensureSystemInfoExists()
|
|||
}
|
||||
|
||||
|
||||
QMap<QString, QStringList> SystemInfo::languages(bool namesOnly)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
QMap<QString, QStringList> result;
|
||||
systemInfos->beginGroup("languages");
|
||||
QStringList a = systemInfos->childKeys();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
QStringList data = systemInfos->value(a.at(i), "null").toStringList();
|
||||
if(namesOnly)
|
||||
result.insert(data.at(0), QStringList(data.at(1)));
|
||||
else
|
||||
result.insert(a.at(i), data);
|
||||
}
|
||||
systemInfos->endGroup();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QMap<int, QStringList> SystemInfo::usbIdMap(enum MapType type)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
|
|
@ -34,9 +34,6 @@ class SystemInfo : public QObject
|
|||
MapIncompatible,
|
||||
};
|
||||
|
||||
//! returns a map of all languages.
|
||||
//! Maps <language code> to (<language name>, <display name>)
|
||||
static QMap<QString, QStringList> languages(bool namesOnly = false);
|
||||
//! returns a map of usb-ids and their targets
|
||||
static QMap<int, QStringList> usbIdMap(enum MapType type);
|
||||
//! get a value from system settings
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "ttssapi.h"
|
||||
#include "utils.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
#include "playerbuildinfo.h"
|
||||
#include "Logger.h"
|
||||
|
||||
TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
|
||||
|
@ -40,15 +40,12 @@ TTSBase::Capabilities TTSSapi::capabilities()
|
|||
void TTSSapi::generateSettings()
|
||||
{
|
||||
// language
|
||||
QMap<QString, QStringList> languages = SystemInfo::languages();
|
||||
QStringList langs;
|
||||
for(int i = 0; i < languages.size(); ++i) {
|
||||
langs.append(languages.values().at(i).at(0));
|
||||
}
|
||||
QMap<QString, QVariant> langmap = PlayerBuildInfo::instance()->value(
|
||||
PlayerBuildInfo::LanguageList).toMap();
|
||||
EncTtsSetting* setting = new EncTtsSetting(this,
|
||||
EncTtsSetting::eSTRINGLIST, tr("Language:"),
|
||||
RbSettings::subValue(m_TTSType, RbSettings::TtsLanguage),
|
||||
langs);
|
||||
langmap.keys());
|
||||
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
|
||||
insertSetting(eLANGUAGE,setting);
|
||||
// voice
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "configure.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
#include "playerbuildinfo.h"
|
||||
#include "Logger.h"
|
||||
|
||||
CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
|
||||
|
@ -70,26 +70,32 @@ void CreateVoiceWindow::accept()
|
|||
*/
|
||||
void CreateVoiceWindow::updateSettings(void)
|
||||
{
|
||||
// fill in language combobox
|
||||
QMap<QString, QStringList> languages = SystemInfo::languages();
|
||||
|
||||
for(int i = 0; i < languages.keys().size(); i++) {
|
||||
QString key = languages.keys().at(i);
|
||||
ui.comboLanguage->addItem(languages.value(key).at(1), languages.value(key).at(0));
|
||||
// fill in language combobox. Map has QString as value, but is stored as QVariant.
|
||||
QMap<QString, QVariant> langs
|
||||
= PlayerBuildInfo::instance()->value(PlayerBuildInfo::LanguageList).toMap();
|
||||
for(auto it = langs.begin(); it != langs.end(); it++) {
|
||||
ui.comboLanguage->addItem(it.value().toString(), it.key());
|
||||
}
|
||||
// set saved lang
|
||||
int sel = ui.comboLanguage->findData(
|
||||
RbSettings::value(RbSettings::VoiceLanguage).toString());
|
||||
// if no saved language is found try to figure the language from the UI lang
|
||||
if(sel == -1) {
|
||||
// the UI language is stored as ISO 631-1 code. Try to resolve it to the
|
||||
// Rockbox language string.
|
||||
QString uilang = RbSettings::value(RbSettings::Language).toString();
|
||||
// if no language is set default to english. Make sure not to check an empty string.
|
||||
QString f = "english";
|
||||
if(!uilang.isEmpty() && languages.contains(uilang)) {
|
||||
f = languages.value(uilang).at(0);
|
||||
// default to english if no language is set.
|
||||
if(uilang.isEmpty()) {
|
||||
// FIXME: we try to set the UI language from the environment, but
|
||||
// don't store it unless changed. Falling back to en is only valid
|
||||
// if the system is actually english.
|
||||
uilang = "en";
|
||||
}
|
||||
QString l = PlayerBuildInfo::instance()->value(
|
||||
PlayerBuildInfo::LanguageInfo, uilang).toStringList().at(0);
|
||||
if(!l.isEmpty()) {
|
||||
sel = ui.comboLanguage->findData(l);
|
||||
}
|
||||
sel = ui.comboLanguage->findData(f);
|
||||
LOG_INFO() << "Selected language index:" << sel;
|
||||
}
|
||||
ui.comboLanguage->setCurrentIndex(sel);
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "playerbuildinfo.h"
|
||||
#include "rbsettings.h"
|
||||
#include "rockboxinfo.h"
|
||||
#include "systeminfo.h"
|
||||
#include "progressloggergui.h"
|
||||
#include "bootloaderinstallbase.h"
|
||||
#include "bootloaderinstallhelper.h"
|
||||
|
@ -100,6 +99,8 @@ void SelectiveInstallWidget::selectedVersionChanged(int index)
|
|||
ui.voiceCheckbox->setEnabled(voice);
|
||||
ui.voiceCombobox->setEnabled(voice);
|
||||
ui.voiceLabel->setEnabled(voice);
|
||||
|
||||
updateVoiceLangs();
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,21 +163,25 @@ void SelectiveInstallWidget::updateVersion(void)
|
|||
RockboxInfo info(m_mountpoint);
|
||||
ui.bootloaderCheckbox->setChecked(!info.success());
|
||||
}
|
||||
|
||||
updateVoiceLangs();
|
||||
}
|
||||
|
||||
void SelectiveInstallWidget::updateVoiceLangs()
|
||||
{
|
||||
// populate languages for voice file.
|
||||
// FIXME: currently only english. Need to get the available languages from
|
||||
// build-info later.
|
||||
QVariant current = ui.voiceCombobox->currentData();
|
||||
QMap<QString, QStringList> languages = SystemInfo::languages(true);
|
||||
QStringList voicelangs;
|
||||
voicelangs << "english";
|
||||
QMap<QString, QVariant> langs = PlayerBuildInfo::instance()->value(
|
||||
PlayerBuildInfo::LanguageList).toMap();
|
||||
QStringList voicelangs = PlayerBuildInfo::instance()->value(
|
||||
PlayerBuildInfo::BuildVoiceLangs, m_buildtype).toStringList();
|
||||
ui.voiceCombobox->clear();
|
||||
for(int i = 0; i < voicelangs.size(); i++) {
|
||||
QString key = voicelangs.at(i);
|
||||
if(!languages.contains(key)) {
|
||||
LOG_WARNING() << "trying to add unknown language" << key;
|
||||
continue;
|
||||
for(auto it = langs.begin(); it != langs.end(); it++) {
|
||||
if(voicelangs.contains(it.key())) {
|
||||
ui.voiceCombobox->addItem(it.value().toString(), it.key());
|
||||
LOG_INFO() << "available voices: adding" << it.key();
|
||||
}
|
||||
ui.voiceCombobox->addItem(languages.value(key).at(0), key);
|
||||
|
||||
}
|
||||
// try to select the previously selected one again (if still present)
|
||||
// TODO: Fall back to system language if not found, or english.
|
||||
|
|
|
@ -42,6 +42,7 @@ class SelectiveInstallWidget : public QWidget
|
|||
void continueInstall(bool);
|
||||
void customizeThemes(void);
|
||||
void selectedVersionChanged(int);
|
||||
void updateVoiceLangs();
|
||||
|
||||
private:
|
||||
void installBootloader(void);
|
||||
|
|
|
@ -137,23 +137,26 @@ struct {
|
|||
QString expected;
|
||||
} testdataPlayer[] =
|
||||
{
|
||||
{"archosfmrecorder", PlayerBuildInfo::BuildStatus, "3"},
|
||||
{ "iriverh10", PlayerBuildInfo::BuildStatus, "0" },
|
||||
{ "iriverh100", PlayerBuildInfo::BuildStatus, "2" },
|
||||
{ "iriverh300", PlayerBuildInfo::BuildStatus, "1" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" },
|
||||
{"archosfmrecorder", PlayerBuildInfo::DisplayName, "Jukebox Recorder FM"},
|
||||
{"archosfmrecorder", PlayerBuildInfo::BootloaderMethod, "none"},
|
||||
{"archosfmrecorder", PlayerBuildInfo::BootloaderName, ""},
|
||||
{"archosfmrecorder", PlayerBuildInfo::BootloaderFile, ""},
|
||||
{"archosfmrecorder", PlayerBuildInfo::BootloaderFilter, ""},
|
||||
{"archosfmrecorder", PlayerBuildInfo::Encoder, "lame"},
|
||||
{"archosfmrecorder", PlayerBuildInfo::Brand, "Archos"},
|
||||
{"archosfmrecorder", PlayerBuildInfo::PlayerPicture, "archosfmrecorder"},
|
||||
{"iriverh100", PlayerBuildInfo::BuildStatus, "2"},
|
||||
{"iriverh100", PlayerBuildInfo::BootloaderMethod, "hex"},
|
||||
{"iriverh100", PlayerBuildInfo::BootloaderFilter, "*.hex *.zip"},
|
||||
{"ipodmini2g", PlayerBuildInfo::Encoder, "rbspeex"},
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" },
|
||||
{ "iriverh10", PlayerBuildInfo::BuildStatus, "0" },
|
||||
{ "iriverh100", PlayerBuildInfo::BuildStatus, "2" },
|
||||
{ "iriverh300", PlayerBuildInfo::BuildStatus, "1" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::DisplayName, "Jukebox Recorder FM"},
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BootloaderMethod, "none" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BootloaderName, "" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BootloaderFile, "" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::BootloaderFilter, "" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::Encoder, "lame" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::Brand, "Archos" },
|
||||
{ "archosfmrecorder", PlayerBuildInfo::PlayerPicture, "archosfmrecorder"},
|
||||
{ "iriverh100", PlayerBuildInfo::BuildStatus, "2" },
|
||||
{ "iriverh100", PlayerBuildInfo::BootloaderMethod, "hex" },
|
||||
{ "iriverh100", PlayerBuildInfo::BootloaderFilter, "*.hex *.zip" },
|
||||
{ "ipodmini2g", PlayerBuildInfo::Encoder, "rbspeex" },
|
||||
{ "078174b1", PlayerBuildInfo::DisplayName, "Sansa View" },
|
||||
{ "de", PlayerBuildInfo::LanguageInfo, "deutsch,Deutsch" },
|
||||
{ "en_US", PlayerBuildInfo::LanguageInfo, "english-us,English (US)" },
|
||||
};
|
||||
|
||||
void TestPlayerBuildInfo::testBuildInfo_data()
|
||||
|
|
Loading…
Reference in a new issue