From c2dacf6736dfcde92a4ed947f06fd85c6b2087d4 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 21 Nov 2020 19:33:29 +0100 Subject: rbutil: Add voice installation to main widget. Add checkbox for installing the prerendered voice file to the main install widget. Current limitations: - only english for now. The available languages are available from the build server but are not yet taken into account. - only for releases. This is the same limitations we had before. We do have voices for daily builds, but that requires adding daily builds again (those have been removed some time back.) - Old voice installation dialog still present. Change-Id: Ia6443b0f15365196df86cc1b64d5e043dff70c4c --- rbutil/rbutilqt/base/rbsettings.cpp | 1 + rbutil/rbutilqt/base/rbsettings.h | 1 + rbutil/rbutilqt/base/systeminfo.cpp | 8 +- rbutil/rbutilqt/base/systeminfo.h | 5 +- rbutil/rbutilqt/gui/selectiveinstallwidget.cpp | 119 +++++++++++++++---- rbutil/rbutilqt/gui/selectiveinstallwidget.h | 2 + rbutil/rbutilqt/gui/selectiveinstallwidgetfrm.ui | 143 +++++++++++++---------- rbutil/rbutilqt/rbutil.ini | 7 +- rbutil/rbutilqt/rbutilqt.cpp | 1 + 9 files changed, 199 insertions(+), 88 deletions(-) diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp index 827c0f96fd..5baa53bee0 100644 --- a/rbutil/rbutilqt/base/rbsettings.cpp +++ b/rbutil/rbutilqt/base/rbsettings.cpp @@ -47,6 +47,7 @@ const static struct { { RbSettings::InstallFonts, "install_fonts", "true" }, { RbSettings::InstallThemes, "install_themes", "false" }, { RbSettings::InstallGamefiles, "install_gamefiles", "true" }, + { RbSettings::InstallVoice, "install_voice", "false" }, #if defined(Q_OS_WIN32) { RbSettings::Tts, "tts", "sapi" }, #elif defined(Q_OS_MACX) diff --git a/rbutil/rbutilqt/base/rbsettings.h b/rbutil/rbutilqt/base/rbsettings.h index 7406aab1ad..a25eabbcee 100644 --- a/rbutil/rbutilqt/base/rbsettings.h +++ b/rbutil/rbutilqt/base/rbsettings.h @@ -46,6 +46,7 @@ class RbSettings : public QObject InstallFonts, InstallThemes, InstallGamefiles, + InstallVoice, Tts, UseTtsCorrections, TalkFolders, diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp index 2aece49110..2ad3c7a7d4 100644 --- a/rbutil/rbutilqt/base/systeminfo.cpp +++ b/rbutil/rbutilqt/base/systeminfo.cpp @@ -159,7 +159,7 @@ QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString va return result; } -QMap SystemInfo::languages(void) +QMap SystemInfo::languages(bool namesOnly) { ensureSystemInfoExists(); @@ -168,7 +168,11 @@ QMap SystemInfo::languages(void) QStringList a = systemInfos->childKeys(); for(int i = 0; i < a.size(); i++) { - result.insert(a.at(i), systemInfos->value(a.at(i), "null").toStringList()); + 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; diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h index 12b9eb4bfb..9bcfe6d253 100644 --- a/rbutil/rbutilqt/base/systeminfo.h +++ b/rbutil/rbutilqt/base/systeminfo.h @@ -90,8 +90,9 @@ class SystemInfo : public QObject //! return a list of all platforms (rbutil internal names) static QStringList platforms(enum PlatformType type = PlatformAll, QString variant=""); - //! returns a map of all languages - static QMap languages(void); + //! returns a map of all languages. + //! Maps to (, ) + static QMap languages(bool namesOnly = false); //! returns a map of usb-ids and their targets static QMap usbIdMap(enum MapType type); //! get a value from system settings diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp index c916e7a190..8a83c6ebc5 100644 --- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp +++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp @@ -39,6 +39,7 @@ SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent ui.fontsCheckbox->setChecked(RbSettings::value(RbSettings::InstallFonts).toBool()); ui.themesCheckbox->setChecked(RbSettings::value(RbSettings::InstallThemes).toBool()); ui.gamefileCheckbox->setChecked(RbSettings::value(RbSettings::InstallGamefiles).toBool()); + ui.voiceCheckbox->setChecked(RbSettings::value(RbSettings::InstallVoice).toBool()); // check if Rockbox is installed by looking after rockbox-info.txt. // If installed uncheck bootloader installation. @@ -62,17 +63,27 @@ SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent void SelectiveInstallWidget::selectedVersionChanged(int index) { - QString current = ui.selectedVersion->itemData(index).toString(); - if(current == "release") + m_buildtype = ui.selectedVersion->itemData(index).toString(); + bool voice = true; + if(m_buildtype == "release") { ui.selectedDescription->setText(tr("This is the latest stable " "release available.")); - if(current == "development") + voice = true; + } + if(m_buildtype == "development") { ui.selectedDescription->setText(tr("The development version is " "updated on every code change. Last update was on %1").arg( ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString())); - if(current == "rc") + voice = false; + } + if(m_buildtype == "rc") { ui.selectedDescription->setText(tr("This will eventually become the " "next Rockbox version. Install it to help testing.")); + voice = false; + } + ui.voiceCheckbox->setEnabled(voice); + ui.voiceCombobox->setEnabled(voice); + ui.voiceLabel->setEnabled(voice); } @@ -144,7 +155,27 @@ void SelectiveInstallWidget::updateVersion(void) RockboxInfo info(m_mountpoint); ui.bootloaderCheckbox->setChecked(!info.success()); } - + // 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 languages = SystemInfo::languages(true); + QStringList voicelangs; + voicelangs << "english"; + 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; + } + 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. + int sel = ui.voiceCombobox->findData(current); + if(sel >= 0) + ui.voiceCombobox->setCurrentIndex(sel); } @@ -157,6 +188,8 @@ void SelectiveInstallWidget::saveSettings(void) RbSettings::setValue(RbSettings::InstallFonts, ui.fontsCheckbox->isChecked()); RbSettings::setValue(RbSettings::InstallThemes, ui.themesCheckbox->isChecked()); RbSettings::setValue(RbSettings::InstallGamefiles, ui.gamefileCheckbox->isChecked()); + RbSettings::setValue(RbSettings::InstallVoice, ui.voiceCheckbox->isChecked()); + RbSettings::setValue(RbSettings::VoiceLanguage, ui.voiceCombobox->currentData().toString()); } @@ -209,7 +242,8 @@ void SelectiveInstallWidget::continueInstall(bool error) case 3: installFonts(); break; case 4: installThemes(); break; case 5: installGamefiles(); break; - case 6: installBootloaderPost(); break; + case 6: installVoicefile(); break; + case 7: installBootloaderPost(); break; default: break; } @@ -381,15 +415,14 @@ void SelectiveInstallWidget::installRockbox(void) LOG_INFO() << "installing Rockbox"; QString url; - QString selected = ui.selectedVersion->itemData(ui.selectedVersion->currentIndex()).toString(); - RbSettings::setValue(RbSettings::Build, selected); + RbSettings::setValue(RbSettings::Build, m_buildtype); RbSettings::sync(); - if(selected == "release") url = ServerInfo::instance()->platformValue( + if(m_buildtype == "release") url = ServerInfo::instance()->platformValue( ServerInfo::CurReleaseUrl, m_target).toString(); - else if(selected == "development") url = ServerInfo::instance()->platformValue( + else if(m_buildtype == "development") url = ServerInfo::instance()->platformValue( ServerInfo::CurDevelUrl, m_target).toString(); - else if(selected == "rc") url = ServerInfo::instance()->platformValue( + else if(m_buildtype == "rc") url = ServerInfo::instance()->platformValue( ServerInfo::RelCandidateUrl, m_target).toString(); //! install build @@ -399,7 +432,7 @@ void SelectiveInstallWidget::installRockbox(void) m_zipinstaller->setLogSection("Rockbox (Base)"); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) m_zipinstaller->setCache(true); - m_zipinstaller->setLogVersion(m_versions[selected]); + m_zipinstaller->setLogVersion(m_versions[m_buildtype]); m_zipinstaller->setMountPoint(m_mountpoint); connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); @@ -422,25 +455,71 @@ void SelectiveInstallWidget::installFonts(void) if(ui.fontsCheckbox->isChecked()) { LOG_INFO() << "installing Fonts"; + RockboxInfo installInfo(m_mountpoint); + QString fontsurl; + QString logversion; + QString relversion = installInfo.release(); + if(relversion.isEmpty()) { + // release is empty for non-release versions (i.e. daily / current) + fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildDaily).toString(); + } + else { + fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildRelease).toString(); + logversion = installInfo.release(); + } + fontsurl.replace("%RELEASEVER%", relversion); + + // create new zip installer + if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); + m_zipinstaller = new ZipInstaller(this); + m_zipinstaller->setUrl(fontsurl); + m_zipinstaller->setLogSection("Fonts"); + m_zipinstaller->setLogVersion(logversion); + m_zipinstaller->setMountPoint(m_mountpoint); + if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) + m_zipinstaller->setCache(true); + + connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); + connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); + connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); + connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); + m_zipinstaller->install(); + } + else { + LOG_INFO() << "Fonts install disabled."; + emit installSkipped(false); + } +} + +void SelectiveInstallWidget::installVoicefile(void) +{ + if(ui.voiceCheckbox->isChecked()) { + LOG_INFO() << "installing Voice file"; + QString lang = ui.voiceCombobox->currentData().toString(); + RockboxInfo installInfo(m_mountpoint); - QString fontsurl; + QString voiceurl; QString logversion; QString relversion = installInfo.release(); - if(relversion.isEmpty()) { + if(m_buildtype == "release") { // release is empty for non-release versions (i.e. daily / current) - fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildDaily).toString(); + voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, SystemInfo::BuildRelease).toString(); } else { - fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildRelease).toString(); + voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, SystemInfo::BuildDaily).toString(); logversion = installInfo.release(); } - fontsurl.replace("%RELEASEVER%", relversion); + voiceurl.replace("%RELVERSION%", m_versions[m_buildtype]); + voiceurl.replace("%MODEL%", m_target); + voiceurl.replace("%LANGUAGE%", lang); + + LOG_INFO() << "voicurl" << voiceurl; // create new zip installer if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); m_zipinstaller = new ZipInstaller(this); - m_zipinstaller->setUrl(fontsurl); - m_zipinstaller->setLogSection("Fonts"); + m_zipinstaller->setUrl(voiceurl); + m_zipinstaller->setLogSection("Voice (" + lang + ")"); m_zipinstaller->setLogVersion(logversion); m_zipinstaller->setMountPoint(m_mountpoint); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) @@ -453,7 +532,7 @@ void SelectiveInstallWidget::installFonts(void) m_zipinstaller->install(); } else { - LOG_INFO() << "Fonts install disabled."; + LOG_INFO() << "Voice install disabled."; emit installSkipped(false); } } diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.h b/rbutil/rbutilqt/gui/selectiveinstallwidget.h index 799829e066..ac07e24ab8 100644 --- a/rbutil/rbutilqt/gui/selectiveinstallwidget.h +++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.h @@ -41,6 +41,7 @@ class SelectiveInstallWidget : public QWidget void installBootloader(void); void installRockbox(void); void installFonts(void); + void installVoicefile(void); void installThemes(void); void installGamefiles(void); void installBootloaderPost(void); @@ -62,6 +63,7 @@ class SelectiveInstallWidget : public QWidget ZipInstaller *m_zipinstaller; QMap m_versions; ThemesInstallWindow *m_themesinstaller; + QString m_buildtype; }; #endif diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidgetfrm.ui b/rbutil/rbutilqt/gui/selectiveinstallwidgetfrm.ui index 5e7fe54ffe..a5bb023f2e 100644 --- a/rbutil/rbutilqt/gui/selectiveinstallwidgetfrm.ui +++ b/rbutil/rbutilqt/gui/selectiveinstallwidgetfrm.ui @@ -7,7 +7,7 @@ 0 0 663 - 369 + 399 @@ -54,22 +54,22 @@ Rockbox components to install - - + + - &Bootloader + &Rockbox - :/icons/preferences-system.svg:/icons/preferences-system.svg + :/icons/multimedia-player.svg:/icons/multimedia-player.svg true - - + + 0 @@ -77,13 +77,51 @@ - The main Rockbox firmware. + The bootloader is required for starting Rockbox. Only necessary for first time install. true + + + + Themes + + + + :/icons/preferences-desktop-theme.svg:/icons/preferences-desktop-theme.svg + + + + + + + Customize + + + + :/icons/preferences-system.svg:/icons/preferences-system.svg + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 1 + 1 + + + + @@ -98,22 +136,19 @@ - - + + - &Rockbox + Game Files - :/icons/multimedia-player.svg:/icons/multimedia-player.svg - - - true + :/icons/input-gaming.svg:/icons/input-gaming.svg - - + + 0 @@ -121,7 +156,7 @@ - Some game plugins require additional files. + Themes allow adjusting the user interface of Rockbox. Use "Customize" to select themes. true @@ -144,8 +179,8 @@ - - + + 0 @@ -153,77 +188,63 @@ - The bootloader is required for starting Rockbox. Only necessary for first time install. + Some game plugins require additional files. true - - + + + + + 0 + 0 + + - Game Files + The main Rockbox firmware. - - - :/icons/input-gaming.svg:/icons/input-gaming.svg + + true - - + + - Customize + &Bootloader :/icons/preferences-system.svg:/icons/preferences-system.svg + + true + - - + + - Themes + &Voice File - :/icons/preferences-desktop-theme.svg:/icons/preferences-desktop-theme.svg + :/icons/audio-volume-high.svg:/icons/audio-volume-high.svg - - - - - 0 - 0 - - + + - Themes allow adjusting the user interface of Rockbox. Use "Customize" to select themes. - - - true + Install prerendered voice file. - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 1 - 1 - - - + + diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index e0d60e797e..f680a15fe2 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini @@ -22,7 +22,7 @@ download_url=http://download.rockbox.org/bootloader [release] build_url=https://download.rockbox.org/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip -voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip +voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-%LANGUAGE%.zip font_url=https://download.rockbox.org/release/%RELEASEVER%/rockbox-fonts-%RELEASEVER%.zip manual_url=https://download.rockbox.org/release/%RELEASEVER%/rockbox-%MODEL%%FORMAT% @@ -34,14 +34,15 @@ manual_url=https://download.rockbox.org/release-candidate/%RELEASEVER%/rockbox-% [development] build_url=http://build.rockbox.org/data/rockbox-%MODEL%.zip -voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip +; we don't have voices for dev builds. +voice_url=https://download.rockbox.org/daily/voices/%MODEL%-%LANGUAGE%.zip font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip ; manual is only built daily, use that one instead. manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT% [daily] build_url=https://download.rockbox.org/daily/%MODEL%/rockbox-%MODEL%.zip -voice_url=https://download.rockbox.org/daily/voices/%MODEL%-%VERSION%-%LANGUAGE%.zip +voice_url=https://download.rockbox.org/daily/voices/%MODEL%-%LANGUAGE%.zip font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT% diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 597509cc78..d996eddfe1 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -496,6 +496,7 @@ void RbUtilQt::installVoice() // replace placeholder in voice url voiceurl.replace("%MODEL%", model); voiceurl.replace("%RELVERSION%", relversion); + voiceurl.replace("%LANGUAGE%", "english"); LOG_INFO() << "voicefile URL:" << voiceurl; -- cgit v1.2.3