summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-01-25 00:12:25 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-01-25 00:12:25 +0000
commit3a54c9b58d05e29343eef2044cf3d3cbce47ca50 (patch)
tree66c0ba1f872af0af3e3c02ec8580ba697353cbf8
parenta665d99d3a1e37c3fa7e1a5f79f9dbb82dd3686d (diff)
downloadrockbox-3a54c9b58d05e29343eef2044cf3d3cbce47ca50.tar.gz
rockbox-3a54c9b58d05e29343eef2044cf3d3cbce47ca50.tar.bz2
rockbox-3a54c9b58d05e29343eef2044cf3d3cbce47ca50.zip
rbtutil: introduce a RbSettings class help code reuse, and minimises duplicated code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16159 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/configure.cpp121
-rw-r--r--rbutil/rbutilqt/configure.h7
-rw-r--r--rbutil/rbutilqt/createvoicewindow.cpp43
-rw-r--r--rbutil/rbutilqt/createvoicewindow.h8
-rw-r--r--rbutil/rbutilqt/encoders.cpp89
-rw-r--r--rbutil/rbutilqt/encoders.h9
-rw-r--r--rbutil/rbutilqt/install.cpp46
-rw-r--r--rbutil/rbutilqt/install.h9
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp28
-rw-r--r--rbutil/rbutilqt/installtalkwindow.h8
-rw-r--r--rbutil/rbutilqt/installthemes.cpp43
-rw-r--r--rbutil/rbutilqt/installthemes.h7
-rw-r--r--rbutil/rbutilqt/rbsettings.cpp563
-rw-r--r--rbutil/rbutilqt/rbsettings.h137
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp220
-rw-r--r--rbutil/rbutilqt/rbutilqt.h5
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro6
-rw-r--r--rbutil/rbutilqt/talkfile.cpp8
-rw-r--r--rbutil/rbutilqt/talkfile.h5
-rw-r--r--rbutil/rbutilqt/tts.cpp83
-rw-r--r--rbutil/rbutilqt/tts.h7
-rw-r--r--rbutil/rbutilqt/uninstallwindow.cpp12
-rw-r--r--rbutil/rbutilqt/uninstallwindow.h9
-rw-r--r--rbutil/rbutilqt/voicefile.cpp10
-rw-r--r--rbutil/rbutilqt/voicefile.h7
25 files changed, 1010 insertions, 480 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index c155cd230c..f583433b8a 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -97,49 +97,49 @@ void Config::accept()
proxy.setHost(ui.proxyHost->text());
proxy.setPort(ui.proxyPort->text().toInt());
}
- userSettings->setValue("proxy", proxy.toString());
+
+ settings->setProxy(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";
- userSettings->setValue("proxytype", proxyType);
+ settings->setProxyType(proxyType);
// language
- if(userSettings->value("lang").toString() != language)
+ if(settings->curLang() != language)
QMessageBox::information(this, tr("Language changed"),
tr("You need to restart the application for the changed language to take effect."));
- userSettings->setValue("lang", language);
+ settings->setLang(language);
// mountpoint
QString mp = ui.mountPoint->text();
if(QFileInfo(mp).isDir())
- userSettings->setValue("mountpoint", mp);
+ settings->setMountpoint( mp);
// platform
QString nplat;
if(ui.treeDevices->selectedItems().size() != 0) {
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
- userSettings->setValue("platform", nplat);
+ settings->setCurPlatform(nplat);
}
// cache settings
if(QFileInfo(ui.cachePath->text()).isDir())
- userSettings->setValue("cachepath", ui.cachePath->text());
+ settings->setCachePath(ui.cachePath->text());
else // default to system temp path
- userSettings->setValue("cachepath", QDir::tempPath());
- userSettings->setValue("cachedisable", ui.cacheDisable->isChecked());
- userSettings->setValue("offline", ui.cacheOfflineMode->isChecked());
+ settings->setCachePath( QDir::tempPath());
+ settings->setCacheDisable(ui.cacheDisable->isChecked());
+ settings->setCacheOffline(ui.cacheOfflineMode->isChecked());
// tts settings
- userSettings->setValue("tts",ui.comboTts->currentText());
-
- //encoder settings
- userSettings->setValue("encoder",ui.comboEncoder->currentText());
+ settings->setCurTTS(ui.comboTts->currentText());
+ //encoder settings
+ settings->setCurEncoder(ui.comboEncoder->currentText());
// sync settings
- userSettings->sync();
+ settings->sync();
this->close();
emit settingsUpdated();
}
@@ -151,11 +151,10 @@ void Config::abort()
this->close();
}
-void Config::setSettings(QSettings* user,QSettings* device)
+void Config::setSettings(RbSettings* sett)
{
- userSettings = user;
- devices = device;
-
+ settings = sett;
+
setUserSettings();
setDevices();
}
@@ -163,7 +162,7 @@ void Config::setSettings(QSettings* user,QSettings* device)
void Config::setUserSettings()
{
// set proxy
- proxy = userSettings->value("proxy").toString();
+ proxy = settings->proxy();
if(proxy.port() > 0)
ui.proxyPort->setText(QString("%1").arg(proxy.port()));
@@ -172,7 +171,7 @@ void Config::setUserSettings()
ui.proxyUser->setText(proxy.userName());
ui.proxyPass->setText(proxy.password());
- QString proxyType = userSettings->value("proxytype", "system").toString();
+ QString proxyType = settings->proxyType();
if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
else ui.radioNoProxy->setChecked(true);
@@ -183,7 +182,7 @@ void Config::setUserSettings()
// find key for lang value
QMap<QString, QString>::const_iterator i = lang.constBegin();
while (i != lang.constEnd()) {
- if(i.value() == userSettings->value("lang").toString()) {
+ if(i.value() == settings->curLang()) {
b = i.key();
break;
}
@@ -196,15 +195,15 @@ void Config::setUserSettings()
ui.listLanguages->setCurrentItem(a.at(0));
// devices tab
- ui.mountPoint->setText(userSettings->value("mountpoint").toString());
+ ui.mountPoint->setText(settings->mountpoint());
// cache tab
- if(!QFileInfo(userSettings->value("cachepath").toString()).isDir())
- userSettings->setValue("cachepath", QDir::tempPath());
- ui.cachePath->setText(userSettings->value("cachepath").toString());
- ui.cacheDisable->setChecked(userSettings->value("cachedisable", true).toBool());
- ui.cacheOfflineMode->setChecked(userSettings->value("offline").toBool());
- updateCacheInfo(userSettings->value("cachepath").toString());
+ if(!QFileInfo(settings->cachePath()).isDir())
+ settings->setCachePath(QDir::tempPath());
+ ui.cachePath->setText(settings->cachePath());
+ ui.cacheDisable->setChecked(settings->cacheDisabled());
+ ui.cacheOfflineMode->setChecked(settings->cacheOffline());
+ updateCacheInfo(settings->cachePath());
}
@@ -227,28 +226,21 @@ void Config::setDevices()
// setup devices table
qDebug() << "Config::setDevices()";
- devices->beginGroup("platforms");
- QStringList a = devices->childKeys();
- devices->endGroup();
+
+ QStringList platformList = settings->allPlatforms();
QMap <QString, QString> manuf;
QMap <QString, QString> devcs;
- for(int it = 0; it < a.size(); it++) {
- QString curdev;
- devices->beginGroup("platforms");
- curdev = devices->value(a.at(it), "null").toString();
- devices->endGroup();
- QString curname;
- devices->beginGroup(curdev);
- curname = devices->value("name", "null").toString();
- QString curbrand = devices->value("brand", "").toString();
- devices->endGroup();
- manuf.insertMulti(curbrand, curdev);
- devcs.insert(curdev, curname);
+ for(int it = 0; it < platformList.size(); it++)
+ {
+ QString curname = settings->name(platformList.at(it));
+ QString curbrand = settings->brand(platformList.at(it));
+ manuf.insertMulti(curbrand, platformList.at(it));
+ devcs.insert(platformList.at(it), curname);
}
QString platform;
- platform = devcs.value(userSettings->value("platform").toString());
+ platform = devcs.value(settings->curPlatform());
// set up devices table
ui.treeDevices->header()->hide();
@@ -269,25 +261,16 @@ void Config::setDevices()
items.append(w);
// go through platforms again for sake of order
- for(int it = 0; it < a.size(); it++) {
- QString curdev;
- devices->beginGroup("platforms");
- curdev = devices->value(a.at(it), "null").toString();
- devices->endGroup();
- QString curname;
- devices->beginGroup(curdev);
- curname = devices->value("name", "null").toString();
- QString curbrand = devices->value("brand", "").toString();
- QString curicon = devices->value("icon", "").toString();
- devices->endGroup();
+ for(int it = 0; it < platformList.size(); it++) {
+
+ QString curname = settings->name(platformList.at(it));
+ QString curbrand = settings->brand(platformList.at(it));
+
if(curbrand != brands.at(c)) continue;
- qDebug() << "adding:" << brands.at(c) << curname << curdev;
+ qDebug() << "adding:" << brands.at(c) << curname;
w2 = new QTreeWidgetItem(w, QStringList(curname));
- w2->setData(0, Qt::UserRole, curdev);
-// QIcon icon;
-// icon.addFile(":/icons/devices/" + curicon + "-tiny.png");
-// w2->setIcon(0, icon);
-// ui.treeDevices->setIconSize(QSize(32, 32));
+ w2->setData(0, Qt::UserRole, platformList.at(it));
+
if(platform.contains(curname)) {
w2->setSelected(true);
w->setExpanded(true);
@@ -306,7 +289,7 @@ void Config::setDevices()
ui.comboEncoder->addItems(getEncoderList());
//update index of combobox
- int index = ui.comboEncoder->findText(userSettings->value("encoder").toString(),Qt::MatchExactly);
+ int index = ui.comboEncoder->findText(settings->curEncoder(),Qt::MatchExactly);
if(index < 0) index = 0;
ui.comboEncoder->setCurrentIndex(index);
updateEncState(index);
@@ -316,7 +299,7 @@ void Config::setDevices()
//update index of combobox
- index = ui.comboTts->findText(userSettings->value("tts").toString(),Qt::MatchExactly);
+ index = ui.comboTts->findText(settings->curTTS(),Qt::MatchExactly);
if(index < 0) index = 0;
ui.comboTts->setCurrentIndex(index);
updateTtsState(index);
@@ -328,7 +311,7 @@ void Config::updateTtsState(int index)
{
QString ttsName = ui.comboTts->itemText(index);
TTSBase* tts = getTTS(ttsName);
- tts->setCfg(userSettings,devices);
+ tts->setCfg(settings);
if(tts->configOk())
{
@@ -346,7 +329,7 @@ void Config::updateEncState(int index)
{
QString encoder = ui.comboEncoder->itemText(index);
EncBase* enc = getEncoder(encoder);
- enc->setUserCfg(userSettings);
+ enc->setCfg(settings);
if(enc->configOk())
{
@@ -594,7 +577,7 @@ void Config::cacheClear()
QFile::remove(f);
qDebug() << "removed:" << f;
}
- updateCacheInfo(userSettings->value("cachepath").toString());
+ updateCacheInfo(settings->cachePath());
}
@@ -602,7 +585,7 @@ void Config::configTts()
{
TTSBase* tts =getTTS(ui.comboTts->currentText());
- tts->setCfg(userSettings,devices);
+ tts->setCfg(settings);
tts->showCfg();
updateTtsState(ui.comboTts->currentIndex());
}
@@ -612,7 +595,7 @@ void Config::configEnc()
{
EncBase* enc =getEncoder(ui.comboEncoder->currentText());
- enc->setUserCfg(userSettings);
+ enc->setCfg(settings);
enc->showCfg();
updateEncState(ui.comboEncoder->currentIndex());
}
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index bb4afb6c86..55f2838537 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -22,6 +22,7 @@
#include "ui_configurefrm.h"
#include "browsedirtree.h"
+#include "rbsettings.h"
#include <QtGui>
class Config : public QDialog
@@ -29,7 +30,7 @@ class Config : public QDialog
Q_OBJECT
public:
Config(QWidget *parent = 0,int index=0);
- void setSettings(QSettings* user,QSettings* device);
+ void setSettings(RbSettings* sett);
signals:
void settingsUpdated(void);
@@ -43,8 +44,8 @@ class Config : public QDialog
void setDevices();
Ui::ConfigForm ui;
- QSettings *userSettings;
- QSettings *devices;
+ RbSettings* settings;
+
QStringList findLanguageFiles(void);
QString languageName(const QString&);
QMap<QString, QString> lang;
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp
index ff72e9a463..dda0097b5e 100644
--- a/rbutil/rbutilqt/createvoicewindow.cpp
+++ b/rbutil/rbutilqt/createvoicewindow.cpp
@@ -34,7 +34,7 @@ CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
void CreateVoiceWindow::change()
{
Config *cw = new Config(this,4);
- cw->setSettings(userSettings,devices);
+ cw->setSettings(settings);
cw->show();
connect(cw, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated()));
}
@@ -45,19 +45,18 @@ void CreateVoiceWindow::accept()
logger->show();
connect(logger,SIGNAL(closed()),this,SLOT(close()));
- QString platform = userSettings->value("platform").toString();
QString lang = ui.comboLanguage->currentText();
int wvThreshold = ui.wavtrimthreshold->value();
//safe selected language
- userSettings->setValue("voicelanguage",lang);
- userSettings->setValue("wavtrimthreshold",wvThreshold);
- userSettings->sync();
+ settings->setVoiceLanguage(lang);
+ settings->setWavtrimTh(wvThreshold);
+ settings->sync();
//configure voicecreator
- voicecreator->setSettings(userSettings,devices);
- voicecreator->setMountPoint(userSettings->value("mountpoint").toString());
- voicecreator->setTargetId(devices->value(platform + "/targetid").toInt());
+ voicecreator->setSettings(settings);
+ voicecreator->setMountPoint(settings->mountpoint());
+ voicecreator->setTargetId(settings->curTargetId());
voicecreator->setLang(lang);
voicecreator->setProxy(m_proxy);
voicecreator->setWavtrimThreshold(wvThreshold);
@@ -68,44 +67,34 @@ void CreateVoiceWindow::accept()
-void CreateVoiceWindow::setSettings(QSettings *user,QSettings *dev)
+void CreateVoiceWindow::setSettings(RbSettings* sett)
{
- devices = dev;
- userSettings = user;
- qDebug() << "Install::setDeviceSettings:" << devices;
+ settings = sett;
// fill in language combobox
- devices->beginGroup("languages");
- QStringList keys = devices->allKeys();
- QStringList languages;
- for(int i =0 ; i < keys.size();i++)
- {
- languages << devices->value(keys.at(i)).toString();
- }
- devices->endGroup();
-
+ QStringList languages = settings->allLanguages();
languages.sort();
ui.comboLanguage->addItems(languages);
// set saved lang
- ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(userSettings->value("voicelanguage").toString()));
+ ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(settings->voiceLanguage()));
- QString ttsName = userSettings->value("tts", "none").toString();
+ QString ttsName = settings->curTTS();
TTSBase* tts = getTTS(ttsName);
- tts->setCfg(userSettings,devices);
+ tts->setCfg(settings);
if(tts->configOk())
ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName));
else
ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
- QString encoder = userSettings->value("encoder", "none").toString();
+ QString encoder = settings->curEncoder();
EncBase* enc = getEncoder(encoder);
- enc->setUserCfg(userSettings);
+ enc->setCfg(settings);
if(enc->configOk())
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(encoder));
else
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
- ui.wavtrimthreshold->setValue(userSettings->value("wavtrimthreshold", 500).toInt());
+ ui.wavtrimthreshold->setValue(settings->wavtrimTh());
}
diff --git a/rbutil/rbutilqt/createvoicewindow.h b/rbutil/rbutilqt/createvoicewindow.h
index cd99b389a2..d9fefc6750 100644
--- a/rbutil/rbutilqt/createvoicewindow.h
+++ b/rbutil/rbutilqt/createvoicewindow.h
@@ -22,18 +22,17 @@
#include <QtGui>
-#include <QSettings>
-
#include "ui_createvoicefrm.h"
#include "progressloggergui.h"
#include "voicefile.h"
+#include "rbsettings.h"
class CreateVoiceWindow : public QDialog
{
Q_OBJECT
public:
CreateVoiceWindow(QWidget *parent = 0);
- void setSettings(QSettings* user,QSettings* device);
+ void setSettings(RbSettings* sett);
void setProxy(QUrl proxy){m_proxy = proxy;}
signals:
@@ -47,8 +46,7 @@ class CreateVoiceWindow : public QDialog
VoiceFileCreator* voicecreator;
Ui::CreateVoiceFrm ui;
ProgressLoggerGui* logger;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
QUrl m_proxy;
};
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp
index 54fc5ad201..56fcd7c80d 100644
--- a/rbutil/rbutilqt/encoders.cpp
+++ b/rbutil/rbutilqt/encoders.cpp
@@ -101,10 +101,8 @@ EncExes::EncExes(QString name,QWidget *parent) : EncBase(parent)
bool EncExes::start()
{
- userSettings->beginGroup(m_name);
- m_EncExec = userSettings->value("encoderpath","").toString();
- m_EncOpts = userSettings->value("encoderoptions","").toString();
- userSettings->endGroup();
+ m_EncExec = settings->encoderPath(m_name);
+ m_EncOpts = settings->encoderOptions(m_name);
m_EncTemplate = m_TemplateMap.value(m_name);
@@ -142,10 +140,8 @@ void EncExes::reset()
void EncExes::showCfg()
{
// try to get config from settings
- userSettings->beginGroup(m_name);
- QString exepath =userSettings->value("encoderpath","").toString();
- ui.encoderoptions->setText(userSettings->value("encoderoptions","").toString());
- userSettings->endGroup();
+ QString exepath =settings->encoderPath(m_name);
+ ui.encoderoptions->setText(settings->encoderOptions(m_name));
if(exepath == "")
{
@@ -184,16 +180,12 @@ void EncExes::showCfg()
void EncExes::accept(void)
{
- if(userSettings != NULL)
- {
- //save settings in user config
- userSettings->beginGroup(m_name);
- userSettings->setValue("encoderpath",ui.encoderpath->text());
- userSettings->setValue("encoderoptions",ui.encoderoptions->text());
- userSettings->endGroup();
- // sync settings
- userSettings->sync();
- }
+ //save settings in user config
+ settings->setEncoderPath(m_name,ui.encoderpath->text());
+ settings->setEncoderOptions(m_name,ui.encoderoptions->text());
+
+ // sync settings
+ settings->sync();
this->close();
}
@@ -204,9 +196,7 @@ void EncExes::reject(void)
bool EncExes::configOk()
{
- userSettings->beginGroup(m_name);
- QString path = userSettings->value("encoderpath","").toString();
- userSettings->endGroup();
+ QString path = settings->encoderPath(m_name);
if (QFileInfo(path).exists())
return true;
@@ -251,19 +241,13 @@ EncRbSpeex::EncRbSpeex(QWidget *parent) : EncBase(parent)
bool EncRbSpeex::start()
{
- // no user config
- if(userSettings == NULL)
- {
- return false;
- }
+
// try to get config from settings
- userSettings->beginGroup("rbspeex");
- quality = userSettings->value("quality",defaultQuality).toDouble();
- complexity = userSettings->value("complexity",defaultComplexity).toInt();
- volume =userSettings->value("volume",defaultVolume).toDouble();
- narrowband = userSettings->value("narrowband",false).toBool();
+ quality = settings->encoderQuality("rbspeex");
+ complexity = settings->encoderComplexity("rbspeex");
+ volume = settings->encoderVolume("rbspeex");
+ narrowband = settings->encoderNarrowband("rbspeex");
- userSettings->endGroup();
return true;
}
@@ -309,37 +293,29 @@ void EncRbSpeex::reset()
void EncRbSpeex::showCfg()
{
//fill in the usersettings
- userSettings->beginGroup("rbspeex");
- ui.volume->setValue(userSettings->value("volume",defaultVolume).toDouble());
- ui.quality->setValue(userSettings->value("quality",defaultQuality).toDouble());
- ui.complexity->setValue(userSettings->value("complexity",defaultComplexity).toInt());
+ ui.volume->setValue(settings->encoderVolume("rbspeex"));
+ ui.quality->setValue(settings->encoderQuality("rbspeex"));
+ ui.complexity->setValue(settings->encoderComplexity("rbspeex"));
- if(userSettings->value("narrowband","False").toString() == "True")
+ if(settings->encoderNarrowband("rbspeex"))
ui.narrowband->setCheckState(Qt::Checked);
else
ui.narrowband->setCheckState(Qt::Unchecked);
- userSettings->endGroup();
-
//show dialog
this->exec();
}
void EncRbSpeex::accept(void)
{
- if(userSettings != NULL)
- {
- //save settings in user config
- userSettings->beginGroup("rbspeex");
- userSettings->setValue("volume",ui.volume->value());
- userSettings->setValue("quality",ui.quality->value());
- userSettings->setValue("complexity",ui.complexity->value());
- userSettings->setValue("narrowband",ui.narrowband->isChecked() ? true : false);
-
- userSettings->endGroup();
- // sync settings
- userSettings->sync();
- }
+ //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);
+
+ // sync settings
+ settings->sync();
this->close();
}
@@ -353,18 +329,15 @@ bool EncRbSpeex::configOk()
{
bool result=true;
// check config
- userSettings->beginGroup("rbspeex");
- if(userSettings->value("volume","null").toDouble() <= 0)
+ if(settings->encoderVolume("rbspeex") <= 0)
result =false;
- if(userSettings->value("quality","null").toDouble() <= 0)
+ if(settings->encoderQuality("rbspeex") <= 0)
result =false;
- if(userSettings->value("complexity","null").toInt() <= 0)
+ if(settings->encoderComplexity("rbspeex") <= 0)
result =false;
-
- userSettings->endGroup();
return result;
}
diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h
index 688ffbcd25..ab59e52060 100644
--- a/rbutil/rbutilqt/encoders.h
+++ b/rbutil/rbutilqt/encoders.h
@@ -20,9 +20,11 @@
#ifndef ENCODERS_H
#define ENCODERS_H
+#include <QtGui>
+
#include "ui_rbspeexcfgfrm.h"
#include "ui_encexescfgfrm.h"
-#include <QtGui>
+#include "rbsettings.h"
extern "C"
{
@@ -39,7 +41,6 @@ EncBase* getEncoder(QString encname);
QStringList getEncoderList();
-
class EncBase : public QDialog
{
Q_OBJECT
@@ -52,7 +53,7 @@ public:
virtual void showCfg(){}
virtual bool configOk(){return false;}
- void setUserCfg(QSettings *uSettings){userSettings = uSettings;}
+ void setCfg(RbSettings *sett){settings = sett;}
public slots:
virtual void accept(void){}
@@ -61,7 +62,7 @@ public slots:
protected:
- QSettings *userSettings;
+ RbSettings* settings;
};
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index b41cd679af..b64e1637d6 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -48,8 +48,8 @@ void Install::accept()
{
logger = new ProgressLoggerGui(this);
logger->show();
- QString mountPoint = userSettings->value("mountpoint").toString();
- qDebug() << "mountpoint:" << userSettings->value("mountpoint").toString();
+ QString mountPoint = settings->mountpoint();
+ qDebug() << "mountpoint:" << settings->mountpoint();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -58,50 +58,46 @@ void Install::accept()
}
QString myversion;
- QString buildname;
- devices->beginGroup(userSettings->value("platform").toString());
- buildname = devices->value("platform").toString();
- devices->endGroup();
+ QString buildname = settings->curPlatform();
if(ui.radioStable->isChecked()) {
file = QString("%1/rockbox-%2-%3.zip")
- .arg(devices->value("download_url").toString(),
- devices->value("last_release").toString(), buildname);
+ .arg(settings->downloadUrl(),
+ settings->lastRelease(), buildname);
fileName = QString("rockbox-%1-%2.zip")
- .arg(devices->value("last_release").toString(), buildname);
- userSettings->setValue("build", "stable");
+ .arg(settings->lastRelease(), buildname);
+ settings->setBuild("stable");
myversion = version.value("rel_rev");
}
else if(ui.radioArchived->isChecked()) {
file = QString("%1%2/rockbox-%3-%4.zip")
- .arg(devices->value("daily_url").toString(),
+ .arg(settings->dailyUrl(),
buildname, buildname, version.value("arch_date"));
fileName = QString("rockbox-%1-%2.zip")
.arg(buildname, version.value("arch_date"));
- userSettings->setValue("build", "archived");
+ settings->setBuild("archived");
myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date");
}
else if(ui.radioCurrent->isChecked()) {
file = QString("%1%2/rockbox.zip")
- .arg(devices->value("bleeding_url").toString(), buildname);
+ .arg(settings->bleedingUrl(), buildname);
fileName = QString("rockbox.zip");
- userSettings->setValue("build", "current");
+ settings->setBuild("current");
myversion = "r" + version.value("bleed_rev");
}
else {
qDebug() << "no build selected -- this shouldn't happen";
return;
}
- userSettings->sync();
+ settings->sync();
installer = new ZipInstaller(this);
installer->setUrl(file);
installer->setProxy(proxy);
installer->setLogSection("Rockbox (Base)");
- if(!userSettings->value("cachedisable").toBool()
+ if(!settings->cacheDisabled()
&& !ui.radioCurrent->isChecked()
&& !ui.checkBoxCache->isChecked())
- installer->setCache(userSettings->value("cachepath",
- QDir::tempPath()).toString());
+ installer->setCache(settings->cachePath());
installer->setLogVersion(myversion);
installer->setMountPoint(mountPoint);
@@ -125,9 +121,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(userSettings->value("mountpoint").toString()
+ QSettings installlog(settings->mountpoint()
+ "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
- installlog.setValue("platform", userSettings->value("platform").toString());
+ installlog.setValue("platform", settings->curPlatform());
installlog.sync();
}
@@ -179,12 +175,6 @@ void Install::setDetailsArchived(bool show)
}
-void Install::setDeviceSettings(QSettings *dev)
-{
- devices = dev;
- qDebug() << "Install::setDeviceSettings:" << devices;
-}
-
void Install::setVersionStrings(QMap<QString, QString> ver)
{
@@ -217,7 +207,7 @@ void Install::setVersionStrings(QMap<QString, QString> ver)
qDebug() << "Install::setVersionStrings" << version;
}
-void Install::setUserSettings(QSettings *user)
+void Install::setSettings(RbSettings *sett)
{
- userSettings = user;
+ settings = sett;
}
diff --git a/rbutil/rbutilqt/install.h b/rbutil/rbutilqt/install.h
index 17c4ba1086..4d102a0e65 100644
--- a/rbutil/rbutilqt/install.h
+++ b/rbutil/rbutilqt/install.h
@@ -22,11 +22,10 @@
#include <QtGui>
-#include <QSettings>
-
#include "ui_installfrm.h"
#include "installzip.h"
#include "progressloggergui.h"
+#include "rbsettings.h"
class Install : public QDialog
{
@@ -34,8 +33,7 @@ class Install : public QDialog
public:
Install(QWidget *parent = 0);
void setProxy(QUrl);
- void setUserSettings(QSettings*);
- void setDeviceSettings(QSettings*);
+ void setSettings(RbSettings* sett);
void setVersionStrings(QMap<QString, QString>);
public slots:
@@ -45,8 +43,7 @@ class Install : public QDialog
Ui::InstallFrm ui;
ProgressLoggerGui* logger;
QUrl proxy;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
QHttp *download;
QFile *target;
QString file;
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index e1b0b69049..f7202aae40 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -66,7 +66,7 @@ void InstallTalkWindow::setTalkFolder(QString folder)
void InstallTalkWindow::change()
{
Config *cw = new Config(this,4);
- cw->setSettings(userSettings,devices);
+ cw->setSettings(settings);
cw->show();
connect(cw, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated()));
}
@@ -86,13 +86,13 @@ void InstallTalkWindow::accept()
return;
}
- userSettings->setValue("last_talked_folder", folderToTalk);
+ settings->setLastTalkedDir(folderToTalk);
- userSettings->sync();
+ settings->sync();
- talkcreator->setSettings(userSettings,devices);
+ talkcreator->setSettings(settings);
talkcreator->setDir(QDir(folderToTalk));
- talkcreator->setMountPoint(userSettings->value("mountpoint").toString());
+ talkcreator->setMountPoint(settings->mountpoint());
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
@@ -106,29 +106,27 @@ void InstallTalkWindow::accept()
}
-void InstallTalkWindow::setSettings(QSettings *user,QSettings *dev)
+void InstallTalkWindow::setSettings(RbSettings* sett)
{
- devices = dev;
- userSettings = user;
- qDebug() << "Install::setDeviceSettings:" << devices;
-
- QString ttsName = userSettings->value("tts", "none").toString();
+ settings = sett;
+
+ QString ttsName = settings->curTTS();
TTSBase* tts = getTTS(ttsName);
- tts->setCfg(userSettings,devices);
+ tts->setCfg(settings);
if(tts->configOk())
ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName));
else
ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
- QString encoder = userSettings->value("encoder", "none").toString();
+ QString encoder = settings->curEncoder();
EncBase* enc = getEncoder(encoder);
- enc->setUserCfg(userSettings);
+ enc->setCfg(settings);
if(enc->configOk())
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(encoder));
else
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
- setTalkFolder(userSettings->value("last_talked_folder").toString());
+ setTalkFolder(settings->lastTalkedFolder());
}
diff --git a/rbutil/rbutilqt/installtalkwindow.h b/rbutil/rbutilqt/installtalkwindow.h
index 5899c5701e..7ac9e45fc0 100644
--- a/rbutil/rbutilqt/installtalkwindow.h
+++ b/rbutil/rbutilqt/installtalkwindow.h
@@ -22,18 +22,17 @@
#include <QtGui>
-#include <QSettings>
-
#include "ui_installtalkfrm.h"
#include "progressloggergui.h"
#include "talkfile.h"
+#include "rbsettings.h"
class InstallTalkWindow : public QDialog
{
Q_OBJECT
public:
InstallTalkWindow(QWidget *parent = 0);
- void setSettings(QSettings* user,QSettings* device);
+ void setSettings(RbSettings* sett);
signals:
void settingsUpdated(void);
@@ -50,8 +49,7 @@ class InstallTalkWindow : public QDialog
TalkFileCreator* talkcreator;
Ui::InstallTalkFrm ui;
ProgressLoggerGui* logger;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
};
diff --git a/rbutil/rbutilqt/installthemes.cpp b/rbutil/rbutilqt/installthemes.cpp
index b468dad189..be196c8274 100644
--- a/rbutil/rbutilqt/installthemes.cpp
+++ b/rbutil/rbutilqt/installthemes.cpp
@@ -46,24 +46,7 @@ ThemesInstallWindow::~ThemesInstallWindow()
QString ThemesInstallWindow::resolution()
{
- QString resolution;
- devices->beginGroup(userSettings->value("platform").toString());
- resolution = devices->value("resolution").toString();
- devices->endGroup();
- return resolution;
-}
-
-
-void ThemesInstallWindow::setDeviceSettings(QSettings *dev)
-{
- devices = dev;
- qDebug() << "setDeviceSettings()" << devices;
-}
-
-
-void ThemesInstallWindow::setUserSettings(QSettings *user)
-{
- userSettings = user;
+ return settings->curResolution();
}
@@ -79,12 +62,12 @@ void ThemesInstallWindow::downloadInfo()
themesInfo.close();
QUrl url;
- url = QUrl(devices->value("themes_url").toString() + "/rbutilqt.php?res=" + resolution());
+ url = QUrl(settings->themeUrl() + "/rbutilqt.php?res=" + resolution());
qDebug() << "downloadInfo()" << url;
qDebug() << url.queryItems();
getter->setProxy(proxy);
- if(userSettings->value("offline").toBool())
- getter->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(settings->cacheOffline())
+ getter->setCache(settings->cachePath());
getter->setFile(&themesInfo);
getter->getFile(url);
}
@@ -173,9 +156,9 @@ void ThemesInstallWindow::updateDetails(int row)
iniDetails.beginGroup(ui.listThemes->item(row)->data(Qt::UserRole).toString());
QUrl img, txt;
- txt = QUrl(QString(devices->value("themes_url").toString() + "/"
+ txt = QUrl(QString(settings->themeUrl() + "/"
+ iniDetails.value("descriptionfile").toString()));
- img = QUrl(QString(devices->value("themes_url").toString() + "/"
+ img = QUrl(QString(settings->themeUrl() + "/"
+ iniDetails.value("image").toString()));
qDebug() << "txt:" << txt;
qDebug() << "img:" << img;
@@ -190,8 +173,8 @@ void ThemesInstallWindow::updateDetails(int row)
igetter.abort();
igetter.setProxy(proxy);
- if(!userSettings->value("cachedisable").toBool())
- igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(!settings->cacheDisabled())
+ igetter.setCache(settings->cachePath());
else
{
if(infocachedir=="")
@@ -291,7 +274,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 = devices->value("themes_url").toString()
+ zip = settings->themeUrl()
+ "/" + iniDetails.value("archive").toString();
themes.append(zip);
names.append("Theme: " +
@@ -305,8 +288,8 @@ void ThemesInstallWindow::accept()
logger = new ProgressLoggerGui(this);
logger->show();
- QString mountPoint = userSettings->value("mountpoint").toString();
- qDebug() << "mountpoint:" << userSettings->value("mountpoint").toString();
+ QString mountPoint = settings->mountpoint();
+ qDebug() << "mountpoint:" << mountPoint;
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -320,8 +303,8 @@ void ThemesInstallWindow::accept()
installer->setLogSection(names);
installer->setLogVersion(version);
installer->setMountPoint(mountPoint);
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
installer->install(logger);
connect(logger, SIGNAL(closed()), this, SLOT(close()));
}
diff --git a/rbutil/rbutilqt/installthemes.h b/rbutil/rbutilqt/installthemes.h
index 12c0f6a2d1..0f7d0f4a6b 100644
--- a/rbutil/rbutilqt/installthemes.h
+++ b/rbutil/rbutilqt/installthemes.h
@@ -27,6 +27,7 @@
#include "httpget.h"
#include "installzip.h"
#include "progressloggergui.h"
+#include "rbsettings.h"
class ThemesInstallWindow : public QDialog
{
@@ -35,8 +36,7 @@ class ThemesInstallWindow : public QDialog
public:
ThemesInstallWindow(QWidget* parent = 0);
~ThemesInstallWindow();
- void setDeviceSettings(QSettings*);
- void setUserSettings(QSettings *);
+ void setSettings(RbSettings* sett){settings=sett;}
void setProxy(QUrl);
void downloadInfo(void);
void show(void);
@@ -47,8 +47,7 @@ class ThemesInstallWindow : public QDialog
private:
Ui::ThemeInstallFrm ui;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
HttpGet *getter;
HttpGet igetter;
QTemporaryFile themesInfo;
diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp
new file mode 100644
index 0000000000..736921ce81
--- /dev/null
+++ b/rbutil/rbutilqt/rbsettings.cpp
@@ -0,0 +1,563 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: rbsettings.cpp 16150 2008-01-23 21:54:40Z domonoky $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "rbsettings.h"
+
+#include <QSettings>
+
+void RbSettings::open()
+{
+ // only use built-in rbutil.ini
+ devices = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
+ // portable installation:
+ // check for a configuration file in the program folder.
+ QFileInfo config;
+ config.setFile(qApp->applicationDirPath() + "/RockboxUtility.ini");
+ if(config.isFile())
+ {
+ userSettings = new QSettings(qApp->applicationDirPath() + "/RockboxUtility.ini",
+ QSettings::IniFormat, 0);
+ qDebug() << "config: portable";
+ }
+ else
+ {
+ userSettings = new QSettings(QSettings::IniFormat,
+ QSettings::UserScope, "rockbox.org", "RockboxUtility");
+ qDebug() << "config: system";
+ }
+}
+
+void RbSettings::sync()
+{
+ userSettings->sync();
+}
+
+QString RbSettings::userSettingFilename()
+{
+ return userSettings->fileName();
+}
+
+bool RbSettings::cacheOffline()
+{
+ return userSettings->value("offline").toBool();
+}
+
+bool RbSettings::curNeedsBootloader()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString result = devices->value("needsbootloader", "").toString();
+ devices->endGroup();
+ if( result == "no")
+ {
+ return false;
+ }
+ else
+ return true;
+}
+
+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::lastRelease()
+{
+ return devices->value("last_release").toString();
+}
+
+QString RbSettings::cachePath()
+{
+ return userSettings->value("cachepath", QDir::tempPath()).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::downloadUrl()
+{
+ return devices->value("download_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", "system").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::curManual()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString name = devices->value("manualname","rockbox-" +
+ devices->value("platform").toString()).toString();
+ devices->endGroup();
+ return name;
+}
+
+bool RbSettings::curReleased()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString released = devices->value("released").toString();
+ devices->endGroup();
+
+ if(released == "yes")
+ return true;
+ else
+ return false;
+}
+
+QString RbSettings::curBootloaderMethod()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString method = devices->value("bootloadermethod").toString();
+ devices->endGroup();
+ return method;
+}
+
+QString RbSettings::curBootloaderName()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString name = devices->value("bootloadername").toString();
+ devices->endGroup();
+ return name;
+}
+
+QString RbSettings::curVoiceName()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString name = devices->value("voicename").toString();
+ devices->endGroup();
+ return name;
+}
+
+QString RbSettings::curLang()
+{
+ return userSettings->value("lang").toString();
+}
+
+QString RbSettings::curEncoder()
+{
+ return userSettings->value("encoder").toString();
+}
+
+QString RbSettings::curTTS()
+{
+ return userSettings->value("tts").toString();
+}
+
+QString RbSettings::lastTalkedFolder()
+{
+ return userSettings->value("last_talked_folder").toString();
+}
+
+QString RbSettings::voiceLanguage()
+{
+ return userSettings->value("voicelanguage").toString();
+}
+
+int RbSettings::wavtrimTh()
+{
+ return userSettings->value("wavtrimthreshold",500).toInt();
+}
+
+QString RbSettings::ttsPath(QString tts)
+{
+ devices->beginGroup(tts);
+ QString path = devices->value("ttspath").toString();
+ devices->endGroup();
+ return path;
+
+}
+QString RbSettings::ttsOptions(QString tts)
+{
+ devices->beginGroup(tts);
+ QString op = devices->value("ttsoptions").toString();
+ devices->endGroup();
+ return op;
+}
+QString RbSettings::ttsVoice(QString tts)
+{
+ devices->beginGroup(tts);
+ QString op = devices->value("ttsvoice").toString();
+ devices->endGroup();
+ return op;
+}
+int RbSettings::ttsSpeed(QString tts)
+{
+ devices->beginGroup(tts);
+ int sp = devices->value("ttsspeed",0).toInt();
+ devices->endGroup();
+ return sp;
+}
+QString RbSettings::ttsLang(QString tts)
+{
+ devices->beginGroup(tts);
+ QString op = devices->value("ttslanguage").toString();
+ devices->endGroup();
+ return op;
+}
+
+QString RbSettings::encoderPath(QString enc)
+{
+ devices->beginGroup(enc);
+ QString path = devices->value("encoderpath").toString();
+ devices->endGroup();
+ return path;
+}
+QString RbSettings::encoderOptions(QString enc)
+{
+ devices->beginGroup(enc);
+ QString op = devices->value("encoderpath").toString();
+ devices->endGroup();
+ return op;
+}
+
+double RbSettings::encoderQuality(QString enc)
+{
+ devices->beginGroup(enc);
+ double q = devices->value("quality",8.f).toDouble();
+ devices->endGroup();
+ return q;
+}
+int RbSettings::encoderComplexity(QString enc)
+{
+ devices->beginGroup(enc);
+ int c = devices->value("complexity",1.f).toInt();
+ devices->endGroup();
+ return c;
+}
+double RbSettings::encoderVolume(QString enc)
+{
+ devices->beginGroup(enc);
+ double v = devices->value("volume",10).toDouble();
+ devices->endGroup();
+ return v;
+}
+bool RbSettings::encoderNarrowband(QString enc)
+{
+ devices->beginGroup(enc);
+ bool nb = devices->value("narrowband",false).toBool();
+ devices->endGroup();
+ return nb;
+}
+
+QStringList RbSettings::allPlatforms()
+{
+ QStringList result;
+ devices->beginGroup("platforms");
+ QStringList a = devices->childKeys();
+ for(int i = 0; i < a.size(); i++)
+ {
+ result.append(devices->value(a.at(i), "null").toString());
+ }
+ devices->endGroup();
+ return result;
+}
+
+QStringList RbSettings::allLanguages()
+{
+ QStringList result;
+ devices->beginGroup("languages");
+ QStringList a = devices->childKeys();
+ for(int i = 0; i < a.size(); i++)
+ {
+ result.append(devices->value(a.at(i), "null").toString());
+ }
+ devices->endGroup();
+ return result;
+}
+
+QString RbSettings::name(QString plattform)
+{
+ devices->beginGroup(plattform);
+ QString name = devices->value("name").toString();
+ devices->endGroup();
+ return name;
+}
+
+QString RbSettings::brand(QString plattform)
+{
+ devices->beginGroup(plattform);
+ QString brand = devices->value("brand").toString();
+ devices->endGroup();
+ return brand;
+}
+
+QString RbSettings::curResolution()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ QString resolution = devices->value("resolution").toString();
+ devices->endGroup();
+ return resolution;
+}
+
+int RbSettings::curTargetId()
+{
+ QString platform = userSettings->value("platform").toString();
+ devices->beginGroup(platform);
+ int id = devices->value("targetid").toInt();
+ devices->endGroup();
+ return id;
+}
+
+
+void RbSettings::setOfPath(QString path)
+{
+ userSettings->setValue("ofpath",path);
+}
+
+void RbSettings::setCachePath(QString path)
+{
+ userSettings->setValue("cachepath", path);
+}
+
+void RbSettings::setBuild(QString build)
+{
+ userSettings->setValue("build", build);
+}
+
+void RbSettings::setLastTalkedDir(QString dir)
+{
+ userSettings->setValue("last_talked_folder", dir);
+}
+
+void RbSettings::setVoiceLanguage(QString dir)
+{
+ userSettings->setValue("voicelanguage", dir);
+}
+
+void RbSettings::setWavtrimTh(int th)
+{
+ userSettings->setValue("wavtrimthreshold", th);
+}
+
+void RbSettings::setProxy(QString proxy)
+{
+ userSettings->setValue("proxy", proxy);
+}
+
+void RbSettings::setProxyType(QString proxytype)
+{
+ userSettings->setValue("proxytype", proxytype);
+}
+
+void RbSettings::setLang(QString lang)
+{
+ userSettings->setValue("lang", lang);
+}
+
+void RbSettings::setMountpoint(QString mp)
+{
+ userSettings->setValue("mountpoint",mp);
+}
+
+void RbSettings::setCurPlatform(QString platt)
+{
+ userSettings->setValue("platform",platt);
+}
+
+
+void RbSettings::setCacheDisable(bool on)
+{
+ userSettings->setValue("cachedisable",on);
+}
+
+void RbSettings::setCacheOffline(bool on)
+{
+ userSettings->setValue("offline",on);
+}
+
+void RbSettings::setCurTTS(QString tts)
+{
+ userSettings->setValue("tts",tts);
+}
+
+void RbSettings::setCurEncoder(QString enc)
+{
+ userSettings->setValue("encoder",enc);
+}
+
+void RbSettings::setTTSPath(QString tts, QString path)
+{
+ userSettings->beginGroup(tts);
+ userSettings->setValue("ttspath",path);
+ userSettings->endGroup();
+}
+
+void RbSettings::setTTSOptions(QString tts, QString options)
+{
+ userSettings->beginGroup(tts);
+ userSettings->setValue("ttsoptions",options);
+ userSettings->endGroup();
+}
+
+void RbSettings::setTTSVoice(QString tts, QString voice)
+{
+ userSettings->beginGroup(tts);
+ userSettings->setValue("ttsvoice",voice);
+ userSettings->endGroup();
+}
+
+void RbSettings::setTTSSpeed(QString tts, int speed)
+{
+ userSettings->beginGroup(tts);
+ userSettings->setValue("ttsspeed",speed);
+ userSettings->endGroup();
+}
+
+void RbSettings::setTTSLang(QString tts, QString lang)
+{
+ userSettings->beginGroup(tts);
+ userSettings->setValue("ttslanguage",lang);
+ userSettings->endGroup();
+}
+
+void RbSettings::setEncoderPath(QString enc, QString path)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("encoderpath",path);
+ userSettings->endGroup();
+}
+
+void RbSettings::setEncoderOptions(QString enc, QString options)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("encoderoptions",options);
+ userSettings->endGroup();
+}
+
+void RbSettings::setEncoderQuality(QString enc, double q)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("quality",q);
+ userSettings->endGroup();
+}
+void RbSettings::setEncoderComplexity(QString enc, int c)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("complexity",c);
+ userSettings->endGroup();
+}
+void RbSettings::setEncoderVolume(QString enc,double v)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("volume",v);
+ userSettings->endGroup();
+}
+void RbSettings::setEncoderNarrowband(QString enc,bool nb)
+{
+ userSettings->beginGroup(enc);
+ userSettings->setValue("narrowband",nb);
+ userSettings->endGroup();
+}
diff --git a/rbutil/rbutilqt/rbsettings.h b/rbutil/rbutilqt/rbsettings.h
new file mode 100644
index 0000000000..29aa9e8a1d
--- /dev/null
+++ b/rbutil/rbutilqt/rbsettings.h
@@ -0,0 +1,137 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: rbsettings.h 16059 2008-01-11 23:59:12Z domonoky $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef RBSETTINGS_H
+#define RBSETTINGS_H
+
+#include <QtGui>
+class QSettings;
+
+class RbSettings : public QObject
+{
+ Q_OBJECT
+
+ public:
+ RbSettings() {}
+
+ //! open the settings files
+ void open();
+ //! call this to flush the user Settings
+ void sync();
+
+ // returns the filename of the usersettings file
+ QString userSettingFilename();
+
+ //! access functions for the settings
+ bool cacheOffline();
+ bool cacheDisabled();
+ QString mountpoint();
+ QString manualUrl();
+ QString bleedingUrl();
+ QString lastRelease();
+ QString cachePath();
+ QString bootloaderUrl();
+ QString bootloaderInfoUrl();
+ QString fontUrl();
+ QString voiceUrl();
+ QString doomUrl();
+ QString downloadUrl();
+ 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);
+ 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();
+ QString name(QString plattform);
+ QString brand(QString plattform);
+ QStringList allLanguages();
+
+ bool curNeedsBootloader();
+ QString curBrand();
+ QString curName();
+ QString curPlatform();
+ QString curManual();
+ bool curReleased();
+ QString curBootloaderMethod();
+ QString curBootloaderName();
+ QString curVoiceName();
+ QString curLang();
+ QString curEncoder();
+ QString curTTS();
+ QString curResolution();
+ int curTargetId();
+
+
+
+ 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 setCurEncoder(QString enc);
+ 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 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:
+ QSettings *devices;
+ QSettings *userSettings;
+
+};
+
+#endif
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index a482daf29e..9d64eac5ea 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -49,26 +49,12 @@
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
{
absolutePath = qApp->applicationDirPath();
- // only use built-in rbutil.ini
- devices = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
-
+
ui.setupUi(this);
-
- // portable installation:
- // check for a configuration file in the program folder.
- QFileInfo config;
- config.setFile(absolutePath + "/RockboxUtility.ini");
- if(config.isFile()) {
- userSettings = new QSettings(absolutePath + "/RockboxUtility.ini",
- QSettings::IniFormat, 0);
- qDebug() << "config: portable";
- }
- else {
- userSettings = new QSettings(QSettings::IniFormat,
- QSettings::UserScope, "rockbox.org", "RockboxUtility");
- qDebug() << "config: system";
- }
-
+
+ settings = new RbSettings();
+ settings->open();
+
// manual tab
updateManual();
updateDevice();
@@ -147,11 +133,11 @@ void RbUtilQt::downloadInfo()
connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
daily->setProxy(proxy());
- if(userSettings->value("offline").toBool())
- daily->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(settings->cacheOffline())
+ daily->setCache(settings->cachePath());
qDebug() << "downloading build info";
daily->setFile(&buildInfo);
- daily->getFile(QUrl(devices->value("server_conf_url").toString()));
+ daily->getFile(QUrl(settings->serverConfUrl()));
}
@@ -174,10 +160,10 @@ void RbUtilQt::downloadDone(bool error)
connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
bleeding->setProxy(proxy());
- if(userSettings->value("offline").toBool())
- bleeding->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(settings->cacheOffline())
+ bleeding->setCache(settings->cachePath());
bleeding->setFile(&bleedingInfo);
- bleeding->getFile(QUrl(devices->value("bleeding_info").toString()));
+ bleeding->getFile(QUrl(settings->bleedingInfo()));
if(chkConfig(false)) {
QApplication::processEvents();
@@ -254,7 +240,7 @@ void RbUtilQt::help()
void RbUtilQt::configDialog()
{
Config *cw = new Config(this);
- cw->setSettings(userSettings,devices);
+ cw->setSettings(settings);
cw->show();
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
@@ -271,10 +257,7 @@ void RbUtilQt::updateSettings()
void RbUtilQt::updateDevice()
{
- platform = userSettings->value("platform").toString();
- // buttons
- devices->beginGroup(platform);
- if(devices->value("needsbootloader", "") == "no") {
+ if(!settings->curNeedsBootloader() ) {
ui.buttonBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
ui.labelBootloader->setEnabled(false);
@@ -283,7 +266,7 @@ void RbUtilQt::updateDevice()
else {
ui.buttonBootloader->setEnabled(true);
ui.labelBootloader->setEnabled(true);
- if(devices->value("bootloadermethod") == "fwpatcher") {
+ if(settings->curBootloaderMethod() == "fwpatcher") {
ui.labelRemoveBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
}
@@ -292,14 +275,11 @@ void RbUtilQt::updateDevice()
ui.buttonRemoveBootloader->setEnabled(true);
}
}
- devices->endGroup();
+
// displayed device info
- platform = userSettings->value("platform").toString();
- QString mountpoint = userSettings->value("mountpoint").toString();
- devices->beginGroup(platform);
- QString brand = devices->value("brand").toString();
- QString name = devices->value("name").toString();
- devices->endGroup();
+ QString mountpoint = settings->mountpoint();
+ QString brand = settings->curBrand();
+ QString name = settings->curName();
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>")
@@ -309,19 +289,16 @@ void RbUtilQt::updateDevice()
void RbUtilQt::updateManual()
{
- if(userSettings->value("platform").toString() != "")
+ if(settings->curPlatform() != "")
{
- devices->beginGroup(userSettings->value("platform").toString());
- QString manual;
- manual = devices->value("manualname", "").toString();
+ QString manual= settings->curManual();
if(manual == "")
- manual = "rockbox-" + devices->value("platform").toString();
- devices->endGroup();
+ manual = "rockbox-" + settings->curPlatform();
QString pdfmanual;
- pdfmanual = devices->value("manual_url").toString() + "/" + manual + ".pdf";
+ pdfmanual = settings->manualUrl() + "/" + manual + ".pdf";
QString htmlmanual;
- htmlmanual = devices->value("manual_url").toString() + "/" + manual + "/rockbox-build.html";
+ htmlmanual = settings->manualUrl() + "/" + 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>")
@@ -403,7 +380,7 @@ void RbUtilQt::smallInstall()
bool RbUtilQt::smallInstallInner()
{
- QString mountpoint = userSettings->value("mountpoint").toString();
+ QString mountpoint = settings->mountpoint();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -411,10 +388,7 @@ bool RbUtilQt::smallInstallInner()
return true;
}
// Bootloader
- devices->beginGroup(userSettings->value("platform").toString());
- QString needBootloader = devices->value("needsbootloader", "").toString();
- devices->endGroup();
- if(needBootloader == "yes")
+ if(settings->curNeedsBootloader())
{
m_error = false;
m_installed = false;
@@ -461,20 +435,16 @@ void RbUtilQt::installBtn()
bool RbUtilQt::installAuto()
{
QString file = QString("%1%2/rockbox.zip")
- .arg(devices->value("bleeding_url").toString(),
- userSettings->value("platform").toString());
+ .arg(settings->bleedingUrl(), settings->curPlatform());
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
- devices->beginGroup(platform);
- QString released = devices->value("released").toString();
- devices->endGroup();
- if(released == "yes") {
+ if(settings->curReleased()) {
// only set the keys if needed -- querying will yield an empty string
// if not set.
- versmap.insert("rel_rev", devices->value("last_release").toString());
+ versmap.insert("rel_rev", settings->lastRelease());
versmap.insert("rel_date", ""); // FIXME: provide the release timestamp
}
@@ -485,9 +455,9 @@ bool RbUtilQt::installAuto()
installer->setProxy(proxy());
installer->setLogSection("Rockbox (Base)");
installer->setLogVersion(myversion);
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
- installer->setMountPoint(userSettings->value("mountpoint").toString());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
+ installer->setMountPoint(settings->mountpoint());
installer->install(logger);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
@@ -498,21 +468,17 @@ bool RbUtilQt::installAuto()
void RbUtilQt::install()
{
Install *installWindow = new Install(this);
- installWindow->setUserSettings(userSettings);
- installWindow->setDeviceSettings(devices);
+ installWindow->setSettings(settings);
installWindow->setProxy(proxy());
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
- devices->beginGroup(platform);
- QString released = devices->value("released").toString();
- devices->endGroup();
- if(released == "yes") {
+ if(settings->curReleased()) {
// only set the keys if needed -- querying will yield an empty string
// if not set.
- versmap.insert("rel_rev", devices->value("last_release").toString());
+ versmap.insert("rel_rev", settings->lastRelease());
versmap.insert("rel_date", ""); // FIXME: provide the release timestamp
}
installWindow->setVersionStrings(versmap);
@@ -543,19 +509,19 @@ void RbUtilQt::installBootloaderBtn()
void RbUtilQt::installBootloader()
{
- QString platform = userSettings->value("platform").toString();
+ QString platform = settings->curPlatform();
// create installer
blinstaller = new BootloaderInstaller(this);
- blinstaller->setMountPoint(userSettings->value("mountpoint").toString());
+ blinstaller->setMountPoint(settings->mountpoint());
blinstaller->setProxy(proxy());
blinstaller->setDevice(platform);
- blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
- blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
- blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
- blinstaller->setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
+ blinstaller->setBootloaderMethod(settings->curBootloaderMethod());
+ blinstaller->setBootloaderName(settings->curBootloaderName());
+ blinstaller->setBootloaderBaseUrl(settings->bootloaderUrl());
+ blinstaller->setBootloaderInfoUrl(settings->bootloaderInfoUrl());
if(!blinstaller->downloadInfo())
{
logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
@@ -581,10 +547,10 @@ void RbUtilQt::installBootloader()
// if fwpatcher , ask for extra file
QString offirmware;
- if(devices->value(platform + "/bootloadermethod").toString() == "fwpatcher")
+ if(settings->curBootloaderMethod() == "fwpatcher")
{
BrowseOF ofbrowser(this);
- ofbrowser.setFile(userSettings->value("ofpath").toString());
+ ofbrowser.setFile(settings->ofPath());
if(ofbrowser.exec() == QDialog::Accepted)
{
offirmware = ofbrowser.getFile();
@@ -598,8 +564,8 @@ void RbUtilQt::installBootloader()
}
else
{
- userSettings->setValue("ofpath",offirmware);
- userSettings->sync();
+ settings->setOfPath(offirmware);
+ settings->sync();
}
}
else
@@ -639,13 +605,13 @@ void RbUtilQt::installFonts()
// create zip installer
installer = new ZipInstaller(this);
- installer->setUrl(devices->value("font_url").toString());
+ installer->setUrl(settings->fontUrl());
installer->setProxy(proxy());
installer->setLogSection("Fonts");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(userSettings->value("mountpoint").toString());
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ installer->setMountPoint(settings->mountpoint());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
installer->install(logger);
}
@@ -664,25 +630,22 @@ void RbUtilQt::installVoice()
installer = new ZipInstaller(this);
installer->setUnzip(false);
- QString voiceurl = devices->value("voice_url").toString() + "/" ;
+ QString voiceurl = settings->voiceUrl() + "/" ;
- devices->beginGroup(userSettings->value("platform").toString());
- voiceurl += devices->value("voicename").toString() + "-" +
+ voiceurl += settings->curVoiceName() + "-" +
versmap.value("arch_date") + "-english.voice";
- devices->endGroup();
qDebug() << voiceurl;
installer->setProxy(proxy());
installer->setUrl(voiceurl);
installer->setLogSection("Voice");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(userSettings->value("mountpoint").toString());
+ installer->setMountPoint(settings->mountpoint());
installer->setTarget("/.rockbox/langs/english.voice");
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
installer->install(logger);
- //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
}
void RbUtilQt::installDoomBtn()
@@ -711,7 +674,7 @@ bool RbUtilQt::installDoomAuto()
bool RbUtilQt::hasDoom()
{
- QFile doomrock(userSettings->value("mountpoint").toString()+"/.rockbox/rocks/games/doom.rock");
+ QFile doomrock(settings->mountpoint() +"/.rockbox/rocks/games/doom.rock");
return doomrock.exists();
}
@@ -720,35 +683,32 @@ void RbUtilQt::installDoom()
// create zip installer
installer = new ZipInstaller(this);
- installer->setUrl(devices->value("doom_url").toString());
+ installer->setUrl(settings->doomUrl());
installer->setProxy(proxy());
installer->setLogSection("Game Addons");
installer->setLogVersion(versmap.value("arch_date"));
- installer->setMountPoint(userSettings->value("mountpoint").toString());
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ installer->setMountPoint(settings->mountpoint());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
installer->install(logger);
}
-
void RbUtilQt::installThemes()
{
if(chkConfig(true)) return;
ThemesInstallWindow* tw = new ThemesInstallWindow(this);
- tw->setDeviceSettings(devices);
- tw->setUserSettings(userSettings);
+ tw->setSettings(settings);
tw->setProxy(proxy());
tw->setModal(true);
tw->show();
}
-
void RbUtilQt::createTalkFiles(void)
{
if(chkConfig(true)) return;
InstallTalkWindow *installWindow = new InstallTalkWindow(this);
- installWindow->setSettings(userSettings,devices);
+ installWindow->setSettings(settings);
installWindow->show();
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
@@ -759,7 +719,7 @@ void RbUtilQt::createVoiceFile(void)
{
if(chkConfig(true)) return;
CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
- installWindow->setSettings(userSettings,devices);
+ installWindow->setSettings(settings);
installWindow->setProxy(proxy());
installWindow->show();
@@ -771,8 +731,7 @@ void RbUtilQt::uninstall(void)
{
if(chkConfig(true)) return;
UninstallWindow *uninstallWindow = new UninstallWindow(this);
- uninstallWindow->setUserSettings(userSettings);
- uninstallWindow->setDeviceSettings(devices);
+ uninstallWindow->setSettings(settings);
uninstallWindow->show();
}
@@ -787,15 +746,14 @@ void RbUtilQt::uninstallBootloader(void)
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
- QString plattform = userSettings->value("platform").toString();
BootloaderInstaller blinstaller(this);
blinstaller.setProxy(proxy());
- blinstaller.setMountPoint(userSettings->value("mountpoint").toString());
- blinstaller.setDevice(userSettings->value("platform").toString());
- blinstaller.setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
- blinstaller.setBootloaderName(devices->value(plattform + "/bootloadername").toString());
- blinstaller.setBootloaderBaseUrl(devices->value("bootloader_url").toString());
- blinstaller.setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
+ blinstaller.setMountPoint(settings->mountpoint());
+ blinstaller.setDevice(settings->curPlatform());
+ blinstaller.setBootloaderMethod(settings->curBootloaderMethod());
+ blinstaller.setBootloaderName(settings->curBootloaderName());
+ blinstaller.setBootloaderBaseUrl(settings->bootloaderUrl());
+ blinstaller.setBootloaderInfoUrl(settings->bootloaderInfoUrl());
if(!blinstaller.downloadInfo())
{
logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
@@ -821,12 +779,8 @@ void RbUtilQt::downloadManual(void)
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
- devices->beginGroup(userSettings->value("platform").toString());
- QString manual;
- manual = devices->value("manualname", "rockbox-" +
- devices->value("platform").toString()).toString();
- devices->endGroup();
-
+ QString manual = settings->curManual();
+
QString date = (info.value("dailies/date").toString());
QString manualurl;
@@ -840,15 +794,15 @@ void RbUtilQt::downloadManual(void)
target = "/" + manual + "-" + date + "-html.zip";
section = "Manual (HTML)";
}
- manualurl = devices->value("manual_url").toString() + "/" + target;
+ manualurl = settings->manualUrl() + "/" + target;
qDebug() << "manualurl =" << manualurl;
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
installer = new ZipInstaller(this);
- installer->setMountPoint(userSettings->value("mountpoint").toString());
- if(!userSettings->value("cachedisable").toBool())
- installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ installer->setMountPoint(settings->mountpoint());
+ if(!settings->cacheDisabled())
+ installer->setCache(settings->cachePath());
installer->setProxy(proxy());
installer->setLogSection(section);
installer->setLogVersion(date);
@@ -874,23 +828,23 @@ void RbUtilQt::installPortable(void)
logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
// check mountpoint
- if(!QFileInfo(userSettings->value("mountpoint").toString()).isDir()) {
+ if(!QFileInfo(settings->mountpoint()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
return;
}
// remove old files first.
- QFile::remove(userSettings->value("mountpoint").toString() + "/RockboxUtility.exe");
- QFile::remove(userSettings->value("mountpoint").toString() + "/RockboxUtility.ini");
+ QFile::remove(settings->mountpoint() + "/RockboxUtility.exe");
+ QFile::remove(settings->mountpoint() + "/RockboxUtility.ini");
// copy currently running binary and currently used settings file
- if(!QFile::copy(qApp->applicationFilePath(), userSettings->value("mountpoint").toString() + "/RockboxUtility.exe")) {
+ if(!QFile::copy(qApp->applicationFilePath(), settings->mountpoint() + "/RockboxUtility.exe")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
logger->abort();
return;
}
logger->addItem(tr("Installing user configuration"), LOGINFO);
- if(!QFile::copy(userSettings->fileName(), userSettings->value("mountpoint").toString() + "/RockboxUtility.ini")) {
+ if(!QFile::copy(settings->userSettingFilename(), settings->mountpoint() + "/RockboxUtility.ini")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR);
logger->abort();
return;
@@ -907,7 +861,7 @@ void RbUtilQt::updateInfo()
{
qDebug() << "RbUtilQt::updateInfo()";
- QSettings log(userSettings->value("mountpoint").toString() + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
+ QSettings log(settings->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
QStringList groups = log.childGroups();
QList<QTreeWidgetItem *> items;
QTreeWidgetItem *w, *w2;
@@ -943,7 +897,7 @@ void RbUtilQt::updateInfo()
for(int b = 0; b < keys.size(); b++) {
QString file;
- file = userSettings->value("mountpoint").toString() + "/" + keys.at(b);
+ file = settings->mountpoint() + "/" + keys.at(b);
if(QFileInfo(file).isDir())
continue;
w2 = new QTreeWidgetItem(w, QStringList() << "/"
@@ -968,9 +922,9 @@ void RbUtilQt::updateInfo()
QUrl RbUtilQt::proxy()
{
- if(userSettings->value("proxytype", "system").toString() == "manual")
- return QUrl(userSettings->value("proxy").toString());
- else if(userSettings->value("proxytype", "system").toString() == "system")
+ if(settings->proxyType() == "manual")
+ return QUrl(settings->proxy());
+ else if(settings->proxy() == "system")
{
systemProxy();
}
@@ -981,9 +935,9 @@ QUrl RbUtilQt::proxy()
bool RbUtilQt::chkConfig(bool warn)
{
bool error = false;
- if(userSettings->value("platform").toString().isEmpty()
- || userSettings->value("mountpoint").toString().isEmpty()
- || !QFileInfo(userSettings->value("mountpoint").toString()).isWritable()) {
+ if(settings->curPlatform().isEmpty()
+ || settings->mountpoint().isEmpty()
+ || !QFileInfo(settings->mountpoint()).isWritable()) {
error = true;
if(warn) QMessageBox::critical(this, tr("Configuration error"),
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index f030d69f3c..35dbf0f30e 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -30,6 +30,7 @@
#include "progressloggergui.h"
#include "installbootloader.h"
+#include "rbsettings.h"
class RbUtilQt : public QMainWindow
{
@@ -40,8 +41,8 @@ class RbUtilQt : public QMainWindow
private:
Ui::RbUtilQtFrm ui;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
+
void initDeviceNames(void);
QString deviceName(QString);
QString platform;
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index ca20444a8b..252d116a86 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -52,7 +52,8 @@ SOURCES += rbutilqt.cpp \
../../tools/wavtrim.c \
../../tools/voicefont.c \
voicefile.cpp \
- createvoicewindow.cpp
+ createvoicewindow.cpp \
+ rbsettings.cpp
HEADERS += rbutilqt.h \
install.h \
@@ -94,7 +95,8 @@ HEADERS += rbutilqt.h \
../../tools/wavtrim.h \
../../tools/voicefont.h \
voicefile.h \
- createvoicewindow.h
+ createvoicewindow.h \
+ rbsettings.h
# Needed by QT on Win
INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex ../../tools
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp
index 89166daa90..be3934de91 100644
--- a/rbutil/rbutilqt/talkfile.cpp
+++ b/rbutil/rbutilqt/talkfile.cpp
@@ -31,8 +31,8 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
//tts
- m_tts = getTTS(userSettings->value("tts").toString());
- m_tts->setCfg(userSettings,deviceSettings);
+ m_tts = getTTS(settings->curTTS());
+ m_tts->setCfg(settings);
QString errStr;
if(!m_tts->start(&errStr))
@@ -44,8 +44,8 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
}
// Encoder
- m_enc = getEncoder(userSettings->value("encoder").toString());
- m_enc->setUserCfg(userSettings);
+ m_enc = getEncoder(settings->curEncoder());
+ m_enc->setCfg(settings);
if(!m_enc->start())
{
diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h
index 38462b1891..6d3b012413 100644
--- a/rbutil/rbutilqt/talkfile.h
+++ b/rbutil/rbutilqt/talkfile.h
@@ -36,7 +36,7 @@ public:
bool createTalkFiles(ProgressloggerInterface* logger);
- void setSettings(QSettings* uSettings,QSettings* dSettings) { userSettings = uSettings; deviceSettings = dSettings;}
+ void setSettings(RbSettings* sett) { settings = sett;}
void setDir(QDir dir){m_dir = dir; }
void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
@@ -55,8 +55,7 @@ private slots:
private:
TTSBase* m_tts;
EncBase* m_enc;
- QSettings *userSettings;
- QSettings *deviceSettings;
+ RbSettings* settings;
QDir m_dir;
QString m_mountpoint;
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp
index de8e1d4468..be2a20a31e 100644
--- a/rbutil/rbutilqt/tts.cpp
+++ b/rbutil/rbutilqt/tts.cpp
@@ -106,10 +106,8 @@ TTSExes::TTSExes(QString name,QWidget *parent) : TTSBase(parent)
bool TTSExes::start(QString *errStr)
{
- userSettings->beginGroup(m_name);
- m_TTSexec = userSettings->value("ttspath","").toString();
- m_TTSOpts = userSettings->value("ttsoptions","").toString();
- userSettings->endGroup();
+ m_TTSexec = settings->ttsPath(m_name);
+ m_TTSOpts = settings->ttsOptions(m_name);
m_TTSTemplate = m_TemplateMap.value(m_name);
@@ -149,10 +147,8 @@ void TTSExes::reset()
void TTSExes::showCfg()
{
// try to get config from settings
- userSettings->beginGroup(m_name);
- QString exepath =userSettings->value("ttspath","").toString();
- ui.ttsoptions->setText(userSettings->value("ttsoptions","").toString());
- userSettings->endGroup();
+ QString exepath =settings->ttsPath(m_name);
+ ui.ttsoptions->setText(settings->ttsOptions(m_name));
if(exepath == "")
{
@@ -191,16 +187,12 @@ void TTSExes::showCfg()
void TTSExes::accept(void)
{
- if(userSettings != NULL)
- {
- //save settings in user config
- userSettings->beginGroup(m_name);
- userSettings->setValue("ttspath",ui.ttspath->text());
- userSettings->setValue("ttsoptions",ui.ttsoptions->text());
- userSettings->endGroup();
- // sync settings
- userSettings->sync();
- }
+ //save settings in user config
+ settings->setTTSPath(m_name,ui.ttspath->text());
+ settings->setTTSOptions(m_name,ui.ttsoptions->text());
+ // sync settings
+ settings->sync();
+
this->close();
}
@@ -211,9 +203,7 @@ void TTSExes::reject(void)
bool TTSExes::configOk()
{
- userSettings->beginGroup(m_name);
- QString path = userSettings->value("ttspath","").toString();
- userSettings->endGroup();
+ QString path = settings->ttsPath(m_name);
if (QFileInfo(path).exists())
return true;
@@ -257,12 +247,10 @@ TTSSapi::TTSSapi(QWidget *parent) : TTSBase(parent)
bool TTSSapi::start(QString *errStr)
{
- userSettings->beginGroup("sapi");
- m_TTSOpts = userSettings->value("ttsoptions","").toString();
- m_TTSLanguage =userSettings->value("ttslanguage","").toString();
- m_TTSVoice=userSettings->value("ttsvoice","").toString();
- m_TTSSpeed=userSettings->value("ttsspeed","").toString();
- userSettings->endGroup();
+ m_TTSOpts = settings->ttsOptions("sapi");
+ m_TTSLanguage =settings->ttsLang("sapi");
+ m_TTSVoice=settings->ttsVoice("sapi");
+ m_TTSSpeed=settings->ttsSpeed("sapi");
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
@@ -384,23 +372,14 @@ void TTSSapi::reset()
void TTSSapi::showCfg()
{
// try to get config from settings
- userSettings->beginGroup("sapi");
- ui.ttsoptions->setText(userSettings->value("ttsoptions","").toString());
- QString selLang = userSettings->value("ttslanguage",defaultLanguage).toString();
- QString selVoice = userSettings->value("ttsvoice","").toString();
- ui.speed->setValue(userSettings->value("ttsspeed",0).toInt());
- userSettings->endGroup();
+ ui.ttsoptions->setText(settings->ttsOptions("sapi"));
+ QString selLang = settings->ttsLang("sapi");
+ QString selVoice = settings->ttsVoice("sapi");
+ ui.speed->setValue(settings->ttsSpeed("sapi"));
+
// fill in language combobox
-
- deviceSettings->beginGroup("languages");
- QStringList keys = deviceSettings->allKeys();
- QStringList languages;
- for(int i =0 ; i < keys.size();i++)
- {
- languages << deviceSettings->value(keys.at(i)).toString();
- }
- deviceSettings->endGroup();
+ QStringList languages = settings->allLanguages();
languages.sort();
ui.languagecombo->clear();
@@ -422,18 +401,14 @@ void TTSSapi::showCfg()
void TTSSapi::accept(void)
{
- if(userSettings != NULL)
- {
- //save settings in user config
- userSettings->beginGroup("sapi");
- userSettings->setValue("ttsoptions",ui.ttsoptions->text());
- userSettings->setValue("ttslanguage",ui.languagecombo->currentText());
- userSettings->setValue("ttsvoice",ui.voicecombo->currentText());
- userSettings->setValue("ttsspeed",QString("%1").arg(ui.speed->value()));
- userSettings->endGroup();
- // sync settings
- userSettings->sync();
- }
+ //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());
+ // sync settings
+ settings->sync();
+
this->close();
}
diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h
index d792f077e0..90c402d8cc 100644
--- a/rbutil/rbutilqt/tts.h
+++ b/rbutil/rbutilqt/tts.h
@@ -23,6 +23,7 @@
#include "ui_ttsexescfgfrm.h"
#include "ui_sapicfgfrm.h"
+#include "rbsettings.h"
#include <QtGui>
@@ -47,7 +48,7 @@ public:
virtual void showCfg(){}
virtual bool configOk(){return false;}
- void setCfg(QSettings *uSettings, QSettings *dSettings){userSettings = uSettings;deviceSettings = dSettings;}
+ void setCfg(RbSettings* sett){settings = sett;}
public slots:
virtual void accept(void){}
@@ -55,9 +56,7 @@ public slots:
virtual void reset(void){}
protected:
- QSettings *userSettings;
- QSettings *deviceSettings;
-
+ RbSettings* settings;
};
class TTSSapi : public TTSBase
diff --git a/rbutil/rbutilqt/uninstallwindow.cpp b/rbutil/rbutilqt/uninstallwindow.cpp
index 61ca8410be..86c7400b99 100644
--- a/rbutil/rbutilqt/uninstallwindow.cpp
+++ b/rbutil/rbutilqt/uninstallwindow.cpp
@@ -67,18 +67,12 @@ void UninstallWindow::UninstallMethodChanged(bool complete)
ui.smartGroupBox->setEnabled(true);
}
-void UninstallWindow::setDeviceSettings(QSettings *dev)
-{
- devices = dev;
- qDebug() << "Install::setDeviceSettings:" << devices;
-}
-
-void UninstallWindow::setUserSettings(QSettings *user)
+void UninstallWindow::setSettings(RbSettings *sett)
{
- userSettings = user;
+ settings = sett;
- QString mountpoint =userSettings->value("mountpoint").toString();
+ QString mountpoint =settings->mountpoint();
uninstaller = new Uninstaller(this,mountpoint);
// disable smart uninstall, if not possible
diff --git a/rbutil/rbutilqt/uninstallwindow.h b/rbutil/rbutilqt/uninstallwindow.h
index e765e18272..f2dfcc851e 100644
--- a/rbutil/rbutilqt/uninstallwindow.h
+++ b/rbutil/rbutilqt/uninstallwindow.h
@@ -22,19 +22,17 @@
#include <QtGui>
-#include <QSettings>
-
#include "ui_uninstallfrm.h"
#include "progressloggergui.h"
#include "uninstall.h"
+#include "rbsettings.h"
class UninstallWindow : public QDialog
{
Q_OBJECT
public:
UninstallWindow(QWidget *parent = 0);
- void setUserSettings(QSettings*);
- void setDeviceSettings(QSettings*);
+ void setSettings(RbSettings* sett);
public slots:
void accept(void);
@@ -46,8 +44,7 @@ class UninstallWindow : public QDialog
Uninstaller* uninstaller;
Ui::UninstallFrm ui;
ProgressLoggerGui* logger;
- QSettings *devices;
- QSettings *userSettings;
+ RbSettings* settings;
};
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp
index 47b659a347..4601bcc698 100644
--- a/rbutil/rbutilqt/voicefile.cpp
+++ b/rbutil/rbutilqt/voicefile.cpp
@@ -77,7 +77,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
info.close();
//prepare download url
- QUrl genlangUrl = deviceSettings->value("genlang_url").toString() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features;
+ QUrl genlangUrl = settings->genlangUrl() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features;
qDebug() << "downloading " << genlangUrl;
@@ -146,8 +146,8 @@ void VoiceFileCreator::downloadDone(bool error)
}
//tts
- m_tts = getTTS(userSettings->value("tts").toString());
- m_tts->setCfg(userSettings,deviceSettings);
+ m_tts = getTTS(settings->curTTS());
+ m_tts->setCfg(settings);
QString errStr;
if(!m_tts->start(&errStr))
@@ -159,8 +159,8 @@ void VoiceFileCreator::downloadDone(bool error)
}
// Encoder
- m_enc = getEncoder(userSettings->value("encoder").toString());
- m_enc->setUserCfg(userSettings);
+ m_enc = getEncoder(settings->curEncoder());
+ m_enc->setCfg(settings);
if(!m_enc->start())
{
diff --git a/rbutil/rbutilqt/voicefile.h b/rbutil/rbutilqt/voicefile.h
index ce7c953237..43eb95a69b 100644
--- a/rbutil/rbutilqt/voicefile.h
+++ b/rbutil/rbutilqt/voicefile.h
@@ -27,6 +27,7 @@
#include "encoders.h"
#include "tts.h"
#include "httpget.h"
+#include "rbsettings.h"
extern "C"
{
@@ -44,7 +45,7 @@ public:
bool createVoiceFile(ProgressloggerInterface* logger);
// set infos
- void setSettings(QSettings* uSettings,QSettings* dSettings) { userSettings = uSettings;deviceSettings = dSettings;}
+ void setSettings(RbSettings* sett) { settings = sett;}
void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
void setTargetId(int id){m_targetid = id;}
@@ -63,9 +64,7 @@ private:
// ptr to encoder, tts and settings
TTSBase* m_tts;
EncBase* m_enc;
- QSettings *userSettings;
- QSettings *deviceSettings;
-
+ RbSettings* settings;
HttpGet *getter;
QUrl m_proxy; //proxy