summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 13:14:43 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 13:44:37 +0100
commit0e315e848ae7ea5b226af4ab16c215119cbd3fb3 (patch)
treeeed592e48bbd636ecdc02d65f7befbf213584faf
parentac5fc26085e390cb55a3a5fd186a8091adcae2d4 (diff)
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
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.cpp25
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.h2
-rw-r--r--rbutil/rbutilqt/base/systeminfo.cpp20
-rw-r--r--rbutil/rbutilqt/base/systeminfo.h3
-rw-r--r--rbutil/rbutilqt/base/ttssapi.cpp11
-rw-r--r--rbutil/rbutilqt/createvoicewindow.cpp32
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.cpp29
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.h1
-rw-r--r--rbutil/rbutilqt/test/test-playerbuildinfo.cpp37
9 files changed, 86 insertions, 74 deletions
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.cpp b/rbutil/rbutilqt/base/playerbuildinfo.cpp
index f49917cfef..4310991f40 100644
--- a/rbutil/rbutilqt/base/playerbuildinfo.cpp
+++ b/rbutil/rbutilqt/base/playerbuildinfo.cpp
@@ -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;
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.h b/rbutil/rbutilqt/base/playerbuildinfo.h
index 5307148ff5..52654312a0 100644
--- a/rbutil/rbutilqt/base/playerbuildinfo.h
+++ b/rbutil/rbutilqt/base/playerbuildinfo.h
@@ -69,6 +69,8 @@ public:
TargetNamesAll,
TargetNamesEnabled,
+ LanguageInfo,
+ LanguageList,
};
enum SystemUrl {
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp
index 6717b120cc..2b39300930 100644
--- a/rbutil/rbutilqt/base/systeminfo.cpp
+++ b/rbutil/rbutilqt/base/systeminfo.cpp
@@ -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();
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h
index d5a99082aa..5ca5b35885 100644
--- a/rbutil/rbutilqt/base/systeminfo.h
+++ b/rbutil/rbutilqt/base/systeminfo.h
@@ -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
diff --git a/rbutil/rbutilqt/base/ttssapi.cpp b/rbutil/rbutilqt/base/ttssapi.cpp
index f754f1a19b..ab972445f3 100644
--- a/rbutil/rbutilqt/base/ttssapi.cpp
+++ b/rbutil/rbutilqt/base/ttssapi.cpp
@@ -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
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp
index b56ffdb2c7..158c1201ce 100644
--- a/rbutil/rbutilqt/createvoicewindow.cpp
+++ b/rbutil/rbutilqt/createvoicewindow.cpp
@@ -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);
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
index 3f8d02a554..dcf3c6558f 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
@@ -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.
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.h b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
index 946aa93429..40e904ea37 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.h
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
@@ -42,6 +42,7 @@ class SelectiveInstallWidget : public QWidget
void continueInstall(bool);
void customizeThemes(void);
void selectedVersionChanged(int);
+ void updateVoiceLangs();
private:
void installBootloader(void);
diff --git a/rbutil/rbutilqt/test/test-playerbuildinfo.cpp b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp
index fe07ba8348..a250e37979 100644
--- a/rbutil/rbutilqt/test/test-playerbuildinfo.cpp
+++ b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp
@@ -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()