diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-03-03 22:26:00 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-03-03 22:26:00 +0000 |
commit | 897e041900db377493eb1ed9649c6291fc4a0630 (patch) | |
tree | 738d57cc983ff0f53a65ef09fb11cd44074e6666 /rbutil/rbutilqt/base | |
parent | be90f74e89978224a169c793d4e688867dc38b41 (diff) |
Code police.
- remove tabs.
- remove trailing spaces.
- break overly long lines.
- fix indentation errors.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25008 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r-- | rbutil/rbutilqt/base/ttsexes.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttsexes.h | 8 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttsfestival.cpp | 64 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttsfestival.h | 54 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttssapi.cpp | 41 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ttssapi.h | 22 |
6 files changed, 115 insertions, 80 deletions
diff --git a/rbutil/rbutilqt/base/ttsexes.cpp b/rbutil/rbutilqt/base/ttsexes.cpp index d116290161..05ed23b41d 100644 --- a/rbutil/rbutilqt/base/ttsexes.cpp +++ b/rbutil/rbutilqt/base/ttsexes.cpp @@ -44,8 +44,10 @@ void TTSExes::generateSettings() void TTSExes::saveSettings() { - RbSettings::setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString()); - RbSettings::setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString()); + RbSettings::setSubValue(m_name,RbSettings::TtsPath, + getSetting(eEXEPATH)->current().toString()); + RbSettings::setSubValue(m_name,RbSettings::TtsOptions, + getSetting(eOPTIONS)->current().toString()); RbSettings::sync(); } diff --git a/rbutil/rbutilqt/base/ttsexes.h b/rbutil/rbutilqt/base/ttsexes.h index ab966f5a7e..c03beb7595 100644 --- a/rbutil/rbutilqt/base/ttsexes.h +++ b/rbutil/rbutilqt/base/ttsexes.h @@ -31,15 +31,15 @@ class TTSExes : public TTSBase eEXEPATH, eOPTIONS }; - + Q_OBJECT public: TTSExes(QString name,QObject* parent=NULL); - TTSStatus voice(QString text,QString wavfile, QString *errStr); + TTSStatus voice(QString text, QString wavfile, QString *errStr); bool start(QString *errStr); bool stop() {return true;} - - // for settings + + // for settings void generateSettings(); void saveSettings(); bool configOk(); diff --git a/rbutil/rbutilqt/base/ttsfestival.cpp b/rbutil/rbutilqt/base/ttsfestival.cpp index 37d263a932..06cf0ef0cc 100644 --- a/rbutil/rbutilqt/base/ttsfestival.cpp +++ b/rbutil/rbutilqt/base/ttsfestival.cpp @@ -29,19 +29,26 @@ TTSFestival::~TTSFestival() void TTSFestival::generateSettings() { // server path - QString exepath = RbSettings::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)); + insertSetting(eSERVERPATH,new EncTtsSetting(this, + EncTtsSetting::eSTRING, "Path to Festival server:", + exepath,EncTtsSetting::eBROWSEBTN)); // client path - QString clientpath = RbSettings::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, - tr("Path to Festival client:"),clientpath,EncTtsSetting::eBROWSEBTN)); + tr("Path to Festival client:"), + clientpath,EncTtsSetting::eBROWSEBTN)); // voice - EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, - tr("Voice:"),RbSettings::subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN); + EncTtsSetting* setting = new EncTtsSetting(this, + EncTtsSetting::eSTRINGLIST, tr("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); @@ -56,9 +63,12 @@ void TTSFestival::generateSettings() void TTSFestival::saveSettings() { //save settings in user config - 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()); + 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()); RbSettings::sync(); } @@ -66,7 +76,8 @@ void TTSFestival::saveSettings() void TTSFestival::updateVoiceDescription() { // get voice Info with current voice and path - QString info = getVoiceInfo(getSetting(eVOICE)->current().toString(),getSetting(eSERVERPATH)->current().toString()); + QString info = getVoiceInfo(getSetting(eVOICE)->current().toString(), + getSetting(eSERVERPATH)->current().toString()); getSetting(eVOICEDESC)->setCurrent(info); } @@ -132,8 +143,10 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) { qDebug() << text << "->" << wavfile; - 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); + 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; QProcess clientProcess; @@ -162,13 +175,17 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) bool TTSFestival::configOk() { - QString serverPath = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString(); - QString clientPath = RbSettings::subValue("festival-client",RbSettings::TtsPath).toString(); + QString serverPath = RbSettings::subValue("festival-server", + RbSettings::TtsPath).toString(); + QString clientPath = RbSettings::subValue("festival-client", + RbSettings::TtsPath).toString(); bool ret = QFileInfo(serverPath).isExecutable() && QFileInfo(clientPath).isExecutable(); - if(RbSettings::subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0) - ret = ret && (voices.indexOf(RbSettings::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; } @@ -213,7 +230,8 @@ QString TTSFestival::getVoiceInfo(QString voice,QString path) if(voiceDescriptions.contains(voice)) return voiceDescriptions[voice]; - QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000,path); + QString response = queryServer(QString("(voice.description '%1)").arg(voice), + 3000,path); if (response == "") { @@ -221,7 +239,8 @@ QString TTSFestival::getVoiceInfo(QString voice,QString path) } else { - response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard)); + response = response.remove(QRegExp("(description \"*\")", + Qt::CaseInsensitive, QRegExp::Wildcard)); qDebug() << "voiceInfo w/o descr: " << response; response = response.remove(')'); QStringList responseLines = response.split('(', QString::SkipEmptyParts); @@ -238,8 +257,10 @@ QString TTSFestival::getVoiceInfo(QString voice,QString path) int firstSpace = line.indexOf(' '); if (firstSpace > 0) { - line = line.insert(firstSpace, ':'); // add a colon between the key and the value - line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value + // add a colon between the key and the value + line = line.insert(firstSpace, ':'); + // capitalize the value + line[firstSpace+2] = line[firstSpace+2].toUpper(); } description += line + "\n"; @@ -298,7 +319,8 @@ QString TTSFestival::queryServer(QString query, int timeout,QString path) emit busyEnd(); return ""; } - /* make sure we wait a little as we don't want to flood the server with requests */ + /* make sure we wait a little as we don't want to flood the server + * with requests */ QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500); while(QDateTime::currentDateTime() < tmpEndTime) QCoreApplication::processEvents(QEventLoop::AllEvents); diff --git a/rbutil/rbutilqt/base/ttsfestival.h b/rbutil/rbutilqt/base/ttsfestival.h index 9d644c1857..00a086af15 100644 --- a/rbutil/rbutilqt/base/ttsfestival.h +++ b/rbutil/rbutilqt/base/ttsfestival.h @@ -33,34 +33,34 @@ class TTSFestival : public TTSBase eVOICE, eVOICEDESC }; - - Q_OBJECT -public: - TTSFestival(QObject* parent=NULL) :TTSBase(parent) {} - ~TTSFestival(); - bool start(QString *errStr); - bool stop(); - TTSStatus voice(QString text,QString wavfile, QString *errStr); - // for settings - bool configOk(); - void generateSettings(); - void saveSettings(); - -private slots: - void updateVoiceList(); - void updateVoiceDescription(); - void clearVoiceDescription(); -private: - QStringList getVoiceList(QString path =""); - QString getVoiceInfo(QString voice,QString path =""); - - inline void startServer(QString path=""); - inline void ensureServerRunning(QString path=""); - QString queryServer(QString query, int timeout = -1,QString path=""); - QProcess serverProcess; - QStringList voices; - QMap<QString, QString> voiceDescriptions; + Q_OBJECT + public: + TTSFestival(QObject* parent=NULL) : TTSBase(parent) {} + ~TTSFestival(); + bool start(QString *errStr); + bool stop(); + TTSStatus voice(QString text,QString wavfile, QString *errStr); + + // for settings + bool configOk(); + void generateSettings(); + void saveSettings(); + + private slots: + void updateVoiceList(); + void updateVoiceDescription(); + void clearVoiceDescription(); + private: + QStringList getVoiceList(QString path =""); + QString getVoiceInfo(QString voice,QString path =""); + + inline void startServer(QString path=""); + inline void ensureServerRunning(QString path=""); + QString queryServer(QString query, int timeout = -1,QString path=""); + QProcess serverProcess; + QStringList voices; + QMap<QString, QString> voiceDescriptions; }; diff --git a/rbutil/rbutilqt/base/ttssapi.cpp b/rbutil/rbutilqt/base/ttssapi.cpp index b8c22f2fa7..4f69de56ae 100644 --- a/rbutil/rbutilqt/base/ttssapi.cpp +++ b/rbutil/rbutilqt/base/ttssapi.cpp @@ -24,7 +24,8 @@ TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent) { - m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\" /speed:%speed \"%options\""; + m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\"" + " /speed:%speed \"%options\""; defaultLanguage ="english"; m_sapi4 =false; } @@ -35,12 +36,15 @@ void TTSSapi::generateSettings() QStringList languages = SystemInfo::languages(); languages.sort(); EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, - tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage),languages); + tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage), + languages); connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList())); insertSetting(eLANGUAGE,setting); // voice setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, - tr("Voice:"),RbSettings::subValue("sapi",RbSettings::TtsVoice),getVoiceList(RbSettings::subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN); + tr("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 @@ -55,10 +59,14 @@ void TTSSapi::generateSettings() void TTSSapi::saveSettings() { //save settings in user config - 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()); + 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()); RbSettings::sync(); } @@ -168,10 +176,11 @@ QStringList TTSSapi::getVoiceList(QString language) } delete voicescript; - QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner - |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser - |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup - |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther ); + QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs", + QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner + | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser + | QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup + | QFile::ReadOther | QFile::WriteOther | QFile::ExeOther ); QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); return result; } @@ -198,10 +207,11 @@ bool TTSSapi::stop() voicescript->waitForFinished(); delete voicestream; delete voicescript; - QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner - |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser - |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup - |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther ); + QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs", + QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner + | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser + | QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup + | QFile::ReadOther | QFile::WriteOther | QFile::ExeOther ); QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); return true; } @@ -212,3 +222,4 @@ bool TTSSapi::configOk() return false; return true; } + diff --git a/rbutil/rbutilqt/base/ttssapi.h b/rbutil/rbutilqt/base/ttssapi.h index 5e81575585..531f25679c 100644 --- a/rbutil/rbutilqt/base/ttssapi.h +++ b/rbutil/rbutilqt/base/ttssapi.h @@ -34,30 +34,30 @@ class TTSSapi : public TTSBase eSPEED, eOPTIONS }; - - Q_OBJECT + + Q_OBJECT public: TTSSapi(QObject* parent=NULL); - + TTSStatus voice(QString text,QString wavfile, QString *errStr); bool start(QString *errStr); bool stop(); - + // for settings bool configOk(); void generateSettings(); void saveSettings(); - - private slots: - void updateVoiceList(); - - private: + + private slots: + void updateVoiceList(); + + private: QStringList getVoiceList(QString language); - + QProcess* voicescript; QTextStream* voicestream; QString defaultLanguage; - + QString m_TTSexec; QString m_TTSOpts; QString m_TTSTemplate; |