summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-29 20:58:47 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-29 20:58:47 +0000
commit3d2e42ab4cc6306db4036983badea0c92750210b (patch)
treedd4303f36be8df6c4f808878da00963cb7316415 /rbutil
parent3c5e67516bfab95afc26f618840ca3db67998028 (diff)
downloadrockbox-3d2e42ab4cc6306db4036983badea0c92750210b.tar.gz
rockbox-3d2e42ab4cc6306db4036983badea0c92750210b.tar.bz2
rockbox-3d2e42ab4cc6306db4036983badea0c92750210b.zip
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
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/detect.cpp7
-rw-r--r--rbutil/rbutilqt/configure.cpp74
-rw-r--r--rbutil/rbutilqt/createvoicewindow.cpp20
-rw-r--r--rbutil/rbutilqt/encoders.cpp22
-rw-r--r--rbutil/rbutilqt/encodersgui.cpp24
-rw-r--r--rbutil/rbutilqt/install.cpp38
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp10
-rw-r--r--rbutil/rbutilqt/rbsettings.cpp556
-rw-r--r--rbutil/rbutilqt/rbsettings.h171
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp174
-rw-r--r--rbutil/rbutilqt/talkfile.cpp160
-rw-r--r--rbutil/rbutilqt/themesinstallwindow.cpp20
-rw-r--r--rbutil/rbutilqt/tts.cpp43
-rw-r--r--rbutil/rbutilqt/ttsgui.cpp59
-rw-r--r--rbutil/rbutilqt/uninstallwindow.cpp2
-rw-r--r--rbutil/rbutilqt/voicefile.cpp7
16 files changed, 552 insertions, 835 deletions
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/detect.cpp
index 74068618f6..df1cf50647 100644
--- a/rbutil/rbutilqt/base/detect.cpp
+++ b/rbutil/rbutilqt/base/detect.cpp
@@ -401,12 +401,13 @@ QString Detect::check(RbSettings* settings, bool permission)
}
// Check TargetId
- QString installed = installedTarget(settings->mountpoint());
- if(!installed.isEmpty() && installed != settings->curConfigure_Modelname())
+ QString installed = installedTarget(settings->value(RbSettings::Mountpoint).toString());
+ if(!installed.isEmpty() && installed != settings->value(RbSettings::CurConfigureModel).toString())
{
text += QObject::tr("<li>Target mismatch detected.\n"
"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())
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 3271818af4..5731dbe78a 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -103,20 +103,20 @@ void Config::accept()
proxy.setPort(ui.proxyPort->text().toInt());
}
- settings->setProxy(proxy.toString());
+ settings->setValue(RbSettings::Proxy, proxy.toString());
qDebug() << "new proxy:" << proxy;
// proxy type
QString proxyType;
if(ui.radioNoProxy->isChecked()) proxyType = "none";
else if(ui.radioSystemProxy->isChecked()) proxyType = "system";
else proxyType = "manual";
- settings->setProxyType(proxyType);
+ settings->setValue(RbSettings::ProxyType, proxyType);
// language
- if(settings->curLang() != language && !language.isEmpty()) {
+ if(settings->value(RbSettings::Language).toString() != language && !language.isEmpty()) {
QMessageBox::information(this, tr("Language changed"),
tr("You need to restart the application for the changed language to take effect."));
- settings->setLang(language);
+ settings->setValue(RbSettings::Language, language);
}
// mountpoint
@@ -138,14 +138,14 @@ void Config::accept()
error = true;
}
else {
- settings->setMountpoint(QDir::fromNativeSeparators(mp));
+ settings->setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp));
}
// platform
QString nplat;
if(ui.treeDevices->selectedItems().size() != 0) {
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
- settings->setCurPlatform(nplat);
+ settings->setValue(RbSettings::Platform, nplat);
}
else {
errormsg += "<li>" + tr("No player selected") + "</li>";
@@ -160,18 +160,18 @@ void Config::accept()
error = true;
}
else
- settings->setCachePath(ui.cachePath->text());
+ settings->setValue(RbSettings::CachePath, ui.cachePath->text());
}
else // default to system temp path
- settings->setCachePath(QDir::tempPath());
- settings->setCacheDisable(ui.cacheDisable->isChecked());
- settings->setCacheOffline(ui.cacheOfflineMode->isChecked());
+ settings->setValue(RbSettings::CachePath, QDir::tempPath());
+ settings->setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked());
+ settings->setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked());
// tts settings
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 += tr("You need to fix the above errors before you can continue.");
@@ -205,7 +205,7 @@ void Config::setSettings(RbSettings* sett)
void Config::setUserSettings()
{
// set proxy
- proxy = settings->proxy();
+ proxy = settings->value(RbSettings::Proxy).toString();
if(proxy.port() > 0)
ui.proxyPort->setText(QString("%1").arg(proxy.port()));
@@ -214,7 +214,7 @@ void Config::setUserSettings()
ui.proxyUser->setText(proxy.userName());
ui.proxyPass->setText(proxy.password());
- QString proxyType = settings->proxyType();
+ QString proxyType = settings->value(RbSettings::ProxyType).toString();
if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
else ui.radioNoProxy->setChecked(true);
@@ -224,12 +224,15 @@ void Config::setUserSettings()
QString b;
// find key for lang value
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()) {
- if(i.value() == settings->curLang()) {
+ if(i.value() == l) {
b = i.key();
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.)
b = i.key();
break;
@@ -244,15 +247,15 @@ void Config::setUserSettings()
connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
// devices tab
- ui.mountPoint->setText(QDir::toNativeSeparators(settings->mountpoint()));
+ ui.mountPoint->setText(QDir::toNativeSeparators(settings->value(RbSettings::Mountpoint).toString()));
// cache tab
- if(!QFileInfo(settings->cachePath()).isDir())
- settings->setCachePath(QDir::tempPath());
- ui.cachePath->setText(QDir::toNativeSeparators(settings->cachePath()));
- ui.cacheDisable->setChecked(settings->cacheDisabled());
- ui.cacheOfflineMode->setChecked(settings->cacheOffline());
- updateCacheInfo(settings->cachePath());
+ if(!QFileInfo(settings->value(RbSettings::CachePath).toString()).isDir())
+ settings->setValue(RbSettings::CachePath, QDir::tempPath());
+ ui.cachePath->setText(QDir::toNativeSeparators(settings->value(RbSettings::CachePath).toString()));
+ ui.cacheDisable->setChecked(settings->value(RbSettings::CacheDisabled).toBool());
+ ui.cacheOfflineMode->setChecked(settings->value(RbSettings::CacheOffline).toBool());
+ updateCacheInfo(settings->value(RbSettings::CachePath).toString());
}
@@ -276,7 +279,7 @@ void Config::setDevices()
// setup devices table
qDebug() << "Config::setDevices()";
- QStringList platformList = settings->allPlatforms();
+ QStringList platformList = settings->platforms();
QMap <QString, QString> manuf;
QMap <QString, QString> devcs;
@@ -289,7 +292,7 @@ void Config::setDevices()
}
QString platform;
- platform = devcs.value(settings->curPlatform());
+ platform = devcs.value(settings->value(RbSettings::Platform).toString());
// set up devices table
ui.treeDevices->header()->hide();
@@ -342,7 +345,7 @@ void Config::setDevices()
for(int a = 0; a < ttslist.size(); a++)
ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a));
//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;
ui.comboTts->setCurrentIndex(index);
updateTtsState(index);
@@ -377,11 +380,11 @@ void Config::updateEncState()
return;
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
- QString olddevice = settings->curPlatform();
- settings->setCurPlatform(devname);
- QString encoder = settings->curEncoder();
- ui.encoderName->setText(EncBase::getEncoderName(settings->curEncoder()));
- settings->setCurPlatform(olddevice);
+ QString olddevice = settings->value(RbSettings::Platform).toString();
+ settings->setValue(RbSettings::Platform, devname);
+ QString encoder = settings->value(RbSettings::CurEncoder).toString();
+ ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
+ settings->setValue(RbSettings::Platform, olddevice);
EncBase* enc = EncBase::getEncoder(encoder);
enc->setCfg(settings);
@@ -597,9 +600,10 @@ void Config::autodetect()
QString text;
// we need to set the platform here to get the brand from the
// settings object
- settings->setCurPlatform(detector.incompatdev());
+ settings->setValue(RbSettings::Platform, detector.incompatdev());
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"),
text, QMessageBox::Ok);
@@ -655,7 +659,7 @@ void Config::cacheClear()
QFile::remove(f);
qDebug() << "removed:" << f;
}
- updateCacheInfo(settings->cachePath());
+ updateCacheInfo(settings->value(RbSettings::CachePath).toString());
}
@@ -672,7 +676,7 @@ void Config::configTts()
void Config::configEnc()
{
- EncBase* enc = EncBase::getEncoder(settings->curEncoder());
+ EncBase* enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
enc->setCfg(settings);
enc->showCfg();
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp
index bb047cb196..2b45386589 100644
--- a/rbutil/rbutilqt/createvoicewindow.cpp
+++ b/rbutil/rbutilqt/createvoicewindow.cpp
@@ -49,14 +49,14 @@ void CreateVoiceWindow::accept()
int wvThreshold = ui.wavtrimthreshold->value();
//safe selected language
- settings->setVoiceLanguage(lang);
- settings->setWavtrimTh(wvThreshold);
+ settings->setValue(RbSettings::Language, lang);
+ settings->setValue(RbSettings::WavtrimThreshold, wvThreshold);
settings->sync();
//configure voicecreator
voicecreator->setSettings(settings);
- voicecreator->setMountPoint(settings->mountpoint());
- voicecreator->setTargetId(settings->curTargetId());
+ voicecreator->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
+ voicecreator->setTargetId(settings->value(RbSettings::CurTargetId).toInt());
voicecreator->setLang(lang);
voicecreator->setWavtrimThreshold(wvThreshold);
@@ -79,14 +79,14 @@ void CreateVoiceWindow::setSettings(RbSettings* sett)
void CreateVoiceWindow::updateSettings(void)
{
// fill in language combobox
- QStringList languages = settings->allLanguages();
+ QStringList languages = settings->languages();
languages.sort();
ui.comboLanguage->addItems(languages);
// 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(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(f.isEmpty()) f = "english";
sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith);
@@ -97,7 +97,7 @@ void CreateVoiceWindow::updateSettings(void)
}
ui.comboLanguage->setCurrentIndex(sel);
- QString ttsName = settings->curTTS();
+ QString ttsName = settings->value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(ttsName);
tts->setCfg(settings);
if(tts->configOk())
@@ -107,7 +107,7 @@ void CreateVoiceWindow::updateSettings(void)
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
.arg("Invalid TTS configuration!"));
- QString encoder = settings->curEncoder();
+ QString encoder = settings->value(RbSettings::CurEncoder).toString();
// only proceed if encoder setting is set
EncBase* enc = EncBase::getEncoder(encoder);
if(enc != NULL) {
@@ -122,7 +122,7 @@ void CreateVoiceWindow::updateSettings(void)
else
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!"));
- ui.wavtrimthreshold->setValue(settings->wavtrimTh());
+ ui.wavtrimthreshold->setValue(settings->value(RbSettings::WavtrimThreshold).toInt());
emit settingsUpdated();
}
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp
index dcd0e13c6d..a822b932f7 100644
--- a/rbutil/rbutilqt/encoders.cpp
+++ b/rbutil/rbutilqt/encoders.cpp
@@ -56,7 +56,7 @@ EncBase* EncBase::getEncoder(QString encoder)
return encoderCache.value(encoder);
EncBase* enc;
- if(encoder == "lame")
+ if(encoder == "lame")
{
enc = new EncExes(encoder);
encoderCache[encoder] = enc;
@@ -99,8 +99,8 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
bool EncExes::start()
{
- m_EncExec = settings->encoderPath(m_name);
- m_EncOpts = settings->encoderOptions(m_name);
+ m_EncExec = settings->subValue(m_name, RbSettings::EncoderPath).toString();
+ m_EncOpts = settings->subValue(m_name, RbSettings::EncoderOptions).toString();
m_EncTemplate = m_TemplateMap.value(m_name);
@@ -144,7 +144,7 @@ void EncExes::showCfg()
bool EncExes::configOk()
{
- QString path = settings->encoderPath(m_name);
+ QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
if (QFileInfo(path).exists())
return true;
@@ -171,10 +171,10 @@ bool EncRbSpeex::start()
{
// try to get config from settings
- quality = settings->encoderQuality("rbspeex");
- complexity = settings->encoderComplexity("rbspeex");
- volume = settings->encoderVolume("rbspeex");
- narrowband = settings->encoderNarrowband("rbspeex");
+ quality = settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble();
+ complexity = settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt();
+ volume = settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble();
+ narrowband = settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool();
return true;
@@ -227,13 +227,13 @@ bool EncRbSpeex::configOk()
bool result=true;
// check config
- if(settings->encoderVolume("rbspeex") <= 0)
+ if(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
result =false;
- if(settings->encoderQuality("rbspeex") <= 0)
+ if(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
result =false;
- if(settings->encoderComplexity("rbspeex") <= 0)
+ if(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
result =false;
return result;
diff --git a/rbutil/rbutilqt/encodersgui.cpp b/rbutil/rbutilqt/encodersgui.cpp
index 82bd8650fb..3d1619f807 100644
--- a/rbutil/rbutilqt/encodersgui.cpp
+++ b/rbutil/rbutilqt/encodersgui.cpp
@@ -34,8 +34,8 @@ void EncExesGui::showCfg(QString name)
{
m_name = name;
// try to get config from settings
- QString exepath =settings->encoderPath(m_name);
- ui.encoderoptions->setText(settings->encoderOptions(m_name));
+ QString exepath =settings->subValue(m_name, RbSettings::EncoderPath).toString();
+ ui.encoderoptions->setText(settings->subValue(m_name, RbSettings::EncoderOptions).toString());
if(exepath == "")
{
@@ -75,8 +75,8 @@ void EncExesGui::showCfg(QString name)
void EncExesGui::accept(void)
{
//save settings in user config
- settings->setEncoderPath(m_name,ui.encoderpath->text());
- settings->setEncoderOptions(m_name,ui.encoderoptions->text());
+ settings->setSubValue(m_name, RbSettings::EncoderPath, ui.encoderpath->text());
+ settings->setSubValue(m_name, RbSettings::EncoderOptions, ui.encoderoptions->text());
// sync settings
settings->sync();
@@ -130,11 +130,11 @@ void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
defaultBand =defB;
//fill in the usersettings
- ui.volume->setValue(settings->encoderVolume("rbspeex"));
- ui.quality->setValue(settings->encoderQuality("rbspeex"));
- ui.complexity->setValue(settings->encoderComplexity("rbspeex"));
+ ui.volume->setValue(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble());
+ ui.quality->setValue(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble());
+ 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);
else
ui.narrowband->setCheckState(Qt::Unchecked);
@@ -146,10 +146,10 @@ void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
void EncRbSpeexGui::accept(void)
{
//save settings in user config
- settings->setEncoderVolume("rbspeex",ui.volume->value());
- settings->setEncoderQuality("rbspeex",ui.quality->value());
- settings->setEncoderComplexity("rbspeex",ui.complexity->value());
- settings->setEncoderNarrowband("rbspeex",ui.narrowband->isChecked() ? true : false);
+ settings->setSubValue("rbspeex", RbSettings::EncoderVolume, ui.volume->value());
+ settings->setSubValue("rbspeex", RbSettings::EncoderQuality, ui.quality->value());
+ settings->setSubValue("rbspeex", RbSettings::EncoderComplexity, ui.complexity->value());
+ settings->setSubValue("rbspeex", RbSettings::EncoderNarrowBand, ui.narrowband->isChecked() ? true : false);
// sync settings
settings->sync();
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index b1020b8982..2332a713c4 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -34,12 +34,12 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
//! check if rockbox is already installed
- QString version = Detect::installedVersion(settings->mountpoint());
+ QString version = Detect::installedVersion(settings->value(RbSettings::Mountpoint).toString());
if(version != "")
{
ui.Backupgroup->show();
- m_backupName = settings->mountpoint();
+ m_backupName = settings->value(RbSettings::Mountpoint).toString();
if(!m_backupName.endsWith("/")) m_backupName += "/";
m_backupName += ".backup/rockbox-backup-"+version+".zip";
// for some reason the label doesn't return its final size yet.
@@ -91,8 +91,8 @@ void Install::accept()
{
logger = new ProgressLoggerGui(this);
logger->show();
- QString mountPoint = settings->mountpoint();
- qDebug() << "mountpoint:" << settings->mountpoint();
+ QString mountPoint = settings->value(RbSettings::Mountpoint).toString();
+ qDebug() << "mountpoint:" << settings->value(RbSettings::Mountpoint).toString();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -101,30 +101,30 @@ void Install::accept()
}
QString myversion;
- QString buildname = settings->curBuildserver_Modelname();
+ QString buildname = settings->value(RbSettings::CurBuildserverModel).toString();
if(ui.radioStable->isChecked()) {
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"));
fileName = QString("rockbox-%1-%2.zip")
.arg(version.value("rel_rev"), buildname);
- settings->setBuild("stable");
+ settings->setValue(RbSettings::Build, "stable");
myversion = version.value("rel_rev");
}
else if(ui.radioArchived->isChecked()) {
file = QString("%1%2/rockbox-%3-%4.zip")
- .arg(settings->dailyUrl(),
+ .arg(settings->value(RbSettings::DailyUrl).toString(),
buildname, buildname, version.value("arch_date"));
fileName = QString("rockbox-%1-%2.zip")
.arg(buildname, version.value("arch_date"));
- settings->setBuild("archived");
+ settings->setValue(RbSettings::Build, "archived");
myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date");
}
else if(ui.radioCurrent->isChecked()) {
file = QString("%1%2/rockbox.zip")
- .arg(settings->bleedingUrl(), buildname);
+ .arg(settings->value(RbSettings::BleedingUrl).toString(), buildname);
fileName = QString("rockbox.zip");
- settings->setBuild("current");
+ settings->setValue(RbSettings::Build, "current");
myversion = "r" + version.value("bleed_rev");
}
else {
@@ -162,7 +162,8 @@ void Install::accept()
//! create backup
RbZip backup;
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);
}
@@ -178,7 +179,7 @@ void Install::accept()
installer = new ZipInstaller(this);
installer->setUrl(file);
installer->setLogSection("Rockbox (Base)");
- if(!settings->cacheDisabled()
+ if(!settings->value(RbSettings::CacheDisabled).toBool()
&& !ui.checkBoxCache->isChecked())
{
installer->setCache(true);
@@ -218,9 +219,9 @@ void Install::done(bool error)
// no error, close the window, when the logger is closed
connect(logger,SIGNAL(closed()),this,SLOT(close()));
// 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);
- installlog.setValue("platform", settings->curPlatform());
+ installlog.setValue("platform", settings->value(RbSettings::Platform).toString());
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
// 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);
- else if(settings->build() == "archived")
+ else if(settings->value(RbSettings::Build).toString() == "archived")
ui.radioArchived->setChecked(true);
- else if(settings->build() == "current")
+ else if(settings->value(RbSettings::Build).toString() == "current")
ui.radioCurrent->setChecked(true);
else if(!version.value("rel_rev").isEmpty()) {
ui.radioStable->setChecked(true);
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index 0d2267e9f4..4caaa4fbc7 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -88,13 +88,13 @@ void InstallTalkWindow::accept()
return;
}
- settings->setLastTalkedDir(folderToTalk);
+ settings->setValue(RbSettings::LastTalkedFolder, folderToTalk);
settings->sync();
talkcreator->setSettings(settings);
talkcreator->setDir(QDir(folderToTalk));
- talkcreator->setMountPoint(settings->mountpoint());
+ talkcreator->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
talkcreator->setRecursive(ui.recursive->isChecked());
@@ -115,7 +115,7 @@ void InstallTalkWindow::setSettings(RbSettings* sett)
void InstallTalkWindow::updateSettings(void)
{
- QString ttsName = settings->curTTS();
+ QString ttsName = settings->value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(ttsName);
tts->setCfg(settings);
if(tts->configOk())
@@ -125,7 +125,7 @@ void InstallTalkWindow::updateSettings(void)
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
.arg("Invalid TTS configuration!"));
- QString encoder = settings->curEncoder();
+ QString encoder = settings->value(RbSettings::CurEncoder).toString();
EncBase* enc = EncBase::getEncoder(encoder);
if(enc != NULL) {
enc->setCfg(settings);
@@ -140,7 +140,7 @@ void InstallTalkWindow::updateSettings(void)
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!"));
- setTalkFolder(settings->lastTalkedFolder());
+ setTalkFolder(settings->value(RbSettings::LastTalkedFolder).toString());
emit settingsUpdated();
}
diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp
index 5a60a67c1b..12654cd288 100644
--- a/rbutil/rbutilqt/rbsettings.cpp
+++ b/rbutil/rbutilqt/rbsettings.cpp
@@ -25,10 +25,79 @@
#include <unistd.h>
#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()
{
// 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:
// check for a configuration file in the program folder.
QFileInfo config;
@@ -74,331 +143,99 @@ void RbSettings::sync()
#endif
}
-QVariant RbSettings::deviceSettingCurGet(QString entry,QString def)
-{
- QString platform = userSettings->value("platform").toString();
- devices->beginGroup(platform);
- QVariant result = devices->value(entry,def);
- devices->endGroup();
- return result;
-}
-QVariant RbSettings::userSettingsGroupGet(QString group,QString entry,QVariant def)
+QVariant RbSettings::value(enum SystemSettings setting)
{
- userSettings->beginGroup(group);
- QVariant result = userSettings->value(entry,def);
- userSettings->endGroup();
- return result;
-}
+ // locate setting item
+ int i = 0;
+ while(SystemSettingsList[i].setting != setting)
+ i++;
-void RbSettings::userSettingsGroupSet(QString group,QString entry,QVariant value)
-{
- userSettings->beginGroup(group);
- userSettings->setValue(entry,value);
- userSettings->endGroup();
+ 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);
}
+
QString RbSettings::userSettingFilename()
{
return userSettings->fileName();
}
-QString RbSettings::curVersion()
-{
- return userSettings->value("rbutil_version").toString();
-}
-
-bool RbSettings::cacheOffline()
-{
- return userSettings->value("offline").toBool();
-}
-
-QString RbSettings::mountpoint()
-{
- return userSettings->value("mountpoint").toString();
-}
-
-QString RbSettings::manualUrl()
-{
- return devices->value("manual_url").toString();
-}
-
-QString RbSettings::bleedingUrl()
-{
- 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()
+QVariant RbSettings::subValue(QString& sub, enum UserSettings setting)
{
- return userSettings->value("last_talked_folder").toString();
-}
+ // locate setting item
+ int i = 0;
+ while(UserSettingsList[i].setting != setting)
+ i++;
-QString RbSettings::voiceLanguage()
-{
- return userSettings->value("voicelanguage").toString();
+ QString s = constructSettingPath(UserSettingsList[i].name, sub);
+ qDebug() << "[Settings] GET U:" << s << userSettings->value(s).toString();
+ return userSettings->value(s, UserSettingsList[i].def);
}
-int RbSettings::wavtrimTh()
-{
- return userSettings->value("wavtrimthreshold",500).toInt();
-}
-QString RbSettings::ttsPath(QString tts)
-{
- return userSettingsGroupGet(tts,"ttspath").toString();
-}
-QString RbSettings::ttsOptions(QString tts)
+void RbSettings::setSubValue(QString& sub, enum UserSettings setting, QVariant value)
{
- 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();
-}
+ // locate setting item
+ int i = 0;
+ while(UserSettingsList[i].setting != setting)
+ i++;
-bool RbSettings::ttsUseSapi4()
-{
- return userSettingsGroupGet("sapi","useSapi4",false).toBool();
+ QString s = constructSettingPath(UserSettingsList[i].name, sub);
+ qDebug() << "[Settings] SET U:" << s << userSettings->value(s).toString();
+ userSettings->setValue(s, value);
}
-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 RbSettings::platforms()
{
QStringList result;
- devices->beginGroup("platforms");
- QStringList a = devices->childKeys();
+ systemSettings->beginGroup("platforms");
+ QStringList a = systemSettings->childKeys();
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;
}
-QStringList RbSettings::allLanguages()
+QStringList RbSettings::languages()
{
QStringList result;
- devices->beginGroup("languages");
- QStringList a = devices->childKeys();
+ systemSettings->beginGroup("languages");
+ QStringList a = systemSettings->childKeys();
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;
}
-QString RbSettings::name(QString plattform)
+QString RbSettings::name(QString platform)
{
- devices->beginGroup(plattform);
- QString name = devices->value("name").toString();
- devices->endGroup();
- return name;
+ return systemSettings->value(platform + "/name").toString();
}
-QString RbSettings::brand(QString plattform)
+QString RbSettings::brand(QString platform)
{
- devices->beginGroup(plattform);
- QString brand = devices->value("brand").toString();
- devices->endGroup();
- return brand;
+ return systemSettings->value(platform + "/brand").toString();
}
QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
{
QMap<int, QString> map;
- // get a list of ID -> target name
+ // get a list of ID -> target name
QStringList platforms;
- devices->beginGroup("platforms");
- platforms = devices->childKeys();
- devices->endGroup();
+ systemSettings->beginGroup("platforms");
+ platforms = systemSettings->childKeys();
+ systemSettings->endGroup();
QString t;
switch(type) {
@@ -415,161 +252,34 @@ QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
for(int i = 0; i < platforms.size(); i++)
{
- devices->beginGroup("platforms");
- QString target = devices->value(platforms.at(i)).toString();
- devices->endGroup();
- devices->beginGroup(target);
- QStringList ids = devices->value(t).toStringList();
+ systemSettings->beginGroup("platforms");
+ QString target = systemSettings->value(platforms.at(i)).toString();
+ systemSettings->endGroup();
+ systemSettings->beginGroup(target);
+ QStringList ids = systemSettings->value(t).toStringList();
int j = ids.size();
while(j--)
map.insert(ids.at(j).toInt(0, 16), target);
- devices->endGroup();
+ systemSettings->endGroup();
}
return map;
}
-QString RbSettings::curResolution()
-{
- return deviceSettingCurGet("resolution").toString();
-}
-
-int RbSettings::curTargetId()
-{
- return deviceSettingCurGet("targetid").toInt();
-}
-
-void RbSettings::setCurVersion(QString version)
-{
- userSettings->setValue("rbutil_version",version);
-}
-
-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)
+QString RbSettings::constructSettingPath(QString path, QString substitute)
{
- 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);
-}
+ QString platform = userSettings->value("platform").toString();
+ if(!substitute.isEmpty()) {
+ path.replace(":tts:", substitute);
+ path.replace(":encoder:", substitute);
+ }
+ else {
+ path.replace(":tts:", userSettings->value("tts").toString());
+ path.replace(":encoder:", systemSettings->value(platform + "/encoder").toString());
+ }
+ path.replace(":platform:", platform);
-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);
+ return path;
}
diff --git a/rbutil/rbutilqt/rbsettings.h b/rbutil/rbutilqt/rbsettings.h
index 339c835d4a..341577abc8 100644
--- a/rbutil/rbutilqt/rbsettings.h
+++ b/rbutil/rbutilqt/rbsettings.h
@@ -46,118 +46,97 @@ class RbSettings : public QObject
MapError,
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,
+ };
+
+ QVariant value(enum SystemSettings setting);
+ // generic and "current selection" values -- getters
+ QVariant value(enum UserSettings setting)
+ { QString empty; return subValue(empty, setting); }
+ void setValue(enum UserSettings setting , QVariant value)
+ { QString empty; return setSubValue(empty, setting, value); }
- //! access functions for the settings
- QString curVersion();
- bool cacheOffline();
- bool cacheDisabled();
- QString mountpoint();
- QString manualUrl();
- 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);
- QStringList allLanguages(void);
+ QVariant subValue(QString& sub, enum UserSettings setting);
+ 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 brand(QString plattform);
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:
-
- //! 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
RbSettings& operator= (const RbSettings& other)
{ (void)other; return *this; }
RbSettings(const RbSettings& other) :QObject()
{ (void)other; }
+ QString constructSettingPath(QString path, QString substitute = QString());
//! pointers to our setting objects
- QSettings *devices;
+ QSettings *systemSettings;
QSettings *userSettings;
-
};
#endif
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 11dbe153e5..e126b0ec45 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -154,13 +154,13 @@ void RbUtilQt::downloadInfo()
connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
- if(settings->cacheOffline())
+ if(settings->value(RbSettings::CacheOffline).toBool())
daily->setCache(true);
else
daily->setCache(false);
qDebug() << "downloading build info";
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());
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();
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(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
- if(settings->cacheOffline())
+ if(settings->value(RbSettings::CacheOffline).toBool())
bleeding->setCache(true);
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();
QMessageBox::information(this, tr("New installation"),
tr("This is a new installation of Rockbox Utility, or a new version. "
@@ -303,23 +303,23 @@ void RbUtilQt::updateSettings()
qDebug() << "updateSettings()";
updateDevice();
updateManual();
- if(settings->proxyType() == "system") {
+ if(settings->value(RbSettings::ProxyType) == "system") {
HttpGet::setGlobalProxy(Detect::systemProxy());
}
- else if(settings->proxyType() == "manual") {
- HttpGet::setGlobalProxy(settings->proxy());
+ else if(settings->value(RbSettings::ProxyType) == "manual") {
+ HttpGet::setGlobalProxy(settings->value(RbSettings::Proxy).toString());
}
else {
HttpGet::setGlobalProxy(QUrl(""));
}
- HttpGet::setGlobalCache(settings->cachePath());
- HttpGet::setGlobalDumbCache(settings->cacheOffline());
+ HttpGet::setGlobalCache(settings->value(RbSettings::CachePath).toString());
+ HttpGet::setGlobalDumbCache(settings->value(RbSettings::CacheOffline).toBool());
}
void RbUtilQt::updateDevice()
{
- if(settings->curBootloaderMethod() == "none" ) {
+ if(settings->value(RbSettings::CurBootloaderMethod) == "none" ) {
ui.buttonBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
ui.labelBootloader->setEnabled(false);
@@ -328,7 +328,7 @@ void RbUtilQt::updateDevice()
else {
ui.buttonBootloader->setEnabled(true);
ui.labelBootloader->setEnabled(true);
- if(settings->curBootloaderMethod() == "fwpatcher") {
+ if(settings->value(RbSettings::CurBootloaderMethod) == "fwpatcher") {
ui.labelRemoveBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
}
@@ -339,9 +339,9 @@ void RbUtilQt::updateDevice()
}
// displayed device info
- QString mountpoint = settings->mountpoint();
- QString brand = settings->curBrand();
- QString name = settings->curName();
+ QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
+ QString brand = settings->value(RbSettings::CurBrand).toString();
+ QString name = settings->value(RbSettings::CurName).toString();
if(name.isEmpty()) name = "&lt;none&gt;";
if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
@@ -351,16 +351,18 @@ void RbUtilQt::updateDevice()
void RbUtilQt::updateManual()
{
- if(settings->curPlatform() != "")
+ if(settings->value(RbSettings::Platform) != "")
{
- QString manual= settings->curManual();
+ QString manual= settings->value(RbSettings::CurManual).toString();
if(manual == "")
- manual = "rockbox-" + settings->curPlatform();
+ manual = "rockbox-" + settings->value(RbSettings::Platform).toString();
QString pdfmanual;
- pdfmanual = settings->manualUrl() + "/" + manual + ".pdf";
+ pdfmanual = settings->value(RbSettings::ManualUrl).toString()
+ + "/" + manual + ".pdf";
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>")
.arg(pdfmanual));
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
@@ -453,7 +455,7 @@ void RbUtilQt::smallInstall()
bool RbUtilQt::smallInstallInner()
{
- QString mountpoint = settings->mountpoint();
+ QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -461,7 +463,7 @@ bool RbUtilQt::smallInstallInner()
return true;
}
// Bootloader
- if(settings->curBootloaderMethod() != "none")
+ if(settings->value(RbSettings::CurBootloaderMethod) != "none")
{
m_error = false;
m_installed = false;
@@ -513,14 +515,16 @@ void RbUtilQt::installBtn()
bool RbUtilQt::installAuto()
{
QString file = QString("%1/%2/rockbox-%3-%4.zip")
- .arg(settings->releaseUrl(), versmap.value("rel_rev"),
- settings->curBuildserver_Modelname(), versmap.value("rel_rev"));
+ .arg(settings->value(RbSettings::ReleaseUrl).toString(),
+ versmap.value("rel_rev"),
+ settings->value(RbSettings::CurBuildserverModel).toString(),
+ versmap.value("rel_rev"));
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
// 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);
if(!warning.isEmpty())
@@ -542,7 +546,7 @@ bool RbUtilQt::installAuto()
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{
logger->addItem(tr("Starting backup..."),LOGINFO);
- QString backupName = settings->mountpoint()
+ QString backupName = settings->value(RbSettings::Mountpoint).toString()
+ "/.backup/rockbox-backup-" + rbVersion + ".zip";
//! create dir, if it doesnt exist
@@ -556,7 +560,8 @@ bool RbUtilQt::installAuto()
//! create backup
RbZip backup;
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);
}
@@ -574,9 +579,9 @@ bool RbUtilQt::installAuto()
installer->setUrl(file);
installer->setLogSection("Rockbox (Base)");
installer->setLogVersion(versmap.value("rel_rev"));
- if(!settings->cacheDisabled())
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
- installer->setMountPoint(settings->mountpoint());
+ installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
@@ -618,13 +623,13 @@ void RbUtilQt::installBootloaderBtn()
void RbUtilQt::installBootloader()
{
- QString platform = settings->curPlatform();
+ QString platform = settings->value(RbSettings::Platform).toString();
QString backupDestination = "";
m_error = false;
// create installer
BootloaderInstallBase *bl;
- QString type = settings->curBootloaderMethod();
+ QString type = settings->value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") {
bl = new BootloaderInstallMi4(this);
}
@@ -648,21 +653,24 @@ void RbUtilQt::installBootloader()
// set bootloader filename. Do this now as installed() needs it.
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
// bootloader file filename. This is handled here to keep the install
// class clean, though having it here is also not the nicest solution.
- if(platform == "h10_ums"
- || platform == "h10_mtp") {
+ if(settings->value(RbSettings::Platform).toString() == "h10_ums"
+ || settings->value(RbSettings::Platform) == "h10_mtp") {
if(resolvePathCase(blfile).isEmpty())
- blfile = settings->mountpoint()
- + settings->curBootloaderName().replace("H10",
- "H10EMP", Qt::CaseInsensitive);
+ blfile = settings->value(RbSettings::Mountpoint).toString()
+ + settings->value(RbSettings::CurBootloaderName).toString()
+ .replace("H10", "H10EMP", Qt::CaseInsensitive);
}
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->setLogfile(settings->mountpoint() + "/.rockbox/rbutil.log");
+ bl->setLogfile(settings->value(RbSettings::Mountpoint).toString()
+ + "/.rockbox/rbutil.log");
if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
if(QMessageBox::question(this, tr("Bootloader detected"),
@@ -684,7 +692,8 @@ void RbUtilQt::installBootloader()
else if(bl->installed() == BootloaderInstallBase::BootloaderOther
&& bl->capabilities() & BootloaderInstallBase::Backup)
{
- QString targetFolder = settings->curPlatform() + " Firmware Backup";
+ QString targetFolder = settings->value(RbSettings::CurPlatformName).toString()
+ + " Firmware Backup";
// remove invalid character(s)
targetFolder.remove(QRegExp("[:/]"));
if(QMessageBox::question(this, tr("Create Bootloader backup"),
@@ -777,7 +786,8 @@ void RbUtilQt::installBootloaderPost(bool error)
if(m_auto)
return;
- QString msg = BootloaderInstallBase::postinstallHints(settings->curPlatform());
+ QString msg = BootloaderInstallBase::postinstallHints(
+ settings->value(RbSettings::Platform).toString());
if(!msg.isEmpty()) {
QMessageBox::information(this, tr("Manual steps required"), msg);
logger->close();
@@ -809,11 +819,11 @@ void RbUtilQt::installFonts()
// create zip installer
installer = new ZipInstaller(this);
- installer->setUrl(settings->fontUrl());
+ installer->setUrl(settings->value(RbSettings::FontUrl).toString());
installer->setLogSection("Fonts");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(settings->mountpoint());
- if(!settings->cacheDisabled())
+ installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
@@ -843,17 +853,17 @@ void RbUtilQt::installVoice()
// create zip installer
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";
qDebug() << voiceurl;
installer->setUrl(voiceurl);
installer->setLogSection("Voice");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(settings->mountpoint());
- if(!settings->cacheDisabled())
+ installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
installer->install(logger);
@@ -885,7 +895,8 @@ bool RbUtilQt::installDoomAuto()
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();
}
@@ -894,11 +905,11 @@ void RbUtilQt::installDoom()
// create zip installer
installer = new ZipInstaller(this);
- installer->setUrl(settings->doomUrl());
+ installer->setUrl(settings->value(RbSettings::DoomUrl).toString());
installer->setLogSection("Game Addons");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(settings->mountpoint());
- if(!settings->cacheDisabled())
+ installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
installer->install(logger);
@@ -957,11 +968,11 @@ void RbUtilQt::uninstallBootloader(void)
logger->setProgressVisible(false);
logger->show();
- QString platform = settings->curPlatform();
+ QString platform = settings->value(RbSettings::Platform).toString();
// create installer
BootloaderInstallBase *bl;
- QString type = settings->curBootloaderMethod();
+ QString type = settings->value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") {
bl = new BootloaderInstallMi4();
}
@@ -983,13 +994,14 @@ void RbUtilQt::uninstallBootloader(void)
return;
}
- QString blfile = settings->mountpoint() + settings->curBootloaderFile();
- if(settings->curPlatform() == "h10_ums"
- || settings->curPlatform() == "h10_mtp") {
+ QString blfile = settings->value(RbSettings::Mountpoint).toString()
+ + settings->value(RbSettings::CurBootloaderFile).toString();
+ if(settings->value(RbSettings::Platform).toString() == "h10_ums"
+ || settings->value(RbSettings::Platform).toString() == "h10_mtp") {
if(resolvePathCase(blfile).isEmpty())
- blfile = settings->mountpoint()
- + settings->curBootloaderName().replace("H10",
- "H10EMP", Qt::CaseInsensitive);
+ blfile = settings->value(RbSettings::Mountpoint).toString()
+ + settings->value(RbSettings::CurBootloaderName).toString()
+ .replace("H10", "H10EMP", Qt::CaseInsensitive);
}
bl->setBlFile(blfile);
@@ -1017,7 +1029,7 @@ void RbUtilQt::downloadManual(void)
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
- QString manual = settings->curManual();
+ QString manual = settings->value(RbSettings::CurManual).toString();
QString date = (info.value("dailies/date").toString());
@@ -1032,14 +1044,14 @@ void RbUtilQt::downloadManual(void)
target = "/" + manual + "-" + date + "-html.zip";
section = "Manual (HTML)";
}
- manualurl = settings->manualUrl() + "/" + target;
+ manualurl = settings->value(RbSettings::ManualUrl).toString() + "/" + target;
qDebug() << "manualurl =" << manualurl;
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
installer = new ZipInstaller(this);
- installer->setMountPoint(settings->mountpoint());
- if(!settings->cacheDisabled())
+ installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
installer->setLogSection(section);
installer->setLogVersion(date);
@@ -1065,24 +1077,28 @@ void RbUtilQt::installPortable(void)
logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
// check mountpoint
- if(!QFileInfo(settings->mountpoint()).isDir()) {
+ if(!QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
return;
}
// remove old files first.
- QFile::remove(settings->mountpoint() + "/RockboxUtility.exe");
- QFile::remove(settings->mountpoint() + "/RockboxUtility.ini");
+ QFile::remove(settings->value(RbSettings::Mountpoint).toString()
+ + "/RockboxUtility.exe");
+ QFile::remove(settings->value(RbSettings::Mountpoint).toString()
+ + "/RockboxUtility.ini");
// 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")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
logger->abort();
return;
}
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")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR);
logger->abort();
@@ -1100,8 +1116,8 @@ void RbUtilQt::updateInfo()
{
qDebug() << "RbUtilQt::updateInfo()";
- QSettings log(settings->mountpoint() + "/.rockbox/rbutil.log",
- QSettings::IniFormat, this);
+ QSettings log(settings->value(RbSettings::Mountpoint).toString()
+ + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
QStringList groups = log.childGroups();
QList<QTreeWidgetItem *> items;
QTreeWidgetItem *w, *w2;
@@ -1137,7 +1153,7 @@ void RbUtilQt::updateInfo()
for(int b = 0; b < keys.size(); b++) {
QString file;
- file = settings->mountpoint() + "/" + keys.at(b);
+ file = settings->value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
if(QFileInfo(file).isDir())
continue;
w2 = new QTreeWidgetItem(w, QStringList() << "/"
@@ -1162,9 +1178,9 @@ void RbUtilQt::updateInfo()
QUrl RbUtilQt::proxy()
{
- if(settings->proxyType() == "manual")
- return QUrl(settings->proxy());
- else if(settings->proxy() == "system")
+ if(settings->value(RbSettings::ProxyType) == "manual")
+ return QUrl(settings->value(RbSettings::Proxy).toString());
+ else if(settings->value(RbSettings::ProxyType) == "system")
return Detect::systemProxy();
return QUrl("");
}
@@ -1173,9 +1189,9 @@ QUrl RbUtilQt::proxy()
bool RbUtilQt::chkConfig(bool warn)
{
bool error = false;
- if(settings->curPlatform().isEmpty()
- || settings->mountpoint().isEmpty()
- || !QFileInfo(settings->mountpoint()).isWritable()) {
+ if(settings->value(RbSettings::Platform).toString().isEmpty()
+ || settings->value(RbSettings::Mountpoint).toString().isEmpty()
+ || !QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isWritable()) {
error = true;
if(warn) QMessageBox::critical(this, tr("Configuration error"),
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp
index 43993be436..6e872ad281 100644
--- a/rbutil/rbutilqt/talkfile.cpp
+++ b/rbutil/rbutilqt/talkfile.cpp
@@ -24,25 +24,25 @@ TalkFileCreator::TalkFileCreator(QObject* parent): QObject(parent)
}
-//! \brief Creates Talkfiles.
+//! \brief Creates Talkfiles.
//!
//! \param logger A pointer to a Loggerobject
bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
{
m_abort = false;
m_logger = logger;
-
+
QMultiMap<QString,QString> fileList;
QMultiMap<QString,QString> dirList;
QStringList toSpeakList, voicedEntries, encodedEntries;
QString errStr;
-
+
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
-
+
//tts
- m_tts = TTSBase::getTTS(settings->curTTS());
+ m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings);
-
+
if(!m_tts->start(&errStr))
{
m_logger->addItem(errStr.trimmed(),LOGERROR);
@@ -52,9 +52,9 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
}
// Encoder
- m_enc = EncBase::getEncoder(settings->curEncoder());
+ m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings);
-
+
if(!m_enc->start())
{
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()));
m_logger->setProgressMax(0);
-
+
// read in Maps of paths - file/dirnames
m_logger->addItem(tr("Reading Filelist..."),LOGINFO);
if(createDirAndFileMaps(m_dir,&dirList,&fileList) == false)
@@ -76,21 +76,21 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList);
return false;
}
-
+
// create List of all Files/Dirs to speak
QMapIterator<QString, QString> dirIt(dirList);
- while (dirIt.hasNext())
+ while (dirIt.hasNext())
{
dirIt.next();
// insert only non dublicate dir entries into list
if(!toSpeakList.contains(dirIt.value()))
{
qDebug() << "toSpeaklist dir:" << dirIt.value();
- toSpeakList.append(dirIt.value());
+ toSpeakList.append(dirIt.value());
}
}
QMapIterator<QString, QString> fileIt(fileList);
- while (fileIt.hasNext())
+ while (fileIt.hasNext())
{
fileIt.next();
// insert only non- dublictae file entries into list
@@ -99,10 +99,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
if(m_stripExtensions)
toSpeakList.append(stripExtension(fileIt.value()));
else
- toSpeakList.append(fileIt.value());
+ toSpeakList.append(fileIt.value());
}
}
-
+
// Voice entries
m_logger->addItem(tr("Voicing entries..."),LOGINFO);
TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries);
@@ -111,7 +111,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList);
return false;
}
-
+
// Encoding Entries
m_logger->addItem(tr("Encoding files..."),LOGINFO);
if(encodeList(voicedEntries,encodedEntries) == false)
@@ -119,25 +119,25 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
doAbort(toSpeakList);
return false;
}
-
- // Copying talk files
+
+ // Copying talk files
m_logger->addItem(tr("Copying Talkfile for Dirs..."),LOGINFO);
if(copyTalkDirFiles(dirList,&errStr) == false)
{
m_logger->addItem(errStr,LOGERROR);
- doAbort(toSpeakList);
+ doAbort(toSpeakList);
return false;
}
-
+
//Copying file talk files
m_logger->addItem(tr("Copying Talkfile for Files..."),LOGINFO);
if(copyTalkFileFiles(fileList,&errStr) == false)
{
m_logger->addItem(errStr,LOGERROR);
- doAbort(toSpeakList);
+ doAbort(toSpeakList);
return false;
}
-
+
// Deleting left overs
if( !cleanup(toSpeakList))
return false;
@@ -184,7 +184,7 @@ void TalkFileCreator::doAbort(QStringList cleanupList)
m_logger->setProgressValue(0);
m_logger->abort();
m_tts->stop();
- m_enc->stop();
+ m_enc->stop();
}
//! \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 dirMap The MulitMap where the dirs 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)
{
// create Iterator
QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
if(m_recursive)
flags = QDirIterator::Subdirectories;
-
+
QDirIterator it(startDir,flags);
-
+
// read in Maps of paths - file/dirnames
while (it.hasNext())
{
@@ -212,14 +212,14 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri
{
return false;
}
-
+
QFileInfo fileInf = it.fileInfo();
-
+
// its a dir
if(fileInf.isDir())
{
QDir dir = fileInf.dir();
-
+
// insert into List
if(!dir.dirName().isEmpty() && m_talkFolders)
{
@@ -238,7 +238,7 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri
}
QCoreApplication::processEvents();
}
- return true;
+ return true;
}
//! \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);
return FatalError;
}
-
+
QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav";
-
+
QString error;
TTSStatus status = m_tts->voice(toSpeak[i],filename, &error);
if(status == Warning)
{
- warnings = true;
+ warnings = true;
m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error),
- LOGWARNING);
+ LOGWARNING);
}
else if (status == FatalError)
{
- m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error),
- LOGERROR);
- return FatalError;
- }
+ m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error),
+ LOGERROR);
+ return FatalError;
+ }
else
- voicedEntries.append(toSpeak[i]);
+ voicedEntries.append(toSpeak[i]);
m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents();
}
if(warnings)
- return Warning;
+ return Warning;
else
- return NoError;
+ return NoError;
}
//! \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 errString pointer to where the Error cause is written
@@ -301,21 +301,21 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie
{
if(m_abort)
{
- m_logger->addItem(tr("Talk file creation aborted"), LOGERROR);
+ m_logger->addItem(tr("Talk file creation aborted"), LOGERROR);
return false;
}
-
+
QString wavfilename = QDir::tempPath()+ "/"+ toEncode[i] + ".wav";
QString filename = QDir::tempPath()+ "/"+ toEncode[i] + ".talk";
-
+
if(!m_enc->encode(wavfilename,filename))
{
m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR);
return false;
- }
+ }
encodedEntries.append(toEncode[i]);
m_logger->setProgressValue(++m_progress);
- QCoreApplication::processEvents();
+ QCoreApplication::processEvents();
}
return true;
}
@@ -324,16 +324,16 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie
//!
//! \param dirMap a MultiMap of Paths -> Dirnames
//! \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)
{
resetProgress(dirMap.size());
-
+
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup("talkfiles");
-
+
QMapIterator<QString, QString> it(dirMap);
- while (it.hasNext())
+ while (it.hasNext())
{
it.next();
if(m_abort)
@@ -341,51 +341,51 @@ bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString
*errString = tr("Talk file creation aborted");
return false;
}
-
+
QString source = QDir::tempPath()+ "/"+ it.value() + ".talk";
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";
- // 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))
QFile::remove(target);
-
+
// copying
if(!QFile::copy(source,target))
{
*errString = tr("Copying of %1 to %2 failed").arg(source).arg(target);
return false;
- }
-
+ }
+
// add to installlog
QString now = QDate::currentDate().toString("yyyyMMdd");
installlog.setValue(target.remove(0,m_mountpoint.length()),now);
-
+
m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents();
}
installlog.endGroup();
- installlog.sync();
- return true;
+ installlog.sync();
+ return true;
}
//! \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 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)
{
resetProgress(fileMap.size());
-
+
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup("talkfiles");
-
+
QMapIterator<QString, QString> it(fileMap);
- while (it.hasNext())
+ while (it.hasNext())
{
it.next();
if(m_abort)
@@ -393,58 +393,58 @@ bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QStri
*errString = tr("Talk file creation aborted");
return false;
}
-
+
QString source;
QString target = it.key() + "/" + it.value() + ".talk";
-
- // correct source if we hav stripExtension enabled
+
+ // correct source if we hav stripExtension enabled
if(m_stripExtensions)
- source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk";
+ source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk";
else
source = QDir::tempPath()+ "/"+ it.value() + ".talk";
-
+
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
if(m_overwriteTalk && QFile::exists(target))
QFile::remove(target);
-
+
// copy file
qDebug() << "copying: " << source << " to " << target;
if(!QFile::copy(source,target))
{
*errString = tr("Copying of %1 to %2 failed").arg(source).arg(target);
return false;
- }
-
+ }
+
// add to Install log
QString now = QDate::currentDate().toString("yyyyMMdd");
installlog.setValue(target.remove(0,m_mountpoint.length()),now);
-
+
m_logger->setProgressValue(++m_progress);
QCoreApplication::processEvents();
}
installlog.endGroup();
- installlog.sync();
- return true;
+ installlog.sync();
+ return true;
}
//! \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
bool TalkFileCreator::cleanup(QStringList list)
{
m_logger->addItem(tr("Cleaning up.."),LOGINFO);
-
+
for(int i=0; i < list.size(); i++)
- {
+ {
if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".wav"))
QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".wav");
if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".talk"))
QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".talk");
-
+
QCoreApplication::processEvents();
}
return true;
diff --git a/rbutil/rbutilqt/themesinstallwindow.cpp b/rbutil/rbutilqt/themesinstallwindow.cpp
index 235299b1de..75d3eeb698 100644
--- a/rbutil/rbutilqt/themesinstallwindow.cpp
+++ b/rbutil/rbutilqt/themesinstallwindow.cpp
@@ -61,11 +61,11 @@ void ThemesInstallWindow::downloadInfo()
themesInfo.close();
QUrl url;
- url = QUrl(settings->themeUrl() + "/rbutilqt.php?target="
- + settings->curConfigure_Modelname());
+ url = QUrl(settings->value(RbSettings::ThemesUrl).toString() + "/rbutilqt.php?target="
+ + settings->value(RbSettings::CurConfigureModel).toString());
qDebug() << "downloadInfo()" << url;
qDebug() << url.queryItems();
- if(settings->cacheOffline())
+ if(settings->value(RbSettings::CacheOffline).toBool())
getter->setCache(true);
getter->setFile(&themesInfo);
@@ -144,7 +144,7 @@ void ThemesInstallWindow::downloadDone(bool error)
// check if there's a themes "MOTD" available
if(iniDetails.contains("status/msg")) {
// 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;
if(iniDetails.contains("status/msg." + lang))
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());
QUrl img, txt;
- txt = QUrl(QString(settings->themeUrl() + "/"
+ txt = QUrl(QString(settings->value(RbSettings::ThemesUrl).toString() + "/"
+ iniDetails.value("descriptionfile").toString()));
- img = QUrl(QString(settings->themeUrl() + "/"
+ img = QUrl(QString(settings->value(RbSettings::ThemesUrl).toString() + "/"
+ iniDetails.value("image").toString()));
QString text;
@@ -211,7 +211,7 @@ void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* p
iniDetails.endGroup();
igetter.abort();
- if(!settings->cacheDisabled())
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
igetter.setCache(true);
else
{
@@ -307,7 +307,7 @@ void ThemesInstallWindow::accept()
QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this);
for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) {
iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString());
- zip = settings->themeUrl()
+ zip = settings->value(RbSettings::ThemesUrl).toString()
+ "/" + iniDetails.value("archive").toString();
themes.append(zip);
names.append("Theme: " +
@@ -321,7 +321,7 @@ void ThemesInstallWindow::accept()
logger = new ProgressLoggerGui(this);
logger->show();
- QString mountPoint = settings->mountpoint();
+ QString mountPoint = settings->value(RbSettings::Mountpoint).toString();
qDebug() << "mountpoint:" << mountPoint;
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
@@ -335,7 +335,7 @@ void ThemesInstallWindow::accept()
installer->setLogSection(names);
installer->setLogVersion(version);
installer->setMountPoint(mountPoint);
- if(!settings->cacheDisabled())
+ if(!settings->value(RbSettings::CacheDisabled).toBool())
installer->setCache(true);
connect(logger, SIGNAL(closed()), this, SLOT(close()));
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp
index 68f169e875..277022b9a1 100644
--- a/rbutil/rbutilqt/tts.cpp
+++ b/rbutil/rbutilqt/tts.cpp
@@ -142,7 +142,7 @@ void TTSExes::setCfg(RbSettings* sett)
break;
}
}
- settings->setTTSPath(m_name,exepath);
+ settings->setSubValue(m_name, RbSettings::TtsPath, exepath);
settings->sync();
}
@@ -150,8 +150,8 @@ void TTSExes::setCfg(RbSettings* sett)
bool TTSExes::start(QString *errStr)
{
- m_TTSexec = settings->ttsPath(m_name);
- m_TTSOpts = settings->ttsOptions(m_name);
+ m_TTSexec = settings->subValue(m_name, RbSettings::TtsPath).toString();
+ m_TTSOpts = settings->subValue(m_name, RbSettings::TtsOptions).toString();
m_TTSTemplate = m_TemplateMap.value(m_name);
@@ -195,7 +195,7 @@ void TTSExes::showCfg()
bool TTSExes::configOk()
{
- QString path = settings->ttsPath(m_name);
+ QString path = settings->subValue(m_name, RbSettings::TtsPath).toString();
if (QFileInfo(path).exists())
return true;
@@ -217,12 +217,12 @@ TTSSapi::TTSSapi() : TTSBase()
bool TTSSapi::start(QString *errStr)
{
- m_TTSOpts = settings->ttsOptions("sapi");
- m_TTSLanguage =settings->ttsLang("sapi");
- m_TTSVoice=settings->ttsVoice("sapi");
- m_TTSSpeed=QString("%1").arg(settings->ttsSpeed("sapi"));
- m_sapi4 = settings->ttsUseSapi4();
-
+ m_TTSOpts = settings->subValue("sapi", RbSettings::TtsOptions).toString();
+ m_TTSLanguage =settings->subValue("sapi", RbSettings::TtsLanguage).toString();
+ m_TTSVoice=settings->subValue("sapi", RbSettings::TtsVoice).toString();
+ m_TTSSpeed=QString("%1").arg(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
+ m_sapi4 = settings->value(RbSettings::TtsUseSapi4).toBool();
+
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",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";
execstring.replace("%exe",m_TTSexec);
execstring.replace("%lang",language);
-
- if(settings->ttsUseSapi4())
+
+ if(settings->value(RbSettings::TtsUseSapi4).toBool())
execstring.append(" /sapi4 ");
qDebug() << "init" << execstring;
@@ -363,7 +363,7 @@ void TTSSapi::showCfg()
bool TTSSapi::configOk()
{
- if(settings->ttsVoice("sapi").isEmpty())
+ if(settings->subValue("sapi", RbSettings::TtsVoice).toString().isEmpty())
return false;
return true;
}
@@ -380,7 +380,7 @@ void TTSFestival::startServer()
if(!configOk())
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.waitForStarted();
@@ -414,8 +414,9 @@ bool TTSFestival::start(QString* errStr)
{
(void) errStr;
ensureServerRunning();
- if (!settings->ttsVoice("festival").isEmpty())
- queryServer(QString("(voice.select '%1)").arg(settings->ttsVoice("festival")));
+ if (!settings->subValue("festival", RbSettings::TtsVoice).toString().isEmpty())
+ queryServer(QString("(voice.select '%1)")
+ .arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
return true;
}
@@ -432,7 +433,7 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
{
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);
qDebug() << cmd;
@@ -462,13 +463,15 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
bool TTSFestival::configOk()
{
- QStringList paths = settings->ttsPath("festival").split(":");
+ QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
if(paths.size() != 2)
return false;
bool ret = QFileInfo(paths[0]).isExecutable() &&
QFileInfo(paths[1]).isExecutable();
- if(settings->ttsVoice("festival").size() > 0 && voices.size() > 0)
- ret = ret && (voices.indexOf(settings->ttsVoice("festival")) != -1);
+ if(settings->subValue("festival", RbSettings::TtsVoice).toString().size() > 0
+ && voices.size() > 0)
+ ret = ret && (voices.indexOf(settings->subValue("festival",
+ RbSettings::TtsVoice).toString()) != -1);
return ret;
}
diff --git a/rbutil/rbutilqt/ttsgui.cpp b/rbutil/rbutilqt/ttsgui.cpp
index cd4dab1fcf..ead32f17c3 100644
--- a/rbutil/rbutilqt/ttsgui.cpp
+++ b/rbutil/rbutilqt/ttsgui.cpp
@@ -36,18 +36,18 @@ TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent)
void TTSSapiGui::showCfg()
{
// try to get config from settings
- ui.ttsoptions->setText(settings->ttsOptions("sapi"));
- QString selLang = settings->ttsLang("sapi");
- QString selVoice = settings->ttsVoice("sapi");
- ui.speed->setValue(settings->ttsSpeed("sapi"));
- if(settings->ttsUseSapi4())
+ ui.ttsoptions->setText(settings->subValue("sapi", RbSettings::TtsOptions).toString());
+ QString selLang = settings->subValue("sapi", RbSettings::TtsLanguage).toString();
+ QString selVoice = settings->subValue("sapi", RbSettings::TtsVoice).toString();
+ ui.speed->setValue(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
+ if(settings->value(RbSettings::TtsUseSapi4).toBool())
ui.usesapi4->setCheckState(Qt::Checked);
else
ui.usesapi4->setCheckState(Qt::Unchecked);
// fill in language combobox
- QStringList languages = settings->allLanguages();
-
+ QStringList languages = settings->languages();
+
languages.sort();
ui.languagecombo->clear();
ui.languagecombo->addItems(languages);
@@ -78,14 +78,14 @@ void TTSSapiGui::reset()
void TTSSapiGui::accept(void)
{
//save settings in user config
- settings->setTTSOptions("sapi",ui.ttsoptions->text());
- settings->setTTSLang("sapi",ui.languagecombo->currentText());
- settings->setTTSVoice("sapi",ui.voicecombo->currentText());
- settings->setTTSSpeed("sapi",ui.speed->value());
+ settings->setSubValue("sapi", RbSettings::TtsOptions, ui.ttsoptions->text());
+ settings->setSubValue("sapi", RbSettings::TtsLanguage, ui.languagecombo->currentText());
+ settings->setSubValue("sapi", RbSettings::TtsVoice, ui.voicecombo->currentText());
+ settings->setSubValue("sapi", RbSettings::TtsSpeed, ui.speed->value());
if(ui.usesapi4->checkState() == Qt::Checked)
- settings->setTTSUseSapi4(true);
+ settings->setValue(RbSettings::TtsUseSapi4, true);
else
- settings->setTTSUseSapi4(false);
+ settings->setValue(RbSettings::TtsUseSapi4, false);
// sync settings
settings->sync();
@@ -108,9 +108,9 @@ void TTSSapiGui::updateVoices(QString language)
void TTSSapiGui::useSapi4Changed(int)
{
if(ui.usesapi4->checkState() == Qt::Checked)
- settings->setTTSUseSapi4(true);
+ settings->setValue(RbSettings::TtsUseSapi4, true);
else
- settings->setTTSUseSapi4(false);
+ settings->setValue(RbSettings::TtsUseSapi4, false);
// sync settings
settings->sync();
updateVoices(ui.languagecombo->currentText());
@@ -136,8 +136,8 @@ void TTSExesGui::showCfg(QString name)
{
m_name = name;
// try to get config from settings
- QString exepath =settings->ttsPath(m_name);
- ui.ttsoptions->setText(settings->ttsOptions(m_name));
+ QString exepath =settings->subValue(m_name, RbSettings::TtsPath).toString();
+ ui.ttsoptions->setText(settings->subValue(m_name, RbSettings::TtsOptions).toString());
ui.ttspath->setText(exepath);
//show dialog
@@ -148,8 +148,8 @@ void TTSExesGui::showCfg(QString name)
void TTSExesGui::accept(void)
{
//save settings in user config
- settings->setTTSPath(m_name,ui.ttspath->text());
- settings->setTTSOptions(m_name,ui.ttsoptions->text());
+ settings->setSubValue(m_name, RbSettings::TtsPath, ui.ttspath->text());
+ settings->setSubValue(m_name, RbSettings::TtsOptions, ui.ttsoptions->text());
// sync settings
settings->sync();
@@ -199,15 +199,15 @@ TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) :
void TTSFestivalGui::showCfg()
{
- qDebug() << "show\tpaths: " << settings->ttsPath("festival") << "\n"
- << "\tvoice: " << settings->ttsVoice("festival");
+ qDebug() << "show\tpaths: " << settings->subValue("festival", RbSettings::TtsPath) << "\n"
+ << "\tvoice: " << settings->subValue("festival", RbSettings::TtsVoice);
// will populate the voices if the paths are correct,
// otherwise, it will require the user to press Refresh
updateVoices();
// 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)
{
ui.serverPath->setText(paths[0]);
@@ -223,8 +223,8 @@ void TTSFestivalGui::accept(void)
//save settings in user config
QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText();
- settings->setTTSPath("festival", newPath);
- settings->setTTSVoice("festival", ui.voicesBox->currentText());
+ settings->setSubValue("festival", RbSettings::TtsPath, newPath);
+ settings->setSubValue("festival", RbSettings::TtsVoice, ui.voicesBox->currentText());
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 */
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);
if(newPath != oldPath)
{
qDebug() << "Using new paths for getVoiceList";
- settings->setTTSPath("festival", newPath);
+ settings->setSubValue("festival", RbSettings::TtsPath, newPath);
settings->sync();
}
@@ -302,7 +302,7 @@ void TTSFestivalGui::onRefreshButton()
if(newPath != oldPath)
{
- settings->setTTSPath("festival", oldPath);
+ settings->setSubValue("festival", RbSettings::TtsPath, oldPath);
settings->sync();
}
}
@@ -324,9 +324,10 @@ void TTSFestivalGui::updateVoices()
ui.voicesBox->clear();
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)
diff --git a/rbutil/rbutilqt/uninstallwindow.cpp b/rbutil/rbutilqt/uninstallwindow.cpp
index b758a3cc6d..7d70f46170 100644
--- a/rbutil/rbutilqt/uninstallwindow.cpp
+++ b/rbutil/rbutilqt/uninstallwindow.cpp
@@ -73,7 +73,7 @@ void UninstallWindow::setSettings(RbSettings *sett)
{
settings = sett;
- QString mountpoint =settings->mountpoint();
+ QString mountpoint = settings->value(RbSettings::Mountpoint).toString();
uninstaller = new Uninstaller(this,mountpoint);
// disable smart uninstall, if not possible
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp
index 873329a47b..14af9adb24 100644
--- a/rbutil/rbutilqt/voicefile.cpp
+++ b/rbutil/rbutilqt/voicefile.cpp
@@ -65,7 +65,8 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
version = version.left(version.indexOf("-")).remove(0,1);
//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;
@@ -127,7 +128,7 @@ void VoiceFileCreator::downloadDone(bool error)
}
//tts
- m_tts = TTSBase::getTTS(settings->curTTS());
+ m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings);
QString errStr;
@@ -141,7 +142,7 @@ void VoiceFileCreator::downloadDone(bool error)
}
// Encoder
- m_enc = EncBase::getEncoder(settings->curEncoder());
+ m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings);
if(!m_enc->start())