summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2009-05-09 16:59:14 +0000
committerDominik Wenger <domonoky@googlemail.com>2009-05-09 16:59:14 +0000
commit33d9cf091a62cb217987092d03bf110c35444845 (patch)
tree4ee6be3018e0b71c38d4857f86ad17a08668afdd /rbutil/rbutilqt/base
parent8e63df19cbeee2de9470049feae8ae0f9c5a339e (diff)
downloadrockbox-33d9cf091a62cb217987092d03bf110c35444845.tar.gz
rockbox-33d9cf091a62cb217987092d03bf110c35444845.tar.bz2
rockbox-33d9cf091a62cb217987092d03bf110c35444845.zip
rbutil: make RbSettings a static class. (FS#10183 with improvements)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20890 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp7
-rw-r--r--rbutil/rbutilqt/base/autodetection.h4
-rw-r--r--rbutil/rbutilqt/base/detect.cpp9
-rw-r--r--rbutil/rbutilqt/base/detect.h3
-rw-r--r--rbutil/rbutilqt/base/encoders.cpp49
-rw-r--r--rbutil/rbutilqt/base/encoders.h7
-rw-r--r--rbutil/rbutilqt/base/rbsettings.cpp86
-rw-r--r--rbutil/rbutilqt/base/rbsettings.h79
-rw-r--r--rbutil/rbutilqt/base/tts.cpp81
-rw-r--r--rbutil/rbutilqt/base/tts.h7
10 files changed, 177 insertions, 155 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 276c270499..30651077f2 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -19,6 +19,7 @@
#include <QtCore>
#include "autodetection.h"
+#include "rbsettings.h"
#include "../ipodpatcher/ipodpatcher.h"
#include "../sansapatcher/sansapatcher.h"
@@ -396,9 +397,9 @@ bool Autodetection::detectUsb()
// usbids holds the mapping in the form
// ((VID<<16)|(PID)), targetname
// the ini file needs to hold the IDs as hex values.
- QMap<int, QString> usbids = settings->usbIdMap(RbSettings::MapDevice);
- QMap<int, QString> usberror = settings->usbIdMap(RbSettings::MapError);
- QMap<int, QString> usbincompat = settings->usbIdMap(RbSettings::MapIncompatible);
+ QMap<int, QString> usbids = RbSettings::usbIdMap(RbSettings::MapDevice);
+ QMap<int, QString> usberror = RbSettings::usbIdMap(RbSettings::MapError);
+ QMap<int, QString> usbincompat = RbSettings::usbIdMap(RbSettings::MapIncompatible);
// usb pid detection
QList<uint32_t> attached;
diff --git a/rbutil/rbutilqt/base/autodetection.h b/rbutil/rbutilqt/base/autodetection.h
index cffab5bd4f..c6b33ac313 100644
--- a/rbutil/rbutilqt/base/autodetection.h
+++ b/rbutil/rbutilqt/base/autodetection.h
@@ -24,7 +24,6 @@
#define AUTODETECTION_H_
#include <QtCore>
-#include "rbsettings.h"
class Autodetection :public QObject
{
@@ -33,8 +32,6 @@ class Autodetection :public QObject
public:
Autodetection(QObject* parent=0);
- void setSettings(RbSettings* sett) {settings = sett;}
-
bool detect();
QString getDevice() {return m_device;}
@@ -54,7 +51,6 @@ private:
QString m_errdev;
QString m_incompat;
QList<int> m_usbconid;
- RbSettings* settings;
};
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/detect.cpp
index df1cf50647..88ffb36723 100644
--- a/rbutil/rbutilqt/base/detect.cpp
+++ b/rbutil/rbutilqt/base/detect.cpp
@@ -59,6 +59,7 @@
#endif
#include "utils.h"
+#include "rbsettings.h"
/** @brief detect permission of user (only Windows at moment).
* @return enum userlevel.
@@ -384,7 +385,7 @@ QString Detect::installedTarget(QString mountpoint)
* @param targetId the targetID to check for. if it is -1 no check is done.
* @return string with error messages if problems occurred, empty strings if none.
*/
-QString Detect::check(RbSettings* settings, bool permission)
+QString Detect::check(bool permission)
{
QString text = "";
@@ -401,12 +402,12 @@ QString Detect::check(RbSettings* settings, bool permission)
}
// Check TargetId
- QString installed = installedTarget(settings->value(RbSettings::Mountpoint).toString());
- if(!installed.isEmpty() && installed != settings->value(RbSettings::CurConfigureModel).toString())
+ QString installed = installedTarget(RbSettings::value(RbSettings::Mountpoint).toString());
+ if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
{
text += QObject::tr("<li>Target mismatch detected.\n"
"Installed target: %1, selected target: %2.</li>")
- .arg(installed, settings->value(RbSettings::CurPlatformName).toString());
+ .arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
// FIXME: replace installed by human-friendly name
}
diff --git a/rbutil/rbutilqt/base/detect.h b/rbutil/rbutilqt/base/detect.h
index 3077699a93..96c0696467 100644
--- a/rbutil/rbutilqt/base/detect.h
+++ b/rbutil/rbutilqt/base/detect.h
@@ -27,7 +27,6 @@
#include <QString>
#include <QUrl>
-#include "rbsettings.h"
class Detect
{
@@ -49,7 +48,7 @@ public:
static QString installedVersion(QString mountpoint);
static QString installedTarget(QString mountpoint);
- static QString check(RbSettings* settings, bool permission);
+ static QString check(bool permission);
};
#endif
diff --git a/rbutil/rbutilqt/base/encoders.cpp b/rbutil/rbutilqt/base/encoders.cpp
index 6ff1185c82..59add74a0d 100644
--- a/rbutil/rbutilqt/base/encoders.cpp
+++ b/rbutil/rbutilqt/base/encoders.cpp
@@ -19,6 +19,7 @@
#include "encoders.h"
#include "utils.h"
+#include "rbsettings.h"
/*********************************************************************
* Encoder Base
@@ -87,24 +88,24 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
void EncExes::generateSettings()
{
- QString exepath =settings->subValue(m_name,RbSettings::EncoderPath).toString();
+ QString exepath =RbSettings::subValue(m_name,RbSettings::EncoderPath).toString();
if(exepath == "") exepath = findExecutable(m_name);
insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Encoder:",exepath,EncTtsSetting::eBROWSEBTN));
- insertSetting(eEXEOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Encoder options:",settings->subValue(m_name,RbSettings::EncoderOptions)));
+ insertSetting(eEXEOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Encoder options:",RbSettings::subValue(m_name,RbSettings::EncoderOptions)));
}
void EncExes::saveSettings()
{
- settings->setSubValue(m_name,RbSettings::EncoderPath,getSetting(eEXEPATH)->current().toString());
- settings->setSubValue(m_name,RbSettings::EncoderOptions,getSetting(eEXEOPTIONS)->current().toString());
- settings->sync();
+ RbSettings::setSubValue(m_name,RbSettings::EncoderPath,getSetting(eEXEPATH)->current().toString());
+ RbSettings::setSubValue(m_name,RbSettings::EncoderOptions,getSetting(eEXEOPTIONS)->current().toString());
+ RbSettings::sync();
}
bool EncExes::start()
{
- m_EncExec = settings->subValue(m_name, RbSettings::EncoderPath).toString();
- m_EncOpts = settings->subValue(m_name, RbSettings::EncoderOptions).toString();
+ m_EncExec = RbSettings::subValue(m_name, RbSettings::EncoderPath).toString();
+ m_EncOpts = RbSettings::subValue(m_name, RbSettings::EncoderOptions).toString();
m_EncTemplate = m_TemplateMap.value(m_name);
@@ -136,7 +137,7 @@ bool EncExes::encode(QString input,QString output)
bool EncExes::configOk()
{
- QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
+ QString path = RbSettings::subValue(m_name, RbSettings::EncoderPath).toString();
if (QFileInfo(path).exists())
return true;
@@ -154,31 +155,31 @@ EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent)
void EncRbSpeex::generateSettings()
{
- insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Volume:",settings->subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
- insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Quality:",settings->subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
- insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,"Complexity:",settings->subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
- insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,"Use Narrowband:",settings->subValue("rbspeex",RbSettings::EncoderNarrowBand)));
+ insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Volume:",RbSettings::subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
+ insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Quality:",RbSettings::subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
+ insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,"Complexity:",RbSettings::subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
+ insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,"Use Narrowband:",RbSettings::subValue("rbspeex",RbSettings::EncoderNarrowBand)));
}
void EncRbSpeex::saveSettings()
{
//save settings in user config
- settings->setSubValue("rbspeex",RbSettings::EncoderVolume,getSetting(eVOLUME)->current().toDouble());
- settings->setSubValue("rbspeex",RbSettings::EncoderQuality,getSetting(eQUALITY)->current().toDouble());
- settings->setSubValue("rbspeex",RbSettings::EncoderComplexity,getSetting(eCOMPLEXITY)->current().toInt());
- settings->setSubValue("rbspeex",RbSettings::EncoderNarrowBand,getSetting(eNARROWBAND)->current().toBool());
+ RbSettings::setSubValue("rbspeex",RbSettings::EncoderVolume,getSetting(eVOLUME)->current().toDouble());
+ RbSettings::setSubValue("rbspeex",RbSettings::EncoderQuality,getSetting(eQUALITY)->current().toDouble());
+ RbSettings::setSubValue("rbspeex",RbSettings::EncoderComplexity,getSetting(eCOMPLEXITY)->current().toInt());
+ RbSettings::setSubValue("rbspeex",RbSettings::EncoderNarrowBand,getSetting(eNARROWBAND)->current().toBool());
- settings->sync();
+ RbSettings::sync();
}
bool EncRbSpeex::start()
{
// try to get config from settings
- 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();
+ quality = RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble();
+ complexity = RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt();
+ volume = RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble();
+ narrowband = RbSettings::subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool();
return true;
@@ -219,13 +220,13 @@ bool EncRbSpeex::configOk()
bool result=true;
// check config
- if(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
+ if(RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
result =false;
- if(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
+ if(RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
result =false;
- if(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
+ if(RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
result =false;
return result;
diff --git a/rbutil/rbutilqt/base/encoders.h b/rbutil/rbutilqt/base/encoders.h
index d5d1723a46..a70f775e98 100644
--- a/rbutil/rbutilqt/base/encoders.h
+++ b/rbutil/rbutilqt/base/encoders.h
@@ -24,7 +24,6 @@
#include <QtCore>
-#include "rbsettings.h"
#include "encttssettings.h"
#include "rbspeex.h"
@@ -54,15 +53,11 @@ class EncBase : public EncTtsSettingInterface
static QString getEncoderName(QString name);
static EncBase* getEncoder(QObject* parent,QString name);
static QStringList getEncoderList(void);
-
- //set the config. users of Encoder classes, always have to call this first
- void setCfg(RbSettings *sett){settings = sett;}
+
private:
static void initEncodernamesList(void);
protected:
- RbSettings* settings;
-
static QMap<QString,QString> encoderList;
};
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp
index 12654cd288..8e2e7c26d2 100644
--- a/rbutil/rbutilqt/base/rbsettings.cpp
+++ b/rbutil/rbutilqt/base/rbsettings.cpp
@@ -25,6 +25,7 @@
#include <unistd.h>
#endif
+
// device settings
const static struct {
RbSettings::SystemSettings setting;
@@ -94,31 +95,45 @@ const static struct {
{ RbSettings::EncoderVolume, ":encoder:/volume", "1.0" },
};
-void RbSettings::open()
+//! pointer to setting object to NULL
+QSettings* RbSettings::systemSettings = NULL;
+QSettings* RbSettings::userSettings = NULL;
+
+void RbSettings::ensureRbSettingsExists()
{
- // only use built-in rbutil.ini
- systemSettings = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
- // portable installation:
- // check for a configuration file in the program folder.
- QFileInfo config;
- config.setFile(QCoreApplication::instance()->applicationDirPath()
- + "/RockboxUtility.ini");
- if(config.isFile())
+ //check and create settings object
+ if(systemSettings == NULL)
{
- userSettings = new QSettings(QCoreApplication::instance()->applicationDirPath()
- + "/RockboxUtility.ini", QSettings::IniFormat, this);
- qDebug() << "config: portable";
+ // only use built-in rbutil.ini
+ systemSettings = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
}
- else
+
+ if(userSettings == NULL)
{
- userSettings = new QSettings(QSettings::IniFormat,
- QSettings::UserScope, "rockbox.org", "RockboxUtility",this);
- qDebug() << "config: system";
+ // portable installation:
+ // check for a configuration file in the program folder.
+ QFileInfo config;
+ config.setFile(QCoreApplication::instance()->applicationDirPath()
+ + "/RockboxUtility.ini");
+ if(config.isFile())
+ {
+ userSettings = new QSettings(QCoreApplication::instance()->applicationDirPath()
+ + "/RockboxUtility.ini", QSettings::IniFormat, NULL);
+ qDebug() << "config: portable";
+ }
+ else
+ {
+ userSettings = new QSettings(QSettings::IniFormat,
+ QSettings::UserScope, "rockbox.org", "RockboxUtility",NULL);
+ qDebug() << "config: system";
+ }
}
}
void RbSettings::sync()
{
+ ensureRbSettingsExists();
+
userSettings->sync();
#if defined(Q_OS_LINUX)
// when using sudo it runs rbutil with uid 0 but unfortunately without a
@@ -143,9 +158,16 @@ void RbSettings::sync()
#endif
}
+QString RbSettings::userSettingFilename()
+{
+ ensureRbSettingsExists();
+ return userSettings->fileName();
+}
QVariant RbSettings::value(enum SystemSettings setting)
{
+ ensureRbSettingsExists();
+
// locate setting item
int i = 0;
while(SystemSettingsList[i].setting != setting)
@@ -158,15 +180,16 @@ QVariant RbSettings::value(enum SystemSettings setting)
return systemSettings->value(s, d);
}
-
-QString RbSettings::userSettingFilename()
-{
- return userSettings->fileName();
+QVariant RbSettings::value(enum UserSettings setting)
+{
+ QString empty;
+ return subValue(empty, setting);
}
-
-QVariant RbSettings::subValue(QString& sub, enum UserSettings setting)
+QVariant RbSettings::subValue(QString sub, enum UserSettings setting)
{
+ ensureRbSettingsExists();
+
// locate setting item
int i = 0;
while(UserSettingsList[i].setting != setting)
@@ -177,9 +200,16 @@ QVariant RbSettings::subValue(QString& sub, enum UserSettings setting)
return userSettings->value(s, UserSettingsList[i].def);
}
+void RbSettings::setValue(enum UserSettings setting , QVariant value)
+{
+ QString empty;
+ return setSubValue(empty, setting, value);
+}
-void RbSettings::setSubValue(QString& sub, enum UserSettings setting, QVariant value)
+void RbSettings::setSubValue(QString sub, enum UserSettings setting, QVariant value)
{
+ ensureRbSettingsExists();
+
// locate setting item
int i = 0;
while(UserSettingsList[i].setting != setting)
@@ -190,10 +220,10 @@ void RbSettings::setSubValue(QString& sub, enum UserSettings setting, QVariant v
userSettings->setValue(s, value);
}
-
-
QStringList RbSettings::platforms()
{
+ ensureRbSettingsExists();
+
QStringList result;
systemSettings->beginGroup("platforms");
QStringList a = systemSettings->childKeys();
@@ -207,6 +237,8 @@ QStringList RbSettings::platforms()
QStringList RbSettings::languages()
{
+ ensureRbSettingsExists();
+
QStringList result;
systemSettings->beginGroup("languages");
QStringList a = systemSettings->childKeys();
@@ -220,16 +252,20 @@ QStringList RbSettings::languages()
QString RbSettings::name(QString platform)
{
+ ensureRbSettingsExists();
return systemSettings->value(platform + "/name").toString();
}
QString RbSettings::brand(QString platform)
{
+ ensureRbSettingsExists();
return systemSettings->value(platform + "/brand").toString();
}
QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
{
+ ensureRbSettingsExists();
+
QMap<int, QString> map;
// get a list of ID -> target name
QStringList platforms;
diff --git a/rbutil/rbutilqt/base/rbsettings.h b/rbutil/rbutilqt/base/rbsettings.h
index 341577abc8..4f2a5c3617 100644
--- a/rbutil/rbutilqt/base/rbsettings.h
+++ b/rbutil/rbutilqt/base/rbsettings.h
@@ -29,23 +29,15 @@ 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();
-
+ //! Type of requested usb-id map
enum MapType {
MapDevice,
MapError,
MapIncompatible,
};
+
+ //! All user settings
enum UserSettings {
RbutilVersion,
CurrentPlatform,
@@ -76,6 +68,8 @@ class RbSettings : public QObject
EncoderQuality,
EncoderVolume,
};
+
+ //! All system settings
enum SystemSettings {
ManualUrl,
BleedingUrl,
@@ -103,40 +97,43 @@ class RbSettings : public QObject
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); }
-
- 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);
+
+ //! call this to flush the user Settings
+ static void sync();
+ //! returns the filename of the usersettings file
+ static QString userSettingFilename();
+ //! return a list of all platforms (rbutil internal names)
+ static QStringList platforms(void);
+ //! returns a list of all languages
+ static QStringList languages(void);
+ //! maps a platform to its name
+ static QString name(QString plattform);
+ //! maps a platform to its brand
+ static QString brand(QString plattform);
+ //! returns a map of usb-ids and their targets
+ static QMap<int, QString> usbIdMap(enum MapType);
+ //! get a value from system settings
+ static QVariant value(enum SystemSettings setting);
+ //! get a vaulue from user settings
+ static QVariant value(enum UserSettings setting);
+ //! set a user setting value
+ static void setValue(enum UserSettings setting , QVariant value);
+ //! get a user setting from a subvalue (ie for encoders and tts engines)
+ static QVariant subValue(QString sub, enum UserSettings setting);
+ //! set a user setting from a subvalue (ie for encoders and tts engines)
+ static void setSubValue(QString sub, enum UserSettings setting, QVariant value);
private:
- //! 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());
+ //! you shouldnt call this, its a fully static calls
+ RbSettings() {}
+ //! create the setting objects if neccessary
+ static void ensureRbSettingsExists();
+ //! create a settings path, substitute platform, tts and encoder
+ static QString constructSettingPath(QString path, QString substitute = QString());
//! pointers to our setting objects
- QSettings *systemSettings;
- QSettings *userSettings;
+ static QSettings *systemSettings;
+ static QSettings *userSettings;
};
#endif
diff --git a/rbutil/rbutilqt/base/tts.cpp b/rbutil/rbutilqt/base/tts.cpp
index d55ba9e739..70332f5f38 100644
--- a/rbutil/rbutilqt/base/tts.cpp
+++ b/rbutil/rbutilqt/base/tts.cpp
@@ -19,6 +19,7 @@
#include "tts.h"
#include "utils.h"
+#include "rbsettings.h"
/*********************************************************************
* TTS Base
**********************************************************************/
@@ -105,24 +106,24 @@ TTSExes::TTSExes(QString name,QObject* parent) : TTSBase(parent)
void TTSExes::generateSettings()
{
- QString exepath =settings->subValue(m_name,RbSettings::TtsPath).toString();
+ QString exepath =RbSettings::subValue(m_name,RbSettings::TtsPath).toString();
if(exepath == "") exepath = findExecutable(m_name);
insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to TTS engine:",exepath,EncTtsSetting::eBROWSEBTN));
- insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"TTS enginge options:",settings->subValue(m_name,RbSettings::TtsOptions)));
+ insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"TTS enginge options:",RbSettings::subValue(m_name,RbSettings::TtsOptions)));
}
void TTSExes::saveSettings()
{
- settings->setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString());
- settings->setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
- settings->sync();
+ RbSettings::setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString());
+ RbSettings::setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
+ RbSettings::sync();
}
bool TTSExes::start(QString *errStr)
{
- m_TTSexec = settings->subValue(m_name,RbSettings::TtsPath).toString();
- m_TTSOpts = settings->subValue(m_name,RbSettings::TtsOptions).toString();
+ m_TTSexec = RbSettings::subValue(m_name,RbSettings::TtsPath).toString();
+ m_TTSOpts = RbSettings::subValue(m_name,RbSettings::TtsOptions).toString();
m_TTSTemplate = m_TemplateMap.value(m_name);
@@ -155,7 +156,7 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
bool TTSExes::configOk()
{
- QString path = settings->subValue(m_name,RbSettings::TtsPath).toString();
+ QString path = RbSettings::subValue(m_name,RbSettings::TtsPath).toString();
if (QFileInfo(path).exists())
return true;
@@ -176,31 +177,31 @@ TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
void TTSSapi::generateSettings()
{
// language
- QStringList languages = settings->languages();
+ QStringList languages = RbSettings::languages();
languages.sort();
- EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Language:",settings->subValue("sapi",RbSettings::TtsLanguage),languages);
+ EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Language:",RbSettings::subValue("sapi",RbSettings::TtsLanguage),languages);
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
insertSetting(eLANGUAGE,setting);
// voice
- setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("sapi",RbSettings::TtsVoice),getVoiceList(settings->subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN);
+ setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",RbSettings::subValue("sapi",RbSettings::TtsVoice),getVoiceList(RbSettings::subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN);
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
insertSetting(eVOICE,setting);
//speed
- insertSetting(eSPEED,new EncTtsSetting(this,EncTtsSetting::eINT,"Speed:",settings->subValue("sapi",RbSettings::TtsSpeed),-10,10));
+ insertSetting(eSPEED,new EncTtsSetting(this,EncTtsSetting::eINT,"Speed:",RbSettings::subValue("sapi",RbSettings::TtsSpeed),-10,10));
// options
- insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Options:",settings->subValue("sapi",RbSettings::TtsOptions)));
+ insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Options:",RbSettings::subValue("sapi",RbSettings::TtsOptions)));
}
void TTSSapi::saveSettings()
{
//save settings in user config
- settings->setSubValue("sapi",RbSettings::TtsLanguage,getSetting(eLANGUAGE)->current().toString());
- settings->setSubValue("sapi",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
- settings->setSubValue("sapi",RbSettings::TtsSpeed,getSetting(eSPEED)->current().toInt());
- settings->setSubValue("sapi",RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
+ RbSettings::setSubValue("sapi",RbSettings::TtsLanguage,getSetting(eLANGUAGE)->current().toString());
+ RbSettings::setSubValue("sapi",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
+ RbSettings::setSubValue("sapi",RbSettings::TtsSpeed,getSetting(eSPEED)->current().toInt());
+ RbSettings::setSubValue("sapi",RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
- settings->sync();
+ RbSettings::sync();
}
void TTSSapi::updateVoiceList()
@@ -215,11 +216,11 @@ void TTSSapi::updateVoiceList()
bool TTSSapi::start(QString *errStr)
{
- 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=settings->subValue("sapi",RbSettings::TtsSpeed).toString();
- m_sapi4 = settings->subValue("sapi",RbSettings::TtsUseSapi4).toBool();
+ m_TTSOpts = RbSettings::subValue("sapi",RbSettings::TtsOptions).toString();
+ m_TTSLanguage =RbSettings::subValue("sapi",RbSettings::TtsLanguage).toString();
+ m_TTSVoice=RbSettings::subValue("sapi",RbSettings::TtsVoice).toString();
+ m_TTSSpeed=RbSettings::subValue("sapi",RbSettings::TtsSpeed).toString();
+ m_sapi4 = RbSettings::subValue("sapi",RbSettings::TtsUseSapi4).toBool();
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
@@ -283,7 +284,7 @@ QStringList TTSSapi::getVoiceList(QString language)
execstring.replace("%exe",m_TTSexec);
execstring.replace("%lang",language);
- if(settings->value(RbSettings::TtsUseSapi4).toBool())
+ if(RbSettings::value(RbSettings::TtsUseSapi4).toBool())
execstring.append(" /sapi4 ");
qDebug() << "init" << execstring;
@@ -348,7 +349,7 @@ bool TTSSapi::stop()
bool TTSSapi::configOk()
{
- if(settings->subValue("sapi",RbSettings::TtsVoice).toString().isEmpty())
+ if(RbSettings::subValue("sapi",RbSettings::TtsVoice).toString().isEmpty())
return false;
return true;
}
@@ -363,17 +364,17 @@ TTSFestival::~TTSFestival()
void TTSFestival::generateSettings()
{
// server path
- QString exepath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
+ QString exepath = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString();
if(exepath == "" ) exepath = findExecutable("festival");
insertSetting(eSERVERPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival server:",exepath,EncTtsSetting::eBROWSEBTN));
// client path
- QString clientpath = settings->subValue("festival-client",RbSettings::TtsPath).toString();
+ QString clientpath = RbSettings::subValue("festival-client",RbSettings::TtsPath).toString();
if(clientpath == "" ) clientpath = findExecutable("festival_client");
insertSetting(eCLIENTPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival client:",clientpath,EncTtsSetting::eBROWSEBTN));
// voice
- EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN);
+ EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",RbSettings::subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN);
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
connect(setting,SIGNAL(dataChanged()),this,SLOT(clearVoiceDescription()));
insertSetting(eVOICE,setting);
@@ -387,11 +388,11 @@ void TTSFestival::generateSettings()
void TTSFestival::saveSettings()
{
//save settings in user config
- settings->setSubValue("festival-server",RbSettings::TtsPath,getSetting(eSERVERPATH)->current().toString());
- settings->setSubValue("festival-client",RbSettings::TtsPath,getSetting(eCLIENTPATH)->current().toString());
- settings->setSubValue("festival",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
+ RbSettings::setSubValue("festival-server",RbSettings::TtsPath,getSetting(eSERVERPATH)->current().toString());
+ RbSettings::setSubValue("festival-client",RbSettings::TtsPath,getSetting(eCLIENTPATH)->current().toString());
+ RbSettings::setSubValue("festival",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
- settings->sync();
+ RbSettings::sync();
}
void TTSFestival::updateVoiceDescription()
@@ -420,7 +421,7 @@ void TTSFestival::startServer(QString path)
return;
if(path == "")
- path = settings->subValue("festival-server",RbSettings::TtsPath).toString();
+ path = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString();
serverProcess.start(QString("%1 --server").arg(path));
serverProcess.waitForStarted();
@@ -444,9 +445,9 @@ bool TTSFestival::start(QString* errStr)
{
(void) errStr;
ensureServerRunning();
- if (!settings->subValue("festival",RbSettings::TtsVoice).toString().isEmpty())
+ if (!RbSettings::subValue("festival",RbSettings::TtsVoice).toString().isEmpty())
queryServer(QString("(voice.select '%1)")
- .arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
+ .arg(RbSettings::subValue("festival", RbSettings::TtsVoice).toString()));
return true;
}
@@ -463,7 +464,7 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
{
qDebug() << text << "->" << wavfile;
- QString path = settings->subValue("festival-client",RbSettings::TtsPath).toString();
+ QString path = RbSettings::subValue("festival-client",RbSettings::TtsPath).toString();
QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(path).arg(wavfile);
qDebug() << cmd;
@@ -493,13 +494,13 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
bool TTSFestival::configOk()
{
- QString serverPath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
- QString clientPath = settings->subValue("festival-client",RbSettings::TtsVoice).toString();
+ QString serverPath = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString();
+ QString clientPath = RbSettings::subValue("festival-client",RbSettings::TtsVoice).toString();
bool ret = QFileInfo(serverPath).isExecutable() &&
QFileInfo(clientPath).isExecutable();
- if(settings->subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0)
- ret = ret && (voices.indexOf(settings->subValue("festival",RbSettings::TtsVoice).toString()) != -1);
+ if(RbSettings::subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0)
+ ret = ret && (voices.indexOf(RbSettings::subValue("festival",RbSettings::TtsVoice).toString()) != -1);
return ret;
}
diff --git a/rbutil/rbutilqt/base/tts.h b/rbutil/rbutilqt/base/tts.h
index 093ccd6138..f665ed2865 100644
--- a/rbutil/rbutilqt/base/tts.h
+++ b/rbutil/rbutilqt/base/tts.h
@@ -23,7 +23,6 @@
#ifndef TTS_H
#define TTS_H
-#include "rbsettings.h"
#include <QtCore>
#include <QProcess>
#include <QDateTime>
@@ -58,16 +57,12 @@ class TTSBase : public EncTtsSettingInterface
static TTSBase* getTTS(QObject* parent,QString ttsname);
static QStringList getTTSList();
static QString getTTSName(QString tts);
-
- // sets the config. Users of TTS classes, always have to call this first
- void setCfg(RbSettings* sett) { settings = sett; }
-
+
private:
//inits the tts List
static void initTTSList();
protected:
- RbSettings* settings;
static QMap<QString,QString> ttsList;
};