1
0
Fork 0
forked from len0rd/rockbox

Completely rework RbSettings class.

- use a single member function for accessing a settings value.
- use an enum to figure the correct value in the settings file instead of functions.
- return the settings value as QVariant instead and leave converting to the caller.
- accept QVariant as value when setting values.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20823 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2009-04-29 20:58:47 +00:00
parent 3c5e67516b
commit 3d2e42ab4c
16 changed files with 557 additions and 840 deletions

View file

@ -401,12 +401,13 @@ QString Detect::check(RbSettings* settings, bool permission)
} }
// Check TargetId // Check TargetId
QString installed = installedTarget(settings->mountpoint()); QString installed = installedTarget(settings->value(RbSettings::Mountpoint).toString());
if(!installed.isEmpty() && installed != settings->curConfigure_Modelname()) if(!installed.isEmpty() && installed != settings->value(RbSettings::CurConfigureModel).toString())
{ {
text += QObject::tr("<li>Target mismatch detected.\n" text += QObject::tr("<li>Target mismatch detected.\n"
"Installed target: %1, selected target: %2.</li>") "Installed target: %1, selected target: %2.</li>")
.arg(installed, settings->curName()); .arg(installed, settings->value(RbSettings::CurPlatformName).toString());
// FIXME: replace installed by human-friendly name
} }
if(!text.isEmpty()) if(!text.isEmpty())

View file

@ -103,20 +103,20 @@ void Config::accept()
proxy.setPort(ui.proxyPort->text().toInt()); proxy.setPort(ui.proxyPort->text().toInt());
} }
settings->setProxy(proxy.toString()); settings->setValue(RbSettings::Proxy, proxy.toString());
qDebug() << "new proxy:" << proxy; qDebug() << "new proxy:" << proxy;
// proxy type // proxy type
QString proxyType; QString proxyType;
if(ui.radioNoProxy->isChecked()) proxyType = "none"; if(ui.radioNoProxy->isChecked()) proxyType = "none";
else if(ui.radioSystemProxy->isChecked()) proxyType = "system"; else if(ui.radioSystemProxy->isChecked()) proxyType = "system";
else proxyType = "manual"; else proxyType = "manual";
settings->setProxyType(proxyType); settings->setValue(RbSettings::ProxyType, proxyType);
// language // language
if(settings->curLang() != language && !language.isEmpty()) { if(settings->value(RbSettings::Language).toString() != language && !language.isEmpty()) {
QMessageBox::information(this, tr("Language changed"), QMessageBox::information(this, tr("Language changed"),
tr("You need to restart the application for the changed language to take effect.")); tr("You need to restart the application for the changed language to take effect."));
settings->setLang(language); settings->setValue(RbSettings::Language, language);
} }
// mountpoint // mountpoint
@ -138,14 +138,14 @@ void Config::accept()
error = true; error = true;
} }
else { else {
settings->setMountpoint(QDir::fromNativeSeparators(mp)); settings->setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp));
} }
// platform // platform
QString nplat; QString nplat;
if(ui.treeDevices->selectedItems().size() != 0) { if(ui.treeDevices->selectedItems().size() != 0) {
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
settings->setCurPlatform(nplat); settings->setValue(RbSettings::Platform, nplat);
} }
else { else {
errormsg += "<li>" + tr("No player selected") + "</li>"; errormsg += "<li>" + tr("No player selected") + "</li>";
@ -160,18 +160,18 @@ void Config::accept()
error = true; error = true;
} }
else else
settings->setCachePath(ui.cachePath->text()); settings->setValue(RbSettings::CachePath, ui.cachePath->text());
} }
else // default to system temp path else // default to system temp path
settings->setCachePath(QDir::tempPath()); settings->setValue(RbSettings::CachePath, QDir::tempPath());
settings->setCacheDisable(ui.cacheDisable->isChecked()); settings->setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked());
settings->setCacheOffline(ui.cacheOfflineMode->isChecked()); settings->setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked());
// tts settings // tts settings
int i = ui.comboTts->currentIndex(); int i = ui.comboTts->currentIndex();
settings->setCurTTS(ui.comboTts->itemData(i).toString()); settings->setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString());
settings->setCurVersion(PUREVERSION); settings->setValue(RbSettings::RbutilVersion, PUREVERSION);
errormsg += "</ul>"; errormsg += "</ul>";
errormsg += tr("You need to fix the above errors before you can continue."); errormsg += tr("You need to fix the above errors before you can continue.");
@ -205,7 +205,7 @@ void Config::setSettings(RbSettings* sett)
void Config::setUserSettings() void Config::setUserSettings()
{ {
// set proxy // set proxy
proxy = settings->proxy(); proxy = settings->value(RbSettings::Proxy).toString();
if(proxy.port() > 0) if(proxy.port() > 0)
ui.proxyPort->setText(QString("%1").arg(proxy.port())); ui.proxyPort->setText(QString("%1").arg(proxy.port()));
@ -214,7 +214,7 @@ void Config::setUserSettings()
ui.proxyUser->setText(proxy.userName()); ui.proxyUser->setText(proxy.userName());
ui.proxyPass->setText(proxy.password()); ui.proxyPass->setText(proxy.password());
QString proxyType = settings->proxyType(); QString proxyType = settings->value(RbSettings::ProxyType).toString();
if(proxyType == "manual") ui.radioManualProxy->setChecked(true); if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true); else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
else ui.radioNoProxy->setChecked(true); else ui.radioNoProxy->setChecked(true);
@ -224,12 +224,15 @@ void Config::setUserSettings()
QString b; QString b;
// find key for lang value // find key for lang value
QMap<QString, QString>::const_iterator i = lang.constBegin(); QMap<QString, QString>::const_iterator i = lang.constBegin();
QString l = settings->value(RbSettings::Language).toString();
if(l.isEmpty())
l = QLocale::system().name();
while (i != lang.constEnd()) { while (i != lang.constEnd()) {
if(i.value() == settings->curLang()) { if(i.value() == l) {
b = i.key(); b = i.key();
break; break;
} }
else if(settings->curLang().startsWith(i.value(), Qt::CaseInsensitive)) { else if(l.startsWith(i.value(), Qt::CaseInsensitive)) {
// check if there is a base language (en -> en_US, etc.) // check if there is a base language (en -> en_US, etc.)
b = i.key(); b = i.key();
break; break;
@ -244,15 +247,15 @@ void Config::setUserSettings()
connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
// devices tab // devices tab
ui.mountPoint->setText(QDir::toNativeSeparators(settings->mountpoint())); ui.mountPoint->setText(QDir::toNativeSeparators(settings->value(RbSettings::Mountpoint).toString()));
// cache tab // cache tab
if(!QFileInfo(settings->cachePath()).isDir()) if(!QFileInfo(settings->value(RbSettings::CachePath).toString()).isDir())
settings->setCachePath(QDir::tempPath()); settings->setValue(RbSettings::CachePath, QDir::tempPath());
ui.cachePath->setText(QDir::toNativeSeparators(settings->cachePath())); ui.cachePath->setText(QDir::toNativeSeparators(settings->value(RbSettings::CachePath).toString()));
ui.cacheDisable->setChecked(settings->cacheDisabled()); ui.cacheDisable->setChecked(settings->value(RbSettings::CacheDisabled).toBool());
ui.cacheOfflineMode->setChecked(settings->cacheOffline()); ui.cacheOfflineMode->setChecked(settings->value(RbSettings::CacheOffline).toBool());
updateCacheInfo(settings->cachePath()); updateCacheInfo(settings->value(RbSettings::CachePath).toString());
} }
@ -276,7 +279,7 @@ void Config::setDevices()
// setup devices table // setup devices table
qDebug() << "Config::setDevices()"; qDebug() << "Config::setDevices()";
QStringList platformList = settings->allPlatforms(); QStringList platformList = settings->platforms();
QMap <QString, QString> manuf; QMap <QString, QString> manuf;
QMap <QString, QString> devcs; QMap <QString, QString> devcs;
@ -289,7 +292,7 @@ void Config::setDevices()
} }
QString platform; QString platform;
platform = devcs.value(settings->curPlatform()); platform = devcs.value(settings->value(RbSettings::Platform).toString());
// set up devices table // set up devices table
ui.treeDevices->header()->hide(); ui.treeDevices->header()->hide();
@ -342,7 +345,7 @@ void Config::setDevices()
for(int a = 0; a < ttslist.size(); a++) for(int a = 0; a < ttslist.size(); a++)
ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a)); ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a));
//update index of combobox //update index of combobox
int index = ui.comboTts->findData(settings->curTTS()); int index = ui.comboTts->findData(settings->value(RbSettings::Tts).toString());
if(index < 0) index = 0; if(index < 0) index = 0;
ui.comboTts->setCurrentIndex(index); ui.comboTts->setCurrentIndex(index);
updateTtsState(index); updateTtsState(index);
@ -377,11 +380,11 @@ void Config::updateEncState()
return; return;
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
QString olddevice = settings->curPlatform(); QString olddevice = settings->value(RbSettings::Platform).toString();
settings->setCurPlatform(devname); settings->setValue(RbSettings::Platform, devname);
QString encoder = settings->curEncoder(); QString encoder = settings->value(RbSettings::CurEncoder).toString();
ui.encoderName->setText(EncBase::getEncoderName(settings->curEncoder())); ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
settings->setCurPlatform(olddevice); settings->setValue(RbSettings::Platform, olddevice);
EncBase* enc = EncBase::getEncoder(encoder); EncBase* enc = EncBase::getEncoder(encoder);
enc->setCfg(settings); enc->setCfg(settings);
@ -597,9 +600,10 @@ void Config::autodetect()
QString text; QString text;
// we need to set the platform here to get the brand from the // we need to set the platform here to get the brand from the
// settings object // settings object
settings->setCurPlatform(detector.incompatdev()); settings->setValue(RbSettings::Platform, detector.incompatdev());
text = tr("Detected an unsupported %1 player variant. Sorry, " text = tr("Detected an unsupported %1 player variant. Sorry, "
"Rockbox doesn't run on your player.").arg(settings->curBrand()); "Rockbox doesn't run on your player.")
.arg(settings->value(RbSettings::CurBrand).toString());
QMessageBox::critical(this, tr("Fatal error: incompatible player found"), QMessageBox::critical(this, tr("Fatal error: incompatible player found"),
text, QMessageBox::Ok); text, QMessageBox::Ok);
@ -655,7 +659,7 @@ void Config::cacheClear()
QFile::remove(f); QFile::remove(f);
qDebug() << "removed:" << f; qDebug() << "removed:" << f;
} }
updateCacheInfo(settings->cachePath()); updateCacheInfo(settings->value(RbSettings::CachePath).toString());
} }
@ -672,7 +676,7 @@ void Config::configTts()
void Config::configEnc() void Config::configEnc()
{ {
EncBase* enc = EncBase::getEncoder(settings->curEncoder()); EncBase* enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
enc->setCfg(settings); enc->setCfg(settings);
enc->showCfg(); enc->showCfg();

View file

@ -49,14 +49,14 @@ void CreateVoiceWindow::accept()
int wvThreshold = ui.wavtrimthreshold->value(); int wvThreshold = ui.wavtrimthreshold->value();
//safe selected language //safe selected language
settings->setVoiceLanguage(lang); settings->setValue(RbSettings::Language, lang);
settings->setWavtrimTh(wvThreshold); settings->setValue(RbSettings::WavtrimThreshold, wvThreshold);
settings->sync(); settings->sync();
//configure voicecreator //configure voicecreator
voicecreator->setSettings(settings); voicecreator->setSettings(settings);
voicecreator->setMountPoint(settings->mountpoint()); voicecreator->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
voicecreator->setTargetId(settings->curTargetId()); voicecreator->setTargetId(settings->value(RbSettings::CurTargetId).toInt());
voicecreator->setLang(lang); voicecreator->setLang(lang);
voicecreator->setWavtrimThreshold(wvThreshold); voicecreator->setWavtrimThreshold(wvThreshold);
@ -79,14 +79,14 @@ void CreateVoiceWindow::setSettings(RbSettings* sett)
void CreateVoiceWindow::updateSettings(void) void CreateVoiceWindow::updateSettings(void)
{ {
// fill in language combobox // fill in language combobox
QStringList languages = settings->allLanguages(); QStringList languages = settings->languages();
languages.sort(); languages.sort();
ui.comboLanguage->addItems(languages); ui.comboLanguage->addItems(languages);
// set saved lang // set saved lang
int sel = ui.comboLanguage->findText(settings->voiceLanguage()); int sel = ui.comboLanguage->findText(settings->value(RbSettings::VoiceLanguage).toString());
// if no saved language is found try to figure the language from the UI lang // if no saved language is found try to figure the language from the UI lang
if(sel == -1) { if(sel == -1) {
QString f = settings->curLang(); QString f = settings->value(RbSettings::Language).toString();
// if no language is set default to english. Make sure not to check an empty string. // if no language is set default to english. Make sure not to check an empty string.
if(f.isEmpty()) f = "english"; if(f.isEmpty()) f = "english";
sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith); sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith);
@ -97,7 +97,7 @@ void CreateVoiceWindow::updateSettings(void)
} }
ui.comboLanguage->setCurrentIndex(sel); ui.comboLanguage->setCurrentIndex(sel);
QString ttsName = settings->curTTS(); QString ttsName = settings->value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(ttsName); TTSBase* tts = TTSBase::getTTS(ttsName);
tts->setCfg(settings); tts->setCfg(settings);
if(tts->configOk()) if(tts->configOk())
@ -107,7 +107,7 @@ void CreateVoiceWindow::updateSettings(void)
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
.arg("Invalid TTS configuration!")); .arg("Invalid TTS configuration!"));
QString encoder = settings->curEncoder(); QString encoder = settings->value(RbSettings::CurEncoder).toString();
// only proceed if encoder setting is set // only proceed if encoder setting is set
EncBase* enc = EncBase::getEncoder(encoder); EncBase* enc = EncBase::getEncoder(encoder);
if(enc != NULL) { if(enc != NULL) {
@ -122,7 +122,7 @@ void CreateVoiceWindow::updateSettings(void)
else else
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>") ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!")); .arg("Invalid encoder configuration!"));
ui.wavtrimthreshold->setValue(settings->wavtrimTh()); ui.wavtrimthreshold->setValue(settings->value(RbSettings::WavtrimThreshold).toInt());
emit settingsUpdated(); emit settingsUpdated();
} }

View file

@ -56,7 +56,7 @@ EncBase* EncBase::getEncoder(QString encoder)
return encoderCache.value(encoder); return encoderCache.value(encoder);
EncBase* enc; EncBase* enc;
if(encoder == "lame") if(encoder == "lame")
{ {
enc = new EncExes(encoder); enc = new EncExes(encoder);
encoderCache[encoder] = enc; encoderCache[encoder] = enc;
@ -99,8 +99,8 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
bool EncExes::start() bool EncExes::start()
{ {
m_EncExec = settings->encoderPath(m_name); m_EncExec = settings->subValue(m_name, RbSettings::EncoderPath).toString();
m_EncOpts = settings->encoderOptions(m_name); m_EncOpts = settings->subValue(m_name, RbSettings::EncoderOptions).toString();
m_EncTemplate = m_TemplateMap.value(m_name); m_EncTemplate = m_TemplateMap.value(m_name);
@ -144,7 +144,7 @@ void EncExes::showCfg()
bool EncExes::configOk() bool EncExes::configOk()
{ {
QString path = settings->encoderPath(m_name); QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
if (QFileInfo(path).exists()) if (QFileInfo(path).exists())
return true; return true;
@ -171,10 +171,10 @@ bool EncRbSpeex::start()
{ {
// try to get config from settings // try to get config from settings
quality = settings->encoderQuality("rbspeex"); quality = settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble();
complexity = settings->encoderComplexity("rbspeex"); complexity = settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt();
volume = settings->encoderVolume("rbspeex"); volume = settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble();
narrowband = settings->encoderNarrowband("rbspeex"); narrowband = settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool();
return true; return true;
@ -227,13 +227,13 @@ bool EncRbSpeex::configOk()
bool result=true; bool result=true;
// check config // check config
if(settings->encoderVolume("rbspeex") <= 0) if(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
result =false; result =false;
if(settings->encoderQuality("rbspeex") <= 0) if(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
result =false; result =false;
if(settings->encoderComplexity("rbspeex") <= 0) if(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
result =false; result =false;
return result; return result;

View file

@ -34,8 +34,8 @@ void EncExesGui::showCfg(QString name)
{ {
m_name = name; m_name = name;
// try to get config from settings // try to get config from settings
QString exepath =settings->encoderPath(m_name); QString exepath =settings->subValue(m_name, RbSettings::EncoderPath).toString();
ui.encoderoptions->setText(settings->encoderOptions(m_name)); ui.encoderoptions->setText(settings->subValue(m_name, RbSettings::EncoderOptions).toString());
if(exepath == "") if(exepath == "")
{ {
@ -75,8 +75,8 @@ void EncExesGui::showCfg(QString name)
void EncExesGui::accept(void) void EncExesGui::accept(void)
{ {
//save settings in user config //save settings in user config
settings->setEncoderPath(m_name,ui.encoderpath->text()); settings->setSubValue(m_name, RbSettings::EncoderPath, ui.encoderpath->text());
settings->setEncoderOptions(m_name,ui.encoderoptions->text()); settings->setSubValue(m_name, RbSettings::EncoderOptions, ui.encoderoptions->text());
// sync settings // sync settings
settings->sync(); settings->sync();
@ -130,11 +130,11 @@ void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
defaultBand =defB; defaultBand =defB;
//fill in the usersettings //fill in the usersettings
ui.volume->setValue(settings->encoderVolume("rbspeex")); ui.volume->setValue(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble());
ui.quality->setValue(settings->encoderQuality("rbspeex")); ui.quality->setValue(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble());
ui.complexity->setValue(settings->encoderComplexity("rbspeex")); ui.complexity->setValue(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt());
if(settings->encoderNarrowband("rbspeex")) if(settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool())
ui.narrowband->setCheckState(Qt::Checked); ui.narrowband->setCheckState(Qt::Checked);
else else
ui.narrowband->setCheckState(Qt::Unchecked); ui.narrowband->setCheckState(Qt::Unchecked);
@ -146,10 +146,10 @@ void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
void EncRbSpeexGui::accept(void) void EncRbSpeexGui::accept(void)
{ {
//save settings in user config //save settings in user config
settings->setEncoderVolume("rbspeex",ui.volume->value()); settings->setSubValue("rbspeex", RbSettings::EncoderVolume, ui.volume->value());
settings->setEncoderQuality("rbspeex",ui.quality->value()); settings->setSubValue("rbspeex", RbSettings::EncoderQuality, ui.quality->value());
settings->setEncoderComplexity("rbspeex",ui.complexity->value()); settings->setSubValue("rbspeex", RbSettings::EncoderComplexity, ui.complexity->value());
settings->setEncoderNarrowband("rbspeex",ui.narrowband->isChecked() ? true : false); settings->setSubValue("rbspeex", RbSettings::EncoderNarrowBand, ui.narrowband->isChecked() ? true : false);
// sync settings // sync settings
settings->sync(); settings->sync();

View file

@ -34,12 +34,12 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int))); connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
//! check if rockbox is already installed //! check if rockbox is already installed
QString version = Detect::installedVersion(settings->mountpoint()); QString version = Detect::installedVersion(settings->value(RbSettings::Mountpoint).toString());
if(version != "") if(version != "")
{ {
ui.Backupgroup->show(); ui.Backupgroup->show();
m_backupName = settings->mountpoint(); m_backupName = settings->value(RbSettings::Mountpoint).toString();
if(!m_backupName.endsWith("/")) m_backupName += "/"; if(!m_backupName.endsWith("/")) m_backupName += "/";
m_backupName += ".backup/rockbox-backup-"+version+".zip"; m_backupName += ".backup/rockbox-backup-"+version+".zip";
// for some reason the label doesn't return its final size yet. // for some reason the label doesn't return its final size yet.
@ -91,8 +91,8 @@ void Install::accept()
{ {
logger = new ProgressLoggerGui(this); logger = new ProgressLoggerGui(this);
logger->show(); logger->show();
QString mountPoint = settings->mountpoint(); QString mountPoint = settings->value(RbSettings::Mountpoint).toString();
qDebug() << "mountpoint:" << settings->mountpoint(); qDebug() << "mountpoint:" << settings->value(RbSettings::Mountpoint).toString();
// show dialog with error if mount point is wrong // show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) { if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR); logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@ -101,30 +101,30 @@ void Install::accept()
} }
QString myversion; QString myversion;
QString buildname = settings->curBuildserver_Modelname(); QString buildname = settings->value(RbSettings::CurBuildserverModel).toString();
if(ui.radioStable->isChecked()) { if(ui.radioStable->isChecked()) {
file = QString("%1/%2/rockbox-%3-%4.zip") file = QString("%1/%2/rockbox-%3-%4.zip")
.arg(settings->releaseUrl(), version.value("rel_rev"), .arg(settings->value(RbSettings::ReleaseUrl).toString(), version.value("rel_rev"),
buildname, version.value("rel_rev")); buildname, version.value("rel_rev"));
fileName = QString("rockbox-%1-%2.zip") fileName = QString("rockbox-%1-%2.zip")
.arg(version.value("rel_rev"), buildname); .arg(version.value("rel_rev"), buildname);
settings->setBuild("stable"); settings->setValue(RbSettings::Build, "stable");
myversion = version.value("rel_rev"); myversion = version.value("rel_rev");
} }
else if(ui.radioArchived->isChecked()) { else if(ui.radioArchived->isChecked()) {
file = QString("%1%2/rockbox-%3-%4.zip") file = QString("%1%2/rockbox-%3-%4.zip")
.arg(settings->dailyUrl(), .arg(settings->value(RbSettings::DailyUrl).toString(),
buildname, buildname, version.value("arch_date")); buildname, buildname, version.value("arch_date"));
fileName = QString("rockbox-%1-%2.zip") fileName = QString("rockbox-%1-%2.zip")
.arg(buildname, version.value("arch_date")); .arg(buildname, version.value("arch_date"));
settings->setBuild("archived"); settings->setValue(RbSettings::Build, "archived");
myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date"); myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date");
} }
else if(ui.radioCurrent->isChecked()) { else if(ui.radioCurrent->isChecked()) {
file = QString("%1%2/rockbox.zip") file = QString("%1%2/rockbox.zip")
.arg(settings->bleedingUrl(), buildname); .arg(settings->value(RbSettings::BleedingUrl).toString(), buildname);
fileName = QString("rockbox.zip"); fileName = QString("rockbox.zip");
settings->setBuild("current"); settings->setValue(RbSettings::Build, "current");
myversion = "r" + version.value("bleed_rev"); myversion = "r" + version.value("bleed_rev");
} }
else { else {
@ -162,7 +162,8 @@ void Install::accept()
//! create backup //! create backup
RbZip backup; RbZip backup;
connect(&backup,SIGNAL(zipProgress(int,int)),logger,SLOT(setProgress(int,int))); connect(&backup,SIGNAL(zipProgress(int,int)),logger,SLOT(setProgress(int,int)));
if(backup.createZip(m_backupName,settings->mountpoint() + "/.rockbox") == Zip::Ok) if(backup.createZip(m_backupName,
settings->value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
{ {
logger->addItem(tr("Backup successful"),LOGOK); logger->addItem(tr("Backup successful"),LOGOK);
} }
@ -178,7 +179,7 @@ void Install::accept()
installer = new ZipInstaller(this); installer = new ZipInstaller(this);
installer->setUrl(file); installer->setUrl(file);
installer->setLogSection("Rockbox (Base)"); installer->setLogSection("Rockbox (Base)");
if(!settings->cacheDisabled() if(!settings->value(RbSettings::CacheDisabled).toBool()
&& !ui.checkBoxCache->isChecked()) && !ui.checkBoxCache->isChecked())
{ {
installer->setCache(true); installer->setCache(true);
@ -218,9 +219,9 @@ void Install::done(bool error)
// no error, close the window, when the logger is closed // no error, close the window, when the logger is closed
connect(logger,SIGNAL(closed()),this,SLOT(close())); connect(logger,SIGNAL(closed()),this,SLOT(close()));
// add platform info to log file for later detection // add platform info to log file for later detection
QSettings installlog(settings->mountpoint() QSettings installlog(settings->value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log", QSettings::IniFormat, 0); + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.setValue("platform", settings->curPlatform()); installlog.setValue("platform", settings->value(RbSettings::Platform).toString());
installlog.sync(); installlog.sync();
} }
@ -288,11 +289,12 @@ void Install::setVersionStrings(QMap<QString, QString>& ver)
// try to use the old selection first. If no selection has been made // try to use the old selection first. If no selection has been made
// in the past, use a preselection based on released status. // in the past, use a preselection based on released status.
if(settings->build() == "stable" && !version.value("rel_rev").isEmpty()) if(settings->value(RbSettings::Build).toString() == "stable"
&& !version.value("rel_rev").isEmpty())
ui.radioStable->setChecked(true); ui.radioStable->setChecked(true);
else if(settings->build() == "archived") else if(settings->value(RbSettings::Build).toString() == "archived")
ui.radioArchived->setChecked(true); ui.radioArchived->setChecked(true);
else if(settings->build() == "current") else if(settings->value(RbSettings::Build).toString() == "current")
ui.radioCurrent->setChecked(true); ui.radioCurrent->setChecked(true);
else if(!version.value("rel_rev").isEmpty()) { else if(!version.value("rel_rev").isEmpty()) {
ui.radioStable->setChecked(true); ui.radioStable->setChecked(true);

View file

@ -88,13 +88,13 @@ void InstallTalkWindow::accept()
return; return;
} }
settings->setLastTalkedDir(folderToTalk); settings->setValue(RbSettings::LastTalkedFolder, folderToTalk);
settings->sync(); settings->sync();
talkcreator->setSettings(settings); talkcreator->setSettings(settings);
talkcreator->setDir(QDir(folderToTalk)); talkcreator->setDir(QDir(folderToTalk));
talkcreator->setMountPoint(settings->mountpoint()); talkcreator->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked()); talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
talkcreator->setRecursive(ui.recursive->isChecked()); talkcreator->setRecursive(ui.recursive->isChecked());
@ -115,7 +115,7 @@ void InstallTalkWindow::setSettings(RbSettings* sett)
void InstallTalkWindow::updateSettings(void) void InstallTalkWindow::updateSettings(void)
{ {
QString ttsName = settings->curTTS(); QString ttsName = settings->value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(ttsName); TTSBase* tts = TTSBase::getTTS(ttsName);
tts->setCfg(settings); tts->setCfg(settings);
if(tts->configOk()) if(tts->configOk())
@ -125,7 +125,7 @@ void InstallTalkWindow::updateSettings(void)
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
.arg("Invalid TTS configuration!")); .arg("Invalid TTS configuration!"));
QString encoder = settings->curEncoder(); QString encoder = settings->value(RbSettings::CurEncoder).toString();
EncBase* enc = EncBase::getEncoder(encoder); EncBase* enc = EncBase::getEncoder(encoder);
if(enc != NULL) { if(enc != NULL) {
enc->setCfg(settings); enc->setCfg(settings);
@ -140,7 +140,7 @@ void InstallTalkWindow::updateSettings(void)
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>") ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!")); .arg("Invalid encoder configuration!"));
setTalkFolder(settings->lastTalkedFolder()); setTalkFolder(settings->value(RbSettings::LastTalkedFolder).toString());
emit settingsUpdated(); emit settingsUpdated();
} }

View file

@ -25,10 +25,79 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
// device settings
const static struct {
RbSettings::SystemSettings setting;
const char* name;
const char* def;
} SystemSettingsList[] = {
{ RbSettings::ManualUrl, "manual_url", "" },
{ RbSettings::BleedingUrl, "bleeding_url", "" },
{ RbSettings::BootloaderUrl, "bootloader_url", "" },
{ RbSettings::BootloaderInfoUrl, "bootloader_info_url", "" },
{ RbSettings::FontUrl, "font_url", "" },
{ RbSettings::VoiceUrl, "voice_url", "" },
{ RbSettings::DoomUrl, "doom_url", "" },
{ RbSettings::ReleaseUrl, "release_url", "" },
{ RbSettings::DailyUrl, "daily_url", "" },
{ RbSettings::ServerConfUrl, "server_conf_url", "" },
{ RbSettings::GenlangUrl, "genlang_url", "" },
{ RbSettings::ThemesUrl, "themes_url", "" },
{ RbSettings::BleedingInfo, "bleeding_info", "" },
{ RbSettings::CurPlatformName, ":platform:/name", "" },
{ RbSettings::CurManual, ":platform:/manual", "rockbox-:platform:" },
{ RbSettings::CurBootloaderMethod, ":platform:/bootloadermethod", "none" },
{ RbSettings::CurBootloaderName, ":platform:/bootloadername", "" },
{ RbSettings::CurBootloaderFile, ":platform:/bootloaderfile", "" },
{ RbSettings::CurEncoder, ":platform:/encoder", "" },
{ RbSettings::CurResolution, ":platform:/resolution", "" },
{ RbSettings::CurBrand, ":platform:/brand", "" },
{ RbSettings::CurName, ":platform:/name", "" },
{ RbSettings::CurBuildserverModel, ":platform:/buildserver_modelname", "" },
{ RbSettings::CurConfigureModel, ":platform:/configure_modelname", "" },
{ RbSettings::CurTargetId, ":platform:/targetid", "" },
};
// user settings
const static struct {
RbSettings::UserSettings setting;
const char* name;
const char* def;
} UserSettingsList[] = {
{ RbSettings::RbutilVersion, "rbutil_version", "" },
{ RbSettings::CurrentPlatform, "platform", "" },
{ RbSettings::Mountpoint, "mountpoint", "" },
{ RbSettings::CachePath, "cachepath", "" },
{ RbSettings::Build, "build", "" },
{ RbSettings::ProxyType, "proxytype", "" },
{ RbSettings::Proxy, "proxy", "" },
{ RbSettings::OfPath, "ofpath", "" },
{ RbSettings::Platform, "platform", "" },
{ RbSettings::Language, "lang", "" },
{ RbSettings::Tts, "tts", "" },
{ RbSettings::LastTalkedFolder, "last_talked_folder", "" },
{ RbSettings::VoiceLanguage, "voicelanguage", "" },
{ RbSettings::TtsLanguage, ":tts:/language", "" },
{ RbSettings::TtsOptions, ":tts:/options", "" },
{ RbSettings::TtsPath, ":tts:/path", "" },
{ RbSettings::TtsVoice, ":tts:/voice", "" },
{ RbSettings::EncoderPath, ":encoder:/encoderpath", "" },
{ RbSettings::EncoderOptions, ":encoder:/encoderoptions", "" },
{ RbSettings::CacheOffline, "offline", "false" },
{ RbSettings::CacheDisabled, "cachedisable", "false" },
{ RbSettings::TtsUseSapi4, "sapi/useSapi4", "false" },
{ RbSettings::EncoderNarrowBand, ":encoder:/narrowband", "false" },
{ RbSettings::WavtrimThreshold, "wavtrimthreshold", "500"},
{ RbSettings::TtsSpeed, ":tts:/speed", "0" },
{ RbSettings::EncoderComplexity, ":encoder:/complexity", "10" },
{ RbSettings::EncoderQuality, ":encoder:/quality", "8.0" },
{ RbSettings::EncoderVolume, ":encoder:/volume", "1.0" },
};
void RbSettings::open() void RbSettings::open()
{ {
// only use built-in rbutil.ini // only use built-in rbutil.ini
devices = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0); systemSettings = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
// portable installation: // portable installation:
// check for a configuration file in the program folder. // check for a configuration file in the program folder.
QFileInfo config; QFileInfo config;
@ -74,331 +143,99 @@ void RbSettings::sync()
#endif #endif
} }
QVariant RbSettings::deviceSettingCurGet(QString entry,QString def)
QVariant RbSettings::value(enum SystemSettings setting)
{ {
QString platform = userSettings->value("platform").toString(); // locate setting item
devices->beginGroup(platform); int i = 0;
QVariant result = devices->value(entry,def); while(SystemSettingsList[i].setting != setting)
devices->endGroup(); i++;
return result;
QString s = constructSettingPath(SystemSettingsList[i].name);
QString d = SystemSettingsList[i].def;
d.replace(":platform:", userSettings->value("platform").toString());
qDebug() << "[Settings] GET S:" << s << systemSettings->value(s, d).toString();
return systemSettings->value(s, d);
} }
QVariant RbSettings::userSettingsGroupGet(QString group,QString entry,QVariant def)
{
userSettings->beginGroup(group);
QVariant result = userSettings->value(entry,def);
userSettings->endGroup();
return result;
}
void RbSettings::userSettingsGroupSet(QString group,QString entry,QVariant value)
{
userSettings->beginGroup(group);
userSettings->setValue(entry,value);
userSettings->endGroup();
}
QString RbSettings::userSettingFilename() QString RbSettings::userSettingFilename()
{ {
return userSettings->fileName(); return userSettings->fileName();
} }
QString RbSettings::curVersion()
QVariant RbSettings::subValue(QString& sub, enum UserSettings setting)
{ {
return userSettings->value("rbutil_version").toString(); // locate setting item
int i = 0;
while(UserSettingsList[i].setting != setting)
i++;
QString s = constructSettingPath(UserSettingsList[i].name, sub);
qDebug() << "[Settings] GET U:" << s << userSettings->value(s).toString();
return userSettings->value(s, UserSettingsList[i].def);
} }
bool RbSettings::cacheOffline()
void RbSettings::setSubValue(QString& sub, enum UserSettings setting, QVariant value)
{ {
return userSettings->value("offline").toBool(); // locate setting item
int i = 0;
while(UserSettingsList[i].setting != setting)
i++;
QString s = constructSettingPath(UserSettingsList[i].name, sub);
qDebug() << "[Settings] SET U:" << s << userSettings->value(s).toString();
userSettings->setValue(s, value);
} }
QString RbSettings::mountpoint()
{
return userSettings->value("mountpoint").toString();
}
QString RbSettings::manualUrl()
{
return devices->value("manual_url").toString();
}
QString RbSettings::bleedingUrl() QStringList RbSettings::platforms()
{
return devices->value("bleeding_url").toString();
}
QString RbSettings::cachePath()
{
return userSettings->value("cachepath", QDir::tempPath()).toString();
}
QString RbSettings::build()
{
return userSettings->value("build").toString();
}
QString RbSettings::bootloaderUrl()
{
return devices->value("bootloader_url").toString();
}
QString RbSettings::bootloaderInfoUrl()
{
return devices->value("bootloader_info_url").toString();
}
QString RbSettings::fontUrl()
{
return devices->value("font_url").toString();
}
QString RbSettings::voiceUrl()
{
return devices->value("voice_url").toString();
}
QString RbSettings::doomUrl()
{
return devices->value("doom_url").toString();
}
QString RbSettings::releaseUrl()
{
return devices->value("release_url").toString();
}
QString RbSettings::dailyUrl()
{
return devices->value("daily_url").toString();
}
QString RbSettings::serverConfUrl()
{
return devices->value("server_conf_url").toString();
}
QString RbSettings::genlangUrl()
{
return devices->value("genlang_url").toString();
}
QString RbSettings::themeUrl()
{
return devices->value("themes_url").toString();
}
QString RbSettings::bleedingInfo()
{
return devices->value("bleeding_info").toString();
}
bool RbSettings::cacheDisabled()
{
return userSettings->value("cachedisable").toBool();
}
QString RbSettings::proxyType()
{
return userSettings->value("proxytype", "none").toString();
}
QString RbSettings::proxy()
{
return userSettings->value("proxy").toString();
}
QString RbSettings::ofPath()
{
return userSettings->value("ofpath").toString();
}
QString RbSettings::curBrand()
{
QString platform = userSettings->value("platform").toString();
return brand(platform);
}
QString RbSettings::curName()
{
QString platform = userSettings->value("platform").toString();
return name(platform);
}
QString RbSettings::curPlatform()
{
return userSettings->value("platform").toString();
}
QString RbSettings::curBuildserver_Modelname()
{
return deviceSettingCurGet("buildserver_modelname").toString();
}
QString RbSettings::curManual()
{
return deviceSettingCurGet("manualname","rockbox-" +
devices->value("platform").toString()).toString();
}
QString RbSettings::curBootloaderMethod()
{
return deviceSettingCurGet("bootloadermethod", "none").toString();
}
QString RbSettings::curBootloaderName()
{
return deviceSettingCurGet("bootloadername").toString();
}
QString RbSettings::curBootloaderFile()
{
return deviceSettingCurGet("bootloaderfile").toString();
}
QString RbSettings::curConfigure_Modelname()
{
return deviceSettingCurGet("configure_modelname").toString();
}
QString RbSettings::curLang()
{
// QSettings::value only returns the default when the setting
// doesn't exist. Make sure to return the system language if
// the language in the configuration is present but empty too.
QString lang = userSettings->value("lang").toString();
if(lang.isEmpty())
lang = QLocale::system().name();
return lang;
}
QString RbSettings::curEncoder()
{
return deviceSettingCurGet("encoder").toString();
}
QString RbSettings::curTTS()
{
return userSettings->value("tts").toString();
}
QString RbSettings::lastTalkedFolder()
{
return userSettings->value("last_talked_folder").toString();
}
QString RbSettings::voiceLanguage()
{
return userSettings->value("voicelanguage").toString();
}
int RbSettings::wavtrimTh()
{
return userSettings->value("wavtrimthreshold",500).toInt();
}
QString RbSettings::ttsPath(QString tts)
{
return userSettingsGroupGet(tts,"ttspath").toString();
}
QString RbSettings::ttsOptions(QString tts)
{
return userSettingsGroupGet(tts,"ttsoptions").toString();
}
QString RbSettings::ttsVoice(QString tts)
{
return userSettingsGroupGet(tts,"ttsvoice","Microsoft Sam").toString();
}
int RbSettings::ttsSpeed(QString tts)
{
return userSettingsGroupGet(tts,"ttsspeed",0).toInt();
}
QString RbSettings::ttsLang(QString tts)
{
return userSettingsGroupGet(tts,"ttslanguage","english").toString();
}
bool RbSettings::ttsUseSapi4()
{
return userSettingsGroupGet("sapi","useSapi4",false).toBool();
}
QString RbSettings::encoderPath(QString enc)
{
return userSettingsGroupGet(enc,"encoderpath").toString();
}
QString RbSettings::encoderOptions(QString enc)
{
return userSettingsGroupGet(enc,"encoderoptions").toString();
}
double RbSettings::encoderQuality(QString enc)
{
return userSettingsGroupGet(enc,"quality",8.f).toDouble();
}
int RbSettings::encoderComplexity(QString enc)
{
return userSettingsGroupGet(enc,"complexity",10).toInt();
}
double RbSettings::encoderVolume(QString enc)
{
return userSettingsGroupGet(enc,"volume",1.f).toDouble();
}
bool RbSettings::encoderNarrowband(QString enc)
{
return userSettingsGroupGet(enc,"narrowband",false).toBool();
}
QStringList RbSettings::allPlatforms()
{ {
QStringList result; QStringList result;
devices->beginGroup("platforms"); systemSettings->beginGroup("platforms");
QStringList a = devices->childKeys(); QStringList a = systemSettings->childKeys();
for(int i = 0; i < a.size(); i++) for(int i = 0; i < a.size(); i++)
{ {
result.append(devices->value(a.at(i), "null").toString()); result.append(systemSettings->value(a.at(i), "null").toString());
} }
devices->endGroup(); systemSettings->endGroup();
return result; return result;
} }
QStringList RbSettings::allLanguages() QStringList RbSettings::languages()
{ {
QStringList result; QStringList result;
devices->beginGroup("languages"); systemSettings->beginGroup("languages");
QStringList a = devices->childKeys(); QStringList a = systemSettings->childKeys();
for(int i = 0; i < a.size(); i++) for(int i = 0; i < a.size(); i++)
{ {
result.append(devices->value(a.at(i), "null").toString()); result.append(systemSettings->value(a.at(i), "null").toString());
} }
devices->endGroup(); systemSettings->endGroup();
return result; return result;
} }
QString RbSettings::name(QString plattform) QString RbSettings::name(QString platform)
{ {
devices->beginGroup(plattform); return systemSettings->value(platform + "/name").toString();
QString name = devices->value("name").toString();
devices->endGroup();
return name;
} }
QString RbSettings::brand(QString plattform) QString RbSettings::brand(QString platform)
{ {
devices->beginGroup(plattform); return systemSettings->value(platform + "/brand").toString();
QString brand = devices->value("brand").toString();
devices->endGroup();
return brand;
} }
QMap<int, QString> RbSettings::usbIdMap(enum MapType type) QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
{ {
QMap<int, QString> map; QMap<int, QString> map;
// get a list of ID -> target name // get a list of ID -> target name
QStringList platforms; QStringList platforms;
devices->beginGroup("platforms"); systemSettings->beginGroup("platforms");
platforms = devices->childKeys(); platforms = systemSettings->childKeys();
devices->endGroup(); systemSettings->endGroup();
QString t; QString t;
switch(type) { switch(type) {
@ -415,161 +252,34 @@ QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
for(int i = 0; i < platforms.size(); i++) for(int i = 0; i < platforms.size(); i++)
{ {
devices->beginGroup("platforms"); systemSettings->beginGroup("platforms");
QString target = devices->value(platforms.at(i)).toString(); QString target = systemSettings->value(platforms.at(i)).toString();
devices->endGroup(); systemSettings->endGroup();
devices->beginGroup(target); systemSettings->beginGroup(target);
QStringList ids = devices->value(t).toStringList(); QStringList ids = systemSettings->value(t).toStringList();
int j = ids.size(); int j = ids.size();
while(j--) while(j--)
map.insert(ids.at(j).toInt(0, 16), target); map.insert(ids.at(j).toInt(0, 16), target);
devices->endGroup(); systemSettings->endGroup();
} }
return map; return map;
} }
QString RbSettings::curResolution() QString RbSettings::constructSettingPath(QString path, QString substitute)
{ {
return deviceSettingCurGet("resolution").toString(); QString platform = userSettings->value("platform").toString();
} if(!substitute.isEmpty()) {
path.replace(":tts:", substitute);
int RbSettings::curTargetId() path.replace(":encoder:", substitute);
{ }
return deviceSettingCurGet("targetid").toInt(); else {
} path.replace(":tts:", userSettings->value("tts").toString());
path.replace(":encoder:", systemSettings->value(platform + "/encoder").toString());
void RbSettings::setCurVersion(QString version) }
{ path.replace(":platform:", platform);
userSettings->setValue("rbutil_version",version);
} return path;
void RbSettings::setOfPath(QString path)
{
userSettings->setValue("ofpath",path);
}
void RbSettings::setCachePath(QString path)
{
userSettings->setValue("cachepath", path);
}
void RbSettings::setBuild(QString build)
{
userSettings->setValue("build", build);
}
void RbSettings::setLastTalkedDir(QString dir)
{
userSettings->setValue("last_talked_folder", dir);
}
void RbSettings::setVoiceLanguage(QString dir)
{
userSettings->setValue("voicelanguage", dir);
}
void RbSettings::setWavtrimTh(int th)
{
userSettings->setValue("wavtrimthreshold", th);
}
void RbSettings::setProxy(QString proxy)
{
userSettings->setValue("proxy", proxy);
}
void RbSettings::setProxyType(QString proxytype)
{
userSettings->setValue("proxytype", proxytype);
}
void RbSettings::setLang(QString lang)
{
userSettings->setValue("lang", lang);
}
void RbSettings::setMountpoint(QString mp)
{
userSettings->setValue("mountpoint",mp);
}
void RbSettings::setCurPlatform(QString platt)
{
userSettings->setValue("platform",platt);
}
void RbSettings::setCacheDisable(bool on)
{
userSettings->setValue("cachedisable",on);
}
void RbSettings::setCacheOffline(bool on)
{
userSettings->setValue("offline",on);
}
void RbSettings::setCurTTS(QString tts)
{
userSettings->setValue("tts",tts);
}
void RbSettings::setTTSPath(QString tts, QString path)
{
userSettingsGroupSet(tts,"ttspath",path);
}
void RbSettings::setTTSOptions(QString tts, QString options)
{
userSettingsGroupSet(tts,"ttsoptions",options);
}
void RbSettings::setTTSVoice(QString tts, QString voice)
{
userSettingsGroupSet(tts,"ttsvoice",voice);
}
void RbSettings::setTTSSpeed(QString tts, int speed)
{
userSettingsGroupSet(tts,"ttsspeed",speed);
}
void RbSettings::setTTSLang(QString tts, QString lang)
{
userSettingsGroupSet(tts,"ttslanguage",lang);
}
void RbSettings::setTTSUseSapi4(bool value)
{
userSettingsGroupSet("sapi","useSapi4",value);
}
void RbSettings::setEncoderPath(QString enc, QString path)
{
userSettingsGroupSet(enc,"encoderpath",path);
}
void RbSettings::setEncoderOptions(QString enc, QString options)
{
userSettingsGroupSet(enc,"encoderoptions",options);
}
void RbSettings::setEncoderQuality(QString enc, double q)
{
userSettingsGroupSet(enc,"quality",q);
}
void RbSettings::setEncoderComplexity(QString enc, int c)
{
userSettingsGroupSet(enc,"complexity",c);
}
void RbSettings::setEncoderVolume(QString enc,double v)
{
userSettingsGroupSet(enc,"volume",v);
}
void RbSettings::setEncoderNarrowband(QString enc,bool nb)
{
userSettingsGroupSet(enc,"narrowband",nb);
} }

View file

@ -46,118 +46,97 @@ class RbSettings : public QObject
MapError, MapError,
MapIncompatible, MapIncompatible,
}; };
enum UserSettings {
RbutilVersion,
CurrentPlatform,
Mountpoint,
CachePath,
Build,
ProxyType,
Proxy,
OfPath,
Platform,
Language,
Tts,
LastTalkedFolder,
VoiceLanguage,
TtsLanguage,
TtsOptions,
TtsPath,
TtsVoice,
EncoderPath,
EncoderOptions,
WavtrimThreshold,
EncoderComplexity,
TtsSpeed,
CacheOffline,
CacheDisabled,
TtsUseSapi4,
EncoderNarrowBand,
EncoderQuality,
EncoderVolume,
};
enum SystemSettings {
ManualUrl,
BleedingUrl,
BootloaderUrl,
BootloaderInfoUrl,
FontUrl,
VoiceUrl,
DoomUrl,
ReleaseUrl,
DailyUrl,
ServerConfUrl,
GenlangUrl,
ThemesUrl,
BleedingInfo,
CurPlatformName,
CurManual,
CurBootloaderMethod,
CurBootloaderName,
CurBootloaderFile,
CurEncoder,
CurResolution,
CurBrand,
CurName,
CurBuildserverModel,
CurConfigureModel,
CurTargetId,
};
//! access functions for the settings QVariant value(enum SystemSettings setting);
QString curVersion(); // generic and "current selection" values -- getters
bool cacheOffline(); QVariant value(enum UserSettings setting)
bool cacheDisabled(); { QString empty; return subValue(empty, setting); }
QString mountpoint(); void setValue(enum UserSettings setting , QVariant value)
QString manualUrl(); { QString empty; return setSubValue(empty, setting, value); }
QString bleedingUrl();
QString cachePath();
QString build(void);
QString bootloaderUrl();
QString bootloaderInfoUrl();
QString fontUrl();
QString voiceUrl();
QString doomUrl();
QString releaseUrl();
QString dailyUrl();
QString serverConfUrl();
QString themeUrl();
QString genlangUrl();
QString proxyType();
QString proxy();
QString bleedingInfo();
QString ofPath();
QString lastTalkedFolder();
QString voiceLanguage();
int wavtrimTh();
QString ttsPath(QString tts);
QString ttsOptions(QString tts);
QString ttsVoice(QString tts);
int ttsSpeed(QString tts);
QString ttsLang(QString tts);
bool ttsUseSapi4();
QString encoderPath(QString enc);
QString encoderOptions(QString enc);
double encoderQuality(QString enc);
int encoderComplexity(QString enc);
double encoderVolume(QString enc);
bool encoderNarrowband(QString enc);
QStringList allPlatforms(void); QVariant subValue(QString& sub, enum UserSettings setting);
QStringList allLanguages(void); QVariant subValue(const char* sub, enum UserSettings setting)
{ QString s = sub; return subValue(s, setting); }
void setSubValue(QString& sub, enum UserSettings setting, QVariant value);
void setSubValue(const char* sub, enum UserSettings setting, QVariant value)
{ QString s = sub; return setSubValue(s, setting, value); }
QStringList platforms(void);
QStringList languages(void);
QString name(QString plattform); QString name(QString plattform);
QString brand(QString plattform); QString brand(QString plattform);
QMap<int, QString> usbIdMap(enum MapType); QMap<int, QString> usbIdMap(enum MapType);
QString curBrand();
QString curName();
QString curPlatform(); // rbutil internal target name.
QString curBuildserver_Modelname(); // modelnames used by the buildserver
QString curManual();
QString curBootloaderMethod();
QString curBootloaderName();
QString curConfigure_Modelname(); // modelname from configure (used for themes, voice, rockbox-info comparing.
QString curLang();
QString curEncoder();
QString curTTS();
QString curResolution();
QString curBootloaderFile();
int curTargetId();
//! Set Functions
void setCurVersion(QString version);
void setOfPath(QString path);
void setCachePath(QString path);
void setBuild(QString build);
void setLastTalkedDir(QString dir);
void setVoiceLanguage(QString lang);
void setWavtrimTh(int th);
void setProxy(QString proxy);
void setProxyType(QString proxytype);
void setLang(QString lang);
void setMountpoint(QString mp);
void setCurPlatform(QString platt);
void setCacheDisable(bool on);
void setCacheOffline(bool on);
void setCurTTS(QString tts);
void setTTSPath(QString tts, QString path);
void setTTSOptions(QString tts, QString options);
void setTTSSpeed(QString tts, int speed);
void setTTSVoice(QString tts, QString voice);
void setTTSLang(QString tts, QString lang);
void setTTSUseSapi4(bool value);
void setEncoderPath(QString enc, QString path);
void setEncoderOptions(QString enc, QString options);
void setEncoderQuality(QString enc, double q);
void setEncoderComplexity(QString enc, int c);
void setEncoderVolume(QString enc,double v);
void setEncoderNarrowband(QString enc,bool nb);
private: private:
//! helper function to get an entry in the current platform section
QVariant deviceSettingCurGet(QString entry,QString def="");
//! helper function to get an entry out of a group in the userSettings
QVariant userSettingsGroupGet(QString group,QString entry,QVariant def="");
//! helper function to set an entry in a group in the userSettings
void userSettingsGroupSet(QString group,QString entry,QVariant value);
//! private copy constructors to prvent copying //! private copy constructors to prvent copying
RbSettings& operator= (const RbSettings& other) RbSettings& operator= (const RbSettings& other)
{ (void)other; return *this; } { (void)other; return *this; }
RbSettings(const RbSettings& other) :QObject() RbSettings(const RbSettings& other) :QObject()
{ (void)other; } { (void)other; }
QString constructSettingPath(QString path, QString substitute = QString());
//! pointers to our setting objects //! pointers to our setting objects
QSettings *devices; QSettings *systemSettings;
QSettings *userSettings; QSettings *userSettings;
}; };
#endif #endif

View file

@ -154,13 +154,13 @@ void RbUtilQt::downloadInfo()
connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort())); connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
if(settings->cacheOffline()) if(settings->value(RbSettings::CacheOffline).toBool())
daily->setCache(true); daily->setCache(true);
else else
daily->setCache(false); daily->setCache(false);
qDebug() << "downloading build info"; qDebug() << "downloading build info";
daily->setFile(&buildInfo); daily->setFile(&buildInfo);
daily->getFile(QUrl(settings->serverConfUrl())); daily->getFile(QUrl(settings->value(RbSettings::ServerConfUrl).toString()));
} }
@ -181,7 +181,7 @@ void RbUtilQt::downloadDone(bool error)
versmap.insert("arch_date", info.value("dailies/date").toString()); versmap.insert("arch_date", info.value("dailies/date").toString());
info.beginGroup("release"); info.beginGroup("release");
versmap.insert("rel_rev", info.value(settings->curBuildserver_Modelname()).toString()); versmap.insert("rel_rev", info.value(settings->value(RbSettings::CurBuildserverModel).toString()).toString());
info.endGroup(); info.endGroup();
if(versmap.value("rel_rev").isEmpty()) { if(versmap.value("rel_rev").isEmpty()) {
@ -197,12 +197,12 @@ void RbUtilQt::downloadDone(bool error)
connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort())); connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
if(settings->cacheOffline()) if(settings->value(RbSettings::CacheOffline).toBool())
bleeding->setCache(true); bleeding->setCache(true);
bleeding->setFile(&bleedingInfo); bleeding->setFile(&bleedingInfo);
bleeding->getFile(QUrl(settings->bleedingInfo())); bleeding->getFile(QUrl(settings->value(RbSettings::BleedingInfo).toString()));
if(settings->curVersion() != PUREVERSION) { if(settings->value(RbSettings::RbutilVersion) != PUREVERSION) {
QApplication::processEvents(); QApplication::processEvents();
QMessageBox::information(this, tr("New installation"), QMessageBox::information(this, tr("New installation"),
tr("This is a new installation of Rockbox Utility, or a new version. " tr("This is a new installation of Rockbox Utility, or a new version. "
@ -303,23 +303,23 @@ void RbUtilQt::updateSettings()
qDebug() << "updateSettings()"; qDebug() << "updateSettings()";
updateDevice(); updateDevice();
updateManual(); updateManual();
if(settings->proxyType() == "system") { if(settings->value(RbSettings::ProxyType) == "system") {
HttpGet::setGlobalProxy(Detect::systemProxy()); HttpGet::setGlobalProxy(Detect::systemProxy());
} }
else if(settings->proxyType() == "manual") { else if(settings->value(RbSettings::ProxyType) == "manual") {
HttpGet::setGlobalProxy(settings->proxy()); HttpGet::setGlobalProxy(settings->value(RbSettings::Proxy).toString());
} }
else { else {
HttpGet::setGlobalProxy(QUrl("")); HttpGet::setGlobalProxy(QUrl(""));
} }
HttpGet::setGlobalCache(settings->cachePath()); HttpGet::setGlobalCache(settings->value(RbSettings::CachePath).toString());
HttpGet::setGlobalDumbCache(settings->cacheOffline()); HttpGet::setGlobalDumbCache(settings->value(RbSettings::CacheOffline).toBool());
} }
void RbUtilQt::updateDevice() void RbUtilQt::updateDevice()
{ {
if(settings->curBootloaderMethod() == "none" ) { if(settings->value(RbSettings::CurBootloaderMethod) == "none" ) {
ui.buttonBootloader->setEnabled(false); ui.buttonBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false); ui.buttonRemoveBootloader->setEnabled(false);
ui.labelBootloader->setEnabled(false); ui.labelBootloader->setEnabled(false);
@ -328,7 +328,7 @@ void RbUtilQt::updateDevice()
else { else {
ui.buttonBootloader->setEnabled(true); ui.buttonBootloader->setEnabled(true);
ui.labelBootloader->setEnabled(true); ui.labelBootloader->setEnabled(true);
if(settings->curBootloaderMethod() == "fwpatcher") { if(settings->value(RbSettings::CurBootloaderMethod) == "fwpatcher") {
ui.labelRemoveBootloader->setEnabled(false); ui.labelRemoveBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false); ui.buttonRemoveBootloader->setEnabled(false);
} }
@ -339,9 +339,9 @@ void RbUtilQt::updateDevice()
} }
// displayed device info // displayed device info
QString mountpoint = settings->mountpoint(); QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
QString brand = settings->curBrand(); QString brand = settings->value(RbSettings::CurBrand).toString();
QString name = settings->curName(); QString name = settings->value(RbSettings::CurName).toString();
if(name.isEmpty()) name = "&lt;none&gt;"; if(name.isEmpty()) name = "&lt;none&gt;";
if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;"; if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>") ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
@ -351,16 +351,18 @@ void RbUtilQt::updateDevice()
void RbUtilQt::updateManual() void RbUtilQt::updateManual()
{ {
if(settings->curPlatform() != "") if(settings->value(RbSettings::Platform) != "")
{ {
QString manual= settings->curManual(); QString manual= settings->value(RbSettings::CurManual).toString();
if(manual == "") if(manual == "")
manual = "rockbox-" + settings->curPlatform(); manual = "rockbox-" + settings->value(RbSettings::Platform).toString();
QString pdfmanual; QString pdfmanual;
pdfmanual = settings->manualUrl() + "/" + manual + ".pdf"; pdfmanual = settings->value(RbSettings::ManualUrl).toString()
+ "/" + manual + ".pdf";
QString htmlmanual; QString htmlmanual;
htmlmanual = settings->manualUrl() + "/" + manual + "/rockbox-build.html"; htmlmanual = settings->value(RbSettings::ManualUrl).toString()
+ "/" + manual + "/rockbox-build.html";
ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>") ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
.arg(pdfmanual)); .arg(pdfmanual));
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>") ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
@ -453,7 +455,7 @@ void RbUtilQt::smallInstall()
bool RbUtilQt::smallInstallInner() bool RbUtilQt::smallInstallInner()
{ {
QString mountpoint = settings->mountpoint(); QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
// show dialog with error if mount point is wrong // show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) { if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR); logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@ -461,7 +463,7 @@ bool RbUtilQt::smallInstallInner()
return true; return true;
} }
// Bootloader // Bootloader
if(settings->curBootloaderMethod() != "none") if(settings->value(RbSettings::CurBootloaderMethod) != "none")
{ {
m_error = false; m_error = false;
m_installed = false; m_installed = false;
@ -513,14 +515,16 @@ void RbUtilQt::installBtn()
bool RbUtilQt::installAuto() bool RbUtilQt::installAuto()
{ {
QString file = QString("%1/%2/rockbox-%3-%4.zip") QString file = QString("%1/%2/rockbox-%3-%4.zip")
.arg(settings->releaseUrl(), versmap.value("rel_rev"), .arg(settings->value(RbSettings::ReleaseUrl).toString(),
settings->curBuildserver_Modelname(), versmap.value("rel_rev")); versmap.value("rel_rev"),
settings->value(RbSettings::CurBuildserverModel).toString(),
versmap.value("rel_rev"));
buildInfo.open(); buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this); QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close(); buildInfo.close();
// check installed Version and Target // check installed Version and Target
QString rbVersion = Detect::installedVersion(settings->mountpoint()); QString rbVersion = Detect::installedVersion(settings->value(RbSettings::Mountpoint).toString());
QString warning = Detect::check(settings, false); QString warning = Detect::check(settings, false);
if(!warning.isEmpty()) if(!warning.isEmpty())
@ -542,7 +546,7 @@ bool RbUtilQt::installAuto()
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
logger->addItem(tr("Starting backup..."),LOGINFO); logger->addItem(tr("Starting backup..."),LOGINFO);
QString backupName = settings->mountpoint() QString backupName = settings->value(RbSettings::Mountpoint).toString()
+ "/.backup/rockbox-backup-" + rbVersion + ".zip"; + "/.backup/rockbox-backup-" + rbVersion + ".zip";
//! create dir, if it doesnt exist //! create dir, if it doesnt exist
@ -556,7 +560,8 @@ bool RbUtilQt::installAuto()
//! create backup //! create backup
RbZip backup; RbZip backup;
connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int))); connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
if(backup.createZip(backupName,settings->mountpoint() + "/.rockbox") == Zip::Ok) if(backup.createZip(backupName,
settings->value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
{ {
logger->addItem(tr("Backup successful"),LOGOK); logger->addItem(tr("Backup successful"),LOGOK);
} }
@ -574,9 +579,9 @@ bool RbUtilQt::installAuto()
installer->setUrl(file); installer->setUrl(file);
installer->setLogSection("Rockbox (Base)"); installer->setLogSection("Rockbox (Base)");
installer->setLogVersion(versmap.value("rel_rev")); installer->setLogVersion(versmap.value("rel_rev"));
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
installer->setMountPoint(settings->mountpoint()); installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
@ -618,13 +623,13 @@ void RbUtilQt::installBootloaderBtn()
void RbUtilQt::installBootloader() void RbUtilQt::installBootloader()
{ {
QString platform = settings->curPlatform(); QString platform = settings->value(RbSettings::Platform).toString();
QString backupDestination = ""; QString backupDestination = "";
m_error = false; m_error = false;
// create installer // create installer
BootloaderInstallBase *bl; BootloaderInstallBase *bl;
QString type = settings->curBootloaderMethod(); QString type = settings->value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") { if(type == "mi4") {
bl = new BootloaderInstallMi4(this); bl = new BootloaderInstallMi4(this);
} }
@ -648,21 +653,24 @@ void RbUtilQt::installBootloader()
// set bootloader filename. Do this now as installed() needs it. // set bootloader filename. Do this now as installed() needs it.
QString blfile; QString blfile;
blfile = settings->mountpoint() + settings->curBootloaderFile(); blfile = settings->value(RbSettings::Mountpoint).toString()
+ settings->value(RbSettings::CurBootloaderFile).toString();
// special case for H10 pure: this player can have a different // special case for H10 pure: this player can have a different
// bootloader file filename. This is handled here to keep the install // bootloader file filename. This is handled here to keep the install
// class clean, though having it here is also not the nicest solution. // class clean, though having it here is also not the nicest solution.
if(platform == "h10_ums" if(settings->value(RbSettings::Platform).toString() == "h10_ums"
|| platform == "h10_mtp") { || settings->value(RbSettings::Platform) == "h10_mtp") {
if(resolvePathCase(blfile).isEmpty()) if(resolvePathCase(blfile).isEmpty())
blfile = settings->mountpoint() blfile = settings->value(RbSettings::Mountpoint).toString()
+ settings->curBootloaderName().replace("H10", + settings->value(RbSettings::CurBootloaderName).toString()
"H10EMP", Qt::CaseInsensitive); .replace("H10", "H10EMP", Qt::CaseInsensitive);
} }
bl->setBlFile(blfile); bl->setBlFile(blfile);
QUrl url(settings->bootloaderUrl() + settings->curBootloaderName()); QUrl url(settings->value(RbSettings::BootloaderUrl).toString()
+ settings->value(RbSettings::CurBootloaderName).toString());
bl->setBlUrl(url); bl->setBlUrl(url);
bl->setLogfile(settings->mountpoint() + "/.rockbox/rbutil.log"); bl->setLogfile(settings->value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log");
if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) { if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
if(QMessageBox::question(this, tr("Bootloader detected"), if(QMessageBox::question(this, tr("Bootloader detected"),
@ -684,7 +692,8 @@ void RbUtilQt::installBootloader()
else if(bl->installed() == BootloaderInstallBase::BootloaderOther else if(bl->installed() == BootloaderInstallBase::BootloaderOther
&& bl->capabilities() & BootloaderInstallBase::Backup) && bl->capabilities() & BootloaderInstallBase::Backup)
{ {
QString targetFolder = settings->curPlatform() + " Firmware Backup"; QString targetFolder = settings->value(RbSettings::CurPlatformName).toString()
+ " Firmware Backup";
// remove invalid character(s) // remove invalid character(s)
targetFolder.remove(QRegExp("[:/]")); targetFolder.remove(QRegExp("[:/]"));
if(QMessageBox::question(this, tr("Create Bootloader backup"), if(QMessageBox::question(this, tr("Create Bootloader backup"),
@ -777,7 +786,8 @@ void RbUtilQt::installBootloaderPost(bool error)
if(m_auto) if(m_auto)
return; return;
QString msg = BootloaderInstallBase::postinstallHints(settings->curPlatform()); QString msg = BootloaderInstallBase::postinstallHints(
settings->value(RbSettings::Platform).toString());
if(!msg.isEmpty()) { if(!msg.isEmpty()) {
QMessageBox::information(this, tr("Manual steps required"), msg); QMessageBox::information(this, tr("Manual steps required"), msg);
logger->close(); logger->close();
@ -809,11 +819,11 @@ void RbUtilQt::installFonts()
// create zip installer // create zip installer
installer = new ZipInstaller(this); installer = new ZipInstaller(this);
installer->setUrl(settings->fontUrl()); installer->setUrl(settings->value(RbSettings::FontUrl).toString());
installer->setLogSection("Fonts"); installer->setLogSection("Fonts");
installer->setLogVersion(versmap.value("arch_date")); installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(settings->mountpoint()); installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
@ -843,17 +853,17 @@ void RbUtilQt::installVoice()
// create zip installer // create zip installer
installer = new ZipInstaller(this); installer = new ZipInstaller(this);
QString voiceurl = settings->voiceUrl(); QString voiceurl = settings->value(RbSettings::VoiceUrl).toString();
voiceurl += settings->curConfigure_Modelname() + "-" + voiceurl += settings->value(RbSettings::CurConfigureModel).toString() + "-" +
versmap.value("arch_date") + "-english.zip"; versmap.value("arch_date") + "-english.zip";
qDebug() << voiceurl; qDebug() << voiceurl;
installer->setUrl(voiceurl); installer->setUrl(voiceurl);
installer->setLogSection("Voice"); installer->setLogSection("Voice");
installer->setLogVersion(versmap.value("arch_date")); installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(settings->mountpoint()); installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
installer->install(logger); installer->install(logger);
@ -885,7 +895,8 @@ bool RbUtilQt::installDoomAuto()
bool RbUtilQt::hasDoom() bool RbUtilQt::hasDoom()
{ {
QFile doomrock(settings->mountpoint() +"/.rockbox/rocks/games/doom.rock"); QFile doomrock(settings->value(RbSettings::Mountpoint).toString()
+"/.rockbox/rocks/games/doom.rock");
return doomrock.exists(); return doomrock.exists();
} }
@ -894,11 +905,11 @@ void RbUtilQt::installDoom()
// create zip installer // create zip installer
installer = new ZipInstaller(this); installer = new ZipInstaller(this);
installer->setUrl(settings->doomUrl()); installer->setUrl(settings->value(RbSettings::DoomUrl).toString());
installer->setLogSection("Game Addons"); installer->setLogSection("Game Addons");
installer->setLogVersion(versmap.value("arch_date")); installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(settings->mountpoint()); installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
installer->install(logger); installer->install(logger);
@ -957,11 +968,11 @@ void RbUtilQt::uninstallBootloader(void)
logger->setProgressVisible(false); logger->setProgressVisible(false);
logger->show(); logger->show();
QString platform = settings->curPlatform(); QString platform = settings->value(RbSettings::Platform).toString();
// create installer // create installer
BootloaderInstallBase *bl; BootloaderInstallBase *bl;
QString type = settings->curBootloaderMethod(); QString type = settings->value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") { if(type == "mi4") {
bl = new BootloaderInstallMi4(); bl = new BootloaderInstallMi4();
} }
@ -983,13 +994,14 @@ void RbUtilQt::uninstallBootloader(void)
return; return;
} }
QString blfile = settings->mountpoint() + settings->curBootloaderFile(); QString blfile = settings->value(RbSettings::Mountpoint).toString()
if(settings->curPlatform() == "h10_ums" + settings->value(RbSettings::CurBootloaderFile).toString();
|| settings->curPlatform() == "h10_mtp") { if(settings->value(RbSettings::Platform).toString() == "h10_ums"
|| settings->value(RbSettings::Platform).toString() == "h10_mtp") {
if(resolvePathCase(blfile).isEmpty()) if(resolvePathCase(blfile).isEmpty())
blfile = settings->mountpoint() blfile = settings->value(RbSettings::Mountpoint).toString()
+ settings->curBootloaderName().replace("H10", + settings->value(RbSettings::CurBootloaderName).toString()
"H10EMP", Qt::CaseInsensitive); .replace("H10", "H10EMP", Qt::CaseInsensitive);
} }
bl->setBlFile(blfile); bl->setBlFile(blfile);
@ -1017,7 +1029,7 @@ void RbUtilQt::downloadManual(void)
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this); QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close(); buildInfo.close();
QString manual = settings->curManual(); QString manual = settings->value(RbSettings::CurManual).toString();
QString date = (info.value("dailies/date").toString()); QString date = (info.value("dailies/date").toString());
@ -1032,14 +1044,14 @@ void RbUtilQt::downloadManual(void)
target = "/" + manual + "-" + date + "-html.zip"; target = "/" + manual + "-" + date + "-html.zip";
section = "Manual (HTML)"; section = "Manual (HTML)";
} }
manualurl = settings->manualUrl() + "/" + target; manualurl = settings->value(RbSettings::ManualUrl).toString() + "/" + target;
qDebug() << "manualurl =" << manualurl; qDebug() << "manualurl =" << manualurl;
ProgressLoggerGui* logger = new ProgressLoggerGui(this); ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show(); logger->show();
installer = new ZipInstaller(this); installer = new ZipInstaller(this);
installer->setMountPoint(settings->mountpoint()); installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
installer->setLogSection(section); installer->setLogSection(section);
installer->setLogVersion(date); installer->setLogVersion(date);
@ -1065,24 +1077,28 @@ void RbUtilQt::installPortable(void)
logger->addItem(tr("Installing Rockbox Utility"), LOGINFO); logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
// check mountpoint // check mountpoint
if(!QFileInfo(settings->mountpoint()).isDir()) { if(!QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR); logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort(); logger->abort();
return; return;
} }
// remove old files first. // remove old files first.
QFile::remove(settings->mountpoint() + "/RockboxUtility.exe"); QFile::remove(settings->value(RbSettings::Mountpoint).toString()
QFile::remove(settings->mountpoint() + "/RockboxUtility.ini"); + "/RockboxUtility.exe");
QFile::remove(settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.ini");
// copy currently running binary and currently used settings file // copy currently running binary and currently used settings file
if(!QFile::copy(qApp->applicationFilePath(), settings->mountpoint() if(!QFile::copy(qApp->applicationFilePath(),
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.exe")) { + "/RockboxUtility.exe")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR); logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
logger->abort(); logger->abort();
return; return;
} }
logger->addItem(tr("Installing user configuration"), LOGINFO); logger->addItem(tr("Installing user configuration"), LOGINFO);
if(!QFile::copy(settings->userSettingFilename(), settings->mountpoint() if(!QFile::copy(settings->userSettingFilename(),
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.ini")) { + "/RockboxUtility.ini")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR); logger->addItem(tr("Error installing user configuration"), LOGERROR);
logger->abort(); logger->abort();
@ -1100,8 +1116,8 @@ void RbUtilQt::updateInfo()
{ {
qDebug() << "RbUtilQt::updateInfo()"; qDebug() << "RbUtilQt::updateInfo()";
QSettings log(settings->mountpoint() + "/.rockbox/rbutil.log", QSettings log(settings->value(RbSettings::Mountpoint).toString()
QSettings::IniFormat, this); + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
QStringList groups = log.childGroups(); QStringList groups = log.childGroups();
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
QTreeWidgetItem *w, *w2; QTreeWidgetItem *w, *w2;
@ -1137,7 +1153,7 @@ void RbUtilQt::updateInfo()
for(int b = 0; b < keys.size(); b++) { for(int b = 0; b < keys.size(); b++) {
QString file; QString file;
file = settings->mountpoint() + "/" + keys.at(b); file = settings->value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
if(QFileInfo(file).isDir()) if(QFileInfo(file).isDir())
continue; continue;
w2 = new QTreeWidgetItem(w, QStringList() << "/" w2 = new QTreeWidgetItem(w, QStringList() << "/"
@ -1162,9 +1178,9 @@ void RbUtilQt::updateInfo()
QUrl RbUtilQt::proxy() QUrl RbUtilQt::proxy()
{ {
if(settings->proxyType() == "manual") if(settings->value(RbSettings::ProxyType) == "manual")
return QUrl(settings->proxy()); return QUrl(settings->value(RbSettings::Proxy).toString());
else if(settings->proxy() == "system") else if(settings->value(RbSettings::ProxyType) == "system")
return Detect::systemProxy(); return Detect::systemProxy();
return QUrl(""); return QUrl("");
} }
@ -1173,9 +1189,9 @@ QUrl RbUtilQt::proxy()
bool RbUtilQt::chkConfig(bool warn) bool RbUtilQt::chkConfig(bool warn)
{ {
bool error = false; bool error = false;
if(settings->curPlatform().isEmpty() if(settings->value(RbSettings::Platform).toString().isEmpty()
|| settings->mountpoint().isEmpty() || settings->value(RbSettings::Mountpoint).toString().isEmpty()
|| !QFileInfo(settings->mountpoint()).isWritable()) { || !QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isWritable()) {
error = true; error = true;
if(warn) QMessageBox::critical(this, tr("Configuration error"), if(warn) QMessageBox::critical(this, tr("Configuration error"),

View file

@ -24,25 +24,25 @@ TalkFileCreator::TalkFileCreator(QObject* parent): QObject(parent)
} }
//! \brief Creates Talkfiles. //! \brief Creates Talkfiles.
//! //!
//! \param logger A pointer to a Loggerobject //! \param logger A pointer to a Loggerobject
bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
{ {
m_abort = false; m_abort = false;
m_logger = logger; m_logger = logger;
QMultiMap<QString,QString> fileList; QMultiMap<QString,QString> fileList;
QMultiMap<QString,QString> dirList; QMultiMap<QString,QString> dirList;
QStringList toSpeakList, voicedEntries, encodedEntries; QStringList toSpeakList, voicedEntries, encodedEntries;
QString errStr; QString errStr;
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
//tts //tts
m_tts = TTSBase::getTTS(settings->curTTS()); m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings); m_tts->setCfg(settings);
if(!m_tts->start(&errStr)) if(!m_tts->start(&errStr))
{ {
m_logger->addItem(errStr.trimmed(),LOGERROR); m_logger->addItem(errStr.trimmed(),LOGERROR);
@ -52,9 +52,9 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
} }
// Encoder // Encoder
m_enc = EncBase::getEncoder(settings->curEncoder()); m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings); m_enc->setCfg(settings);
if(!m_enc->start()) if(!m_enc->start())
{ {
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR); m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
@ -67,7 +67,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
connect(logger,SIGNAL(aborted()),this,SLOT(abort())); connect(logger,SIGNAL(aborted()),this,SLOT(abort()));
m_logger->setProgressMax(0); m_logger->setProgressMax(0);
// read in Maps of paths - file/dirnames // read in Maps of paths - file/dirnames
m_logger->addItem(tr("Reading Filelist..."),LOGINFO); m_logger->addItem(tr("Reading Filelist..."),LOGINFO);
if(createDirAndFileMaps(m_dir,&dirList,&fileList) == false) if(createDirAndFileMaps(m_dir,&dirList,&fileList) == false)
@ -76,21 +76,21 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList); doAbort(toSpeakList);
return false; return false;
} }
// create List of all Files/Dirs to speak // create List of all Files/Dirs to speak
QMapIterator<QString, QString> dirIt(dirList); QMapIterator<QString, QString> dirIt(dirList);
while (dirIt.hasNext()) while (dirIt.hasNext())
{ {
dirIt.next(); dirIt.next();
// insert only non dublicate dir entries into list // insert only non dublicate dir entries into list
if(!toSpeakList.contains(dirIt.value())) if(!toSpeakList.contains(dirIt.value()))
{ {
qDebug() << "toSpeaklist dir:" << dirIt.value(); qDebug() << "toSpeaklist dir:" << dirIt.value();
toSpeakList.append(dirIt.value()); toSpeakList.append(dirIt.value());
} }
} }
QMapIterator<QString, QString> fileIt(fileList); QMapIterator<QString, QString> fileIt(fileList);
while (fileIt.hasNext()) while (fileIt.hasNext())
{ {
fileIt.next(); fileIt.next();
// insert only non- dublictae file entries into list // insert only non- dublictae file entries into list
@ -99,10 +99,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
if(m_stripExtensions) if(m_stripExtensions)
toSpeakList.append(stripExtension(fileIt.value())); toSpeakList.append(stripExtension(fileIt.value()));
else else
toSpeakList.append(fileIt.value()); toSpeakList.append(fileIt.value());
} }
} }
// Voice entries // Voice entries
m_logger->addItem(tr("Voicing entries..."),LOGINFO); m_logger->addItem(tr("Voicing entries..."),LOGINFO);
TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries); TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries);
@ -111,7 +111,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList); doAbort(toSpeakList);
return false; return false;
} }
// Encoding Entries // Encoding Entries
m_logger->addItem(tr("Encoding files..."),LOGINFO); m_logger->addItem(tr("Encoding files..."),LOGINFO);
if(encodeList(voicedEntries,encodedEntries) == false) if(encodeList(voicedEntries,encodedEntries) == false)
@ -119,25 +119,25 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList); doAbort(toSpeakList);
return false; return false;
} }
// Copying talk files // Copying talk files
m_logger->addItem(tr("Copying Talkfile for Dirs..."),LOGINFO); m_logger->addItem(tr("Copying Talkfile for Dirs..."),LOGINFO);
if(copyTalkDirFiles(dirList,&errStr) == false) if(copyTalkDirFiles(dirList,&errStr) == false)
{ {
m_logger->addItem(errStr,LOGERROR); m_logger->addItem(errStr,LOGERROR);
doAbort(toSpeakList); doAbort(toSpeakList);
return false; return false;
} }
//Copying file talk files //Copying file talk files
m_logger->addItem(tr("Copying Talkfile for Files..."),LOGINFO); m_logger->addItem(tr("Copying Talkfile for Files..."),LOGINFO);
if(copyTalkFileFiles(fileList,&errStr) == false) if(copyTalkFileFiles(fileList,&errStr) == false)
{ {
m_logger->addItem(errStr,LOGERROR); m_logger->addItem(errStr,LOGERROR);
doAbort(toSpeakList); doAbort(toSpeakList);
return false; return false;
} }
// Deleting left overs // Deleting left overs
if( !cleanup(toSpeakList)) if( !cleanup(toSpeakList))
return false; return false;
@ -184,7 +184,7 @@ void TalkFileCreator::doAbort(QStringList cleanupList)
m_logger->setProgressValue(0); m_logger->setProgressValue(0);
m_logger->abort(); m_logger->abort();
m_tts->stop(); m_tts->stop();
m_enc->stop(); m_enc->stop();
} }
//! \brief Creates MultiMaps (paths -> File/dir names) of all Dirs and Files in a Folder. //! \brief Creates MultiMaps (paths -> File/dir names) of all Dirs and Files in a Folder.
@ -194,16 +194,16 @@ void TalkFileCreator::doAbort(QStringList cleanupList)
//! \param startDir The dir where it beginns scanning //! \param startDir The dir where it beginns scanning
//! \param dirMap The MulitMap where the dirs are stored //! \param dirMap The MulitMap where the dirs are stored
//! \param filMap The MultiMap where Files are stored //! \param filMap The MultiMap where Files are stored
//! \returns true on Success, false if User aborted. //! \returns true on Success, false if User aborted.
bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QString> *dirMap,QMultiMap<QString,QString> *fileMap) bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QString> *dirMap,QMultiMap<QString,QString> *fileMap)
{ {
// create Iterator // create Iterator
QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
if(m_recursive) if(m_recursive)
flags = QDirIterator::Subdirectories; flags = QDirIterator::Subdirectories;
QDirIterator it(startDir,flags); QDirIterator it(startDir,flags);
// read in Maps of paths - file/dirnames // read in Maps of paths - file/dirnames
while (it.hasNext()) while (it.hasNext())
{ {
@ -212,14 +212,14 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri
{ {
return false; return false;
} }
QFileInfo fileInf = it.fileInfo(); QFileInfo fileInf = it.fileInfo();
// its a dir // its a dir
if(fileInf.isDir()) if(fileInf.isDir())
{ {
QDir dir = fileInf.dir(); QDir dir = fileInf.dir();
// insert into List // insert into List
if(!dir.dirName().isEmpty() && m_talkFolders) if(!dir.dirName().isEmpty() && m_talkFolders)
{ {
@ -238,7 +238,7 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri
} }
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
return true; return true;
} }
//! \brief Voices a List of string to the temp dir. Progress is handled inside. //! \brief Voices a List of string to the temp dir. Progress is handled inside.
@ -259,37 +259,37 @@ TTSStatus TalkFileCreator::voiceList(QStringList toSpeak,QStringList& voicedEntr
m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); m_logger->addItem(tr("Talk file creation aborted"), LOGERROR);
return FatalError; return FatalError;
} }
QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav"; QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav";
QString error; QString error;
TTSStatus status = m_tts->voice(toSpeak[i],filename, &error); TTSStatus status = m_tts->voice(toSpeak[i],filename, &error);
if(status == Warning) if(status == Warning)
{ {
warnings = true; warnings = true;
m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error),
LOGWARNING); LOGWARNING);
} }
else if (status == FatalError) else if (status == FatalError)
{ {
m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error),
LOGERROR); LOGERROR);
return FatalError; return FatalError;
} }
else else
voicedEntries.append(toSpeak[i]); voicedEntries.append(toSpeak[i]);
m_logger->setProgressValue(++m_progress); m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
if(warnings) if(warnings)
return Warning; return Warning;
else else
return NoError; return NoError;
} }
//! \brief Encodes a List of strings from/to the temp dir. Progress is handled inside. //! \brief Encodes a List of strings from/to the temp dir. Progress is handled inside.
//! It expects the inputfile in the temp dir with the name in the List appended with ".wav" //! It expects the inputfile in the temp dir with the name in the List appended with ".wav"
//! //!
//! \param toSpeak QStringList with the Entries to encode. //! \param toSpeak QStringList with the Entries to encode.
//! \param errString pointer to where the Error cause is written //! \param errString pointer to where the Error cause is written
@ -301,21 +301,21 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie
{ {
if(m_abort) if(m_abort)
{ {
m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); m_logger->addItem(tr("Talk file creation aborted"), LOGERROR);
return false; return false;
} }
QString wavfilename = QDir::tempPath()+ "/"+ toEncode[i] + ".wav"; QString wavfilename = QDir::tempPath()+ "/"+ toEncode[i] + ".wav";
QString filename = QDir::tempPath()+ "/"+ toEncode[i] + ".talk"; QString filename = QDir::tempPath()+ "/"+ toEncode[i] + ".talk";
if(!m_enc->encode(wavfilename,filename)) if(!m_enc->encode(wavfilename,filename))
{ {
m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR); m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR);
return false; return false;
} }
encodedEntries.append(toEncode[i]); encodedEntries.append(toEncode[i]);
m_logger->setProgressValue(++m_progress); m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
return true; return true;
} }
@ -324,16 +324,16 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie
//! //!
//! \param dirMap a MultiMap of Paths -> Dirnames //! \param dirMap a MultiMap of Paths -> Dirnames
//! \param errString Pointer to a QString where the error cause is written. //! \param errString Pointer to a QString where the error cause is written.
//! \returns true on success, false on error or user abort //! \returns true on success, false on error or user abort
bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString* errString) bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString* errString)
{ {
resetProgress(dirMap.size()); resetProgress(dirMap.size());
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup("talkfiles"); installlog.beginGroup("talkfiles");
QMapIterator<QString, QString> it(dirMap); QMapIterator<QString, QString> it(dirMap);
while (it.hasNext()) while (it.hasNext())
{ {
it.next(); it.next();
if(m_abort) if(m_abort)
@ -341,51 +341,51 @@ bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString
*errString = tr("Talk file creation aborted"); *errString = tr("Talk file creation aborted");
return false; return false;
} }
QString source = QDir::tempPath()+ "/"+ it.value() + ".talk"; QString source = QDir::tempPath()+ "/"+ it.value() + ".talk";
if(!QFileInfo(source).exists()) if(!QFileInfo(source).exists())
continue; // this file was skipped in one of the previous steps continue; // this file was skipped in one of the previous steps
QString target = it.key() + "/" + "_dirname.talk"; QString target = it.key() + "/" + "_dirname.talk";
// remove target if it exists, and if we should overwrite it // remove target if it exists, and if we should overwrite it
if(m_overwriteTalk && QFile::exists(target)) if(m_overwriteTalk && QFile::exists(target))
QFile::remove(target); QFile::remove(target);
// copying // copying
if(!QFile::copy(source,target)) if(!QFile::copy(source,target))
{ {
*errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target);
return false; return false;
} }
// add to installlog // add to installlog
QString now = QDate::currentDate().toString("yyyyMMdd"); QString now = QDate::currentDate().toString("yyyyMMdd");
installlog.setValue(target.remove(0,m_mountpoint.length()),now); installlog.setValue(target.remove(0,m_mountpoint.length()),now);
m_logger->setProgressValue(++m_progress); m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
installlog.endGroup(); installlog.endGroup();
installlog.sync(); installlog.sync();
return true; return true;
} }
//! \brief copys Talkfile for Files from the temp dir to the target. Progress and installlog is handled inside //! \brief copys Talkfile for Files from the temp dir to the target. Progress and installlog is handled inside
//! //!
//! \param fileMap a MultiMap of Paths -> Filenames //! \param fileMap a MultiMap of Paths -> Filenames
//! \param errString Pointer to a QString where the error cause is written. //! \param errString Pointer to a QString where the error cause is written.
//! \returns true on success, false on error or user abort //! \returns true on success, false on error or user abort
bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QString* errString) bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QString* errString)
{ {
resetProgress(fileMap.size()); resetProgress(fileMap.size());
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup("talkfiles"); installlog.beginGroup("talkfiles");
QMapIterator<QString, QString> it(fileMap); QMapIterator<QString, QString> it(fileMap);
while (it.hasNext()) while (it.hasNext())
{ {
it.next(); it.next();
if(m_abort) if(m_abort)
@ -393,58 +393,58 @@ bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QStri
*errString = tr("Talk file creation aborted"); *errString = tr("Talk file creation aborted");
return false; return false;
} }
QString source; QString source;
QString target = it.key() + "/" + it.value() + ".talk"; QString target = it.key() + "/" + it.value() + ".talk";
// correct source if we hav stripExtension enabled // correct source if we hav stripExtension enabled
if(m_stripExtensions) if(m_stripExtensions)
source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk"; source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk";
else else
source = QDir::tempPath()+ "/"+ it.value() + ".talk"; source = QDir::tempPath()+ "/"+ it.value() + ".talk";
if(!QFileInfo(source).exists()) if(!QFileInfo(source).exists())
continue; // this file was skipped in one of the previous steps continue; // this file was skipped in one of the previous steps
// remove target if it exists, and if we should overwrite it // remove target if it exists, and if we should overwrite it
if(m_overwriteTalk && QFile::exists(target)) if(m_overwriteTalk && QFile::exists(target))
QFile::remove(target); QFile::remove(target);
// copy file // copy file
qDebug() << "copying: " << source << " to " << target; qDebug() << "copying: " << source << " to " << target;
if(!QFile::copy(source,target)) if(!QFile::copy(source,target))
{ {
*errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target);
return false; return false;
} }
// add to Install log // add to Install log
QString now = QDate::currentDate().toString("yyyyMMdd"); QString now = QDate::currentDate().toString("yyyyMMdd");
installlog.setValue(target.remove(0,m_mountpoint.length()),now); installlog.setValue(target.remove(0,m_mountpoint.length()),now);
m_logger->setProgressValue(++m_progress); m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
installlog.endGroup(); installlog.endGroup();
installlog.sync(); installlog.sync();
return true; return true;
} }
//! \brief Cleans up Files potentially left in the temp dir //! \brief Cleans up Files potentially left in the temp dir
//! //!
//! \param list List of file to try to delete in the temp dir. Function appends ".wav" and ".talk" to the filenames //! \param list List of file to try to delete in the temp dir. Function appends ".wav" and ".talk" to the filenames
bool TalkFileCreator::cleanup(QStringList list) bool TalkFileCreator::cleanup(QStringList list)
{ {
m_logger->addItem(tr("Cleaning up.."),LOGINFO); m_logger->addItem(tr("Cleaning up.."),LOGINFO);
for(int i=0; i < list.size(); i++) for(int i=0; i < list.size(); i++)
{ {
if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".wav")) if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".wav"))
QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".wav"); QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".wav");
if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".talk")) if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".talk"))
QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".talk"); QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".talk");
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
return true; return true;

View file

@ -61,11 +61,11 @@ void ThemesInstallWindow::downloadInfo()
themesInfo.close(); themesInfo.close();
QUrl url; QUrl url;
url = QUrl(settings->themeUrl() + "/rbutilqt.php?target=" url = QUrl(settings->value(RbSettings::ThemesUrl).toString() + "/rbutilqt.php?target="
+ settings->curConfigure_Modelname()); + settings->value(RbSettings::CurConfigureModel).toString());
qDebug() << "downloadInfo()" << url; qDebug() << "downloadInfo()" << url;
qDebug() << url.queryItems(); qDebug() << url.queryItems();
if(settings->cacheOffline()) if(settings->value(RbSettings::CacheOffline).toBool())
getter->setCache(true); getter->setCache(true);
getter->setFile(&themesInfo); getter->setFile(&themesInfo);
@ -144,7 +144,7 @@ void ThemesInstallWindow::downloadDone(bool error)
// check if there's a themes "MOTD" available // check if there's a themes "MOTD" available
if(iniDetails.contains("status/msg")) { if(iniDetails.contains("status/msg")) {
// check if there's a localized msg available // check if there's a localized msg available
QString lang = settings->curLang().split("_").at(0); QString lang = settings->value(RbSettings::Language).toString().split("_").at(0);
QString msg; QString msg;
if(iniDetails.contains("status/msg." + lang)) if(iniDetails.contains("status/msg." + lang))
msg = iniDetails.value("status/msg." + lang).toString(); msg = iniDetails.value("status/msg." + lang).toString();
@ -191,9 +191,9 @@ void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* p
iniDetails.beginGroup(cur->data(Qt::UserRole).toString()); iniDetails.beginGroup(cur->data(Qt::UserRole).toString());
QUrl img, txt; QUrl img, txt;
txt = QUrl(QString(settings->themeUrl() + "/" txt = QUrl(QString(settings->value(RbSettings::ThemesUrl).toString() + "/"
+ iniDetails.value("descriptionfile").toString())); + iniDetails.value("descriptionfile").toString()));
img = QUrl(QString(settings->themeUrl() + "/" img = QUrl(QString(settings->value(RbSettings::ThemesUrl).toString() + "/"
+ iniDetails.value("image").toString())); + iniDetails.value("image").toString()));
QString text; QString text;
@ -211,7 +211,7 @@ void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* p
iniDetails.endGroup(); iniDetails.endGroup();
igetter.abort(); igetter.abort();
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
igetter.setCache(true); igetter.setCache(true);
else else
{ {
@ -307,7 +307,7 @@ void ThemesInstallWindow::accept()
QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this);
for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) { for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) {
iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString()); iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString());
zip = settings->themeUrl() zip = settings->value(RbSettings::ThemesUrl).toString()
+ "/" + iniDetails.value("archive").toString(); + "/" + iniDetails.value("archive").toString();
themes.append(zip); themes.append(zip);
names.append("Theme: " + names.append("Theme: " +
@ -321,7 +321,7 @@ void ThemesInstallWindow::accept()
logger = new ProgressLoggerGui(this); logger = new ProgressLoggerGui(this);
logger->show(); logger->show();
QString mountPoint = settings->mountpoint(); QString mountPoint = settings->value(RbSettings::Mountpoint).toString();
qDebug() << "mountpoint:" << mountPoint; qDebug() << "mountpoint:" << mountPoint;
// show dialog with error if mount point is wrong // show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) { if(!QFileInfo(mountPoint).isDir()) {
@ -335,7 +335,7 @@ void ThemesInstallWindow::accept()
installer->setLogSection(names); installer->setLogSection(names);
installer->setLogVersion(version); installer->setLogVersion(version);
installer->setMountPoint(mountPoint); installer->setMountPoint(mountPoint);
if(!settings->cacheDisabled()) if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true); installer->setCache(true);
connect(logger, SIGNAL(closed()), this, SLOT(close())); connect(logger, SIGNAL(closed()), this, SLOT(close()));

View file

@ -142,7 +142,7 @@ void TTSExes::setCfg(RbSettings* sett)
break; break;
} }
} }
settings->setTTSPath(m_name,exepath); settings->setSubValue(m_name, RbSettings::TtsPath, exepath);
settings->sync(); settings->sync();
} }
@ -150,8 +150,8 @@ void TTSExes::setCfg(RbSettings* sett)
bool TTSExes::start(QString *errStr) bool TTSExes::start(QString *errStr)
{ {
m_TTSexec = settings->ttsPath(m_name); m_TTSexec = settings->subValue(m_name, RbSettings::TtsPath).toString();
m_TTSOpts = settings->ttsOptions(m_name); m_TTSOpts = settings->subValue(m_name, RbSettings::TtsOptions).toString();
m_TTSTemplate = m_TemplateMap.value(m_name); m_TTSTemplate = m_TemplateMap.value(m_name);
@ -195,7 +195,7 @@ void TTSExes::showCfg()
bool TTSExes::configOk() bool TTSExes::configOk()
{ {
QString path = settings->ttsPath(m_name); QString path = settings->subValue(m_name, RbSettings::TtsPath).toString();
if (QFileInfo(path).exists()) if (QFileInfo(path).exists())
return true; return true;
@ -217,12 +217,12 @@ TTSSapi::TTSSapi() : TTSBase()
bool TTSSapi::start(QString *errStr) bool TTSSapi::start(QString *errStr)
{ {
m_TTSOpts = settings->ttsOptions("sapi"); m_TTSOpts = settings->subValue("sapi", RbSettings::TtsOptions).toString();
m_TTSLanguage =settings->ttsLang("sapi"); m_TTSLanguage =settings->subValue("sapi", RbSettings::TtsLanguage).toString();
m_TTSVoice=settings->ttsVoice("sapi"); m_TTSVoice=settings->subValue("sapi", RbSettings::TtsVoice).toString();
m_TTSSpeed=QString("%1").arg(settings->ttsSpeed("sapi")); m_TTSSpeed=QString("%1").arg(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
m_sapi4 = settings->ttsUseSapi4(); m_sapi4 = settings->value(RbSettings::TtsUseSapi4).toBool();
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs"); QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs"; m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs";
@ -284,8 +284,8 @@ QStringList TTSSapi::getVoiceList(QString language)
QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices"; QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices";
execstring.replace("%exe",m_TTSexec); execstring.replace("%exe",m_TTSexec);
execstring.replace("%lang",language); execstring.replace("%lang",language);
if(settings->ttsUseSapi4()) if(settings->value(RbSettings::TtsUseSapi4).toBool())
execstring.append(" /sapi4 "); execstring.append(" /sapi4 ");
qDebug() << "init" << execstring; qDebug() << "init" << execstring;
@ -363,7 +363,7 @@ void TTSSapi::showCfg()
bool TTSSapi::configOk() bool TTSSapi::configOk()
{ {
if(settings->ttsVoice("sapi").isEmpty()) if(settings->subValue("sapi", RbSettings::TtsVoice).toString().isEmpty())
return false; return false;
return true; return true;
} }
@ -380,7 +380,7 @@ void TTSFestival::startServer()
if(!configOk()) if(!configOk())
return; return;
QStringList paths = settings->ttsPath("festival").split(":"); QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
serverProcess.start(QString("%1 --server").arg(paths[0])); serverProcess.start(QString("%1 --server").arg(paths[0]));
serverProcess.waitForStarted(); serverProcess.waitForStarted();
@ -414,8 +414,9 @@ bool TTSFestival::start(QString* errStr)
{ {
(void) errStr; (void) errStr;
ensureServerRunning(); ensureServerRunning();
if (!settings->ttsVoice("festival").isEmpty()) if (!settings->subValue("festival", RbSettings::TtsVoice).toString().isEmpty())
queryServer(QString("(voice.select '%1)").arg(settings->ttsVoice("festival"))); queryServer(QString("(voice.select '%1)")
.arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
return true; return true;
} }
@ -432,7 +433,7 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
{ {
qDebug() << text << "->" << wavfile; qDebug() << text << "->" << wavfile;
QStringList paths = settings->ttsPath("festival").split(":"); QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(paths[1]).arg(wavfile); QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(paths[1]).arg(wavfile);
qDebug() << cmd; qDebug() << cmd;
@ -462,13 +463,15 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
bool TTSFestival::configOk() bool TTSFestival::configOk()
{ {
QStringList paths = settings->ttsPath("festival").split(":"); QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
if(paths.size() != 2) if(paths.size() != 2)
return false; return false;
bool ret = QFileInfo(paths[0]).isExecutable() && bool ret = QFileInfo(paths[0]).isExecutable() &&
QFileInfo(paths[1]).isExecutable(); QFileInfo(paths[1]).isExecutable();
if(settings->ttsVoice("festival").size() > 0 && voices.size() > 0) if(settings->subValue("festival", RbSettings::TtsVoice).toString().size() > 0
ret = ret && (voices.indexOf(settings->ttsVoice("festival")) != -1); && voices.size() > 0)
ret = ret && (voices.indexOf(settings->subValue("festival",
RbSettings::TtsVoice).toString()) != -1);
return ret; return ret;
} }

View file

@ -36,18 +36,18 @@ TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent)
void TTSSapiGui::showCfg() void TTSSapiGui::showCfg()
{ {
// try to get config from settings // try to get config from settings
ui.ttsoptions->setText(settings->ttsOptions("sapi")); ui.ttsoptions->setText(settings->subValue("sapi", RbSettings::TtsOptions).toString());
QString selLang = settings->ttsLang("sapi"); QString selLang = settings->subValue("sapi", RbSettings::TtsLanguage).toString();
QString selVoice = settings->ttsVoice("sapi"); QString selVoice = settings->subValue("sapi", RbSettings::TtsVoice).toString();
ui.speed->setValue(settings->ttsSpeed("sapi")); ui.speed->setValue(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
if(settings->ttsUseSapi4()) if(settings->value(RbSettings::TtsUseSapi4).toBool())
ui.usesapi4->setCheckState(Qt::Checked); ui.usesapi4->setCheckState(Qt::Checked);
else else
ui.usesapi4->setCheckState(Qt::Unchecked); ui.usesapi4->setCheckState(Qt::Unchecked);
// fill in language combobox // fill in language combobox
QStringList languages = settings->allLanguages(); QStringList languages = settings->languages();
languages.sort(); languages.sort();
ui.languagecombo->clear(); ui.languagecombo->clear();
ui.languagecombo->addItems(languages); ui.languagecombo->addItems(languages);
@ -78,14 +78,14 @@ void TTSSapiGui::reset()
void TTSSapiGui::accept(void) void TTSSapiGui::accept(void)
{ {
//save settings in user config //save settings in user config
settings->setTTSOptions("sapi",ui.ttsoptions->text()); settings->setSubValue("sapi", RbSettings::TtsOptions, ui.ttsoptions->text());
settings->setTTSLang("sapi",ui.languagecombo->currentText()); settings->setSubValue("sapi", RbSettings::TtsLanguage, ui.languagecombo->currentText());
settings->setTTSVoice("sapi",ui.voicecombo->currentText()); settings->setSubValue("sapi", RbSettings::TtsVoice, ui.voicecombo->currentText());
settings->setTTSSpeed("sapi",ui.speed->value()); settings->setSubValue("sapi", RbSettings::TtsSpeed, ui.speed->value());
if(ui.usesapi4->checkState() == Qt::Checked) if(ui.usesapi4->checkState() == Qt::Checked)
settings->setTTSUseSapi4(true); settings->setValue(RbSettings::TtsUseSapi4, true);
else else
settings->setTTSUseSapi4(false); settings->setValue(RbSettings::TtsUseSapi4, false);
// sync settings // sync settings
settings->sync(); settings->sync();
@ -108,9 +108,9 @@ void TTSSapiGui::updateVoices(QString language)
void TTSSapiGui::useSapi4Changed(int) void TTSSapiGui::useSapi4Changed(int)
{ {
if(ui.usesapi4->checkState() == Qt::Checked) if(ui.usesapi4->checkState() == Qt::Checked)
settings->setTTSUseSapi4(true); settings->setValue(RbSettings::TtsUseSapi4, true);
else else
settings->setTTSUseSapi4(false); settings->setValue(RbSettings::TtsUseSapi4, false);
// sync settings // sync settings
settings->sync(); settings->sync();
updateVoices(ui.languagecombo->currentText()); updateVoices(ui.languagecombo->currentText());
@ -136,8 +136,8 @@ void TTSExesGui::showCfg(QString name)
{ {
m_name = name; m_name = name;
// try to get config from settings // try to get config from settings
QString exepath =settings->ttsPath(m_name); QString exepath =settings->subValue(m_name, RbSettings::TtsPath).toString();
ui.ttsoptions->setText(settings->ttsOptions(m_name)); ui.ttsoptions->setText(settings->subValue(m_name, RbSettings::TtsOptions).toString());
ui.ttspath->setText(exepath); ui.ttspath->setText(exepath);
//show dialog //show dialog
@ -148,8 +148,8 @@ void TTSExesGui::showCfg(QString name)
void TTSExesGui::accept(void) void TTSExesGui::accept(void)
{ {
//save settings in user config //save settings in user config
settings->setTTSPath(m_name,ui.ttspath->text()); settings->setSubValue(m_name, RbSettings::TtsPath, ui.ttspath->text());
settings->setTTSOptions(m_name,ui.ttsoptions->text()); settings->setSubValue(m_name, RbSettings::TtsOptions, ui.ttsoptions->text());
// sync settings // sync settings
settings->sync(); settings->sync();
@ -199,15 +199,15 @@ TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) :
void TTSFestivalGui::showCfg() void TTSFestivalGui::showCfg()
{ {
qDebug() << "show\tpaths: " << settings->ttsPath("festival") << "\n" qDebug() << "show\tpaths: " << settings->subValue("festival", RbSettings::TtsPath) << "\n"
<< "\tvoice: " << settings->ttsVoice("festival"); << "\tvoice: " << settings->subValue("festival", RbSettings::TtsVoice);
// will populate the voices if the paths are correct, // will populate the voices if the paths are correct,
// otherwise, it will require the user to press Refresh // otherwise, it will require the user to press Refresh
updateVoices(); updateVoices();
// try to get config from settings // try to get config from settings
QStringList paths = settings->ttsPath("festival").split(":"); QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
if(paths.size() == 2) if(paths.size() == 2)
{ {
ui.serverPath->setText(paths[0]); ui.serverPath->setText(paths[0]);
@ -223,8 +223,8 @@ void TTSFestivalGui::accept(void)
//save settings in user config //save settings in user config
QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText(); qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText();
settings->setTTSPath("festival", newPath); settings->setSubValue("festival", RbSettings::TtsPath, newPath);
settings->setTTSVoice("festival", ui.voicesBox->currentText()); settings->setSubValue("festival", RbSettings::TtsVoice, ui.voicesBox->currentText());
settings->sync(); settings->sync();
@ -288,13 +288,13 @@ void TTSFestivalGui::onRefreshButton()
{ {
/* Temporarily commit the settings so that we get the new path when we check for voices */ /* Temporarily commit the settings so that we get the new path when we check for voices */
QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
QString oldPath = settings->ttsPath("festival"); QString oldPath = settings->subValue("festival", RbSettings::TtsPath).toString();
qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath); qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath);
if(newPath != oldPath) if(newPath != oldPath)
{ {
qDebug() << "Using new paths for getVoiceList"; qDebug() << "Using new paths for getVoiceList";
settings->setTTSPath("festival", newPath); settings->setSubValue("festival", RbSettings::TtsPath, newPath);
settings->sync(); settings->sync();
} }
@ -302,7 +302,7 @@ void TTSFestivalGui::onRefreshButton()
if(newPath != oldPath) if(newPath != oldPath)
{ {
settings->setTTSPath("festival", oldPath); settings->setSubValue("festival", RbSettings::TtsPath, oldPath);
settings->sync(); settings->sync();
} }
} }
@ -324,9 +324,10 @@ void TTSFestivalGui::updateVoices()
ui.voicesBox->clear(); ui.voicesBox->clear();
ui.voicesBox->addItems(voiceList); ui.voicesBox->addItems(voiceList);
ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(settings->ttsVoice("festival"))); ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(
settings->subValue("festival", RbSettings::TtsVoice).toString()));
updateDescription(settings->ttsVoice("festival")); updateDescription(settings->subValue("festival", RbSettings::TtsVoice).toString());
} }
void TTSFestivalGui::updateDescription(QString value) void TTSFestivalGui::updateDescription(QString value)

View file

@ -73,7 +73,7 @@ void UninstallWindow::setSettings(RbSettings *sett)
{ {
settings = sett; settings = sett;
QString mountpoint =settings->mountpoint(); QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
uninstaller = new Uninstaller(this,mountpoint); uninstaller = new Uninstaller(this,mountpoint);
// disable smart uninstall, if not possible // disable smart uninstall, if not possible

View file

@ -65,7 +65,8 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
version = version.left(version.indexOf("-")).remove(0,1); version = version.left(version.indexOf("-")).remove(0,1);
//prepare download url //prepare download url
QUrl genlangUrl = settings->genlangUrl() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features; QUrl genlangUrl = settings->value(RbSettings::GenlangUrl).toString()
+"?lang=" + m_lang + "&t=" + target + "&rev=" + version + "&f=" + features;
qDebug() << "downloading " << genlangUrl; qDebug() << "downloading " << genlangUrl;
@ -127,7 +128,7 @@ void VoiceFileCreator::downloadDone(bool error)
} }
//tts //tts
m_tts = TTSBase::getTTS(settings->curTTS()); m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings); m_tts->setCfg(settings);
QString errStr; QString errStr;
@ -141,7 +142,7 @@ void VoiceFileCreator::downloadDone(bool error)
} }
// Encoder // Encoder
m_enc = EncBase::getEncoder(settings->curEncoder()); m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings); m_enc->setCfg(settings);
if(!m_enc->start()) if(!m_enc->start())