From 4105c82e6bb6cf5407256af736405ddff437c25f Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 29 Jan 2012 15:36:52 +0100 Subject: [PATCH] Centralize settings for executable based TTS systems. The configuration values for executable based TTS systems is stored in member variables. Instead of reading them multiple times provide a function for that and move searching the executable to the loading function. Previously the executable was only searched in the path when opening the TTS configuration. Having this in the loading function removes that unnecessary step in case the TTS is in the path (and doesn't require additional configuration). Change-Id: I06799b55545dcb719ee3c916795b20e01c248a15 --- rbutil/rbutilqt/base/ttsexes.cpp | 31 ++++++++++++++++++------------- rbutil/rbutilqt/base/ttsexes.h | 1 + 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/rbutil/rbutilqt/base/ttsexes.cpp b/rbutil/rbutilqt/base/ttsexes.cpp index 5e06b950bd..9e24044e5b 100644 --- a/rbutil/rbutilqt/base/ttsexes.cpp +++ b/rbutil/rbutilqt/base/ttsexes.cpp @@ -37,13 +37,11 @@ TTSBase::Capabilities TTSExes::capabilities() void TTSExes::generateSettings() { - QString exepath =RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); - if(exepath == "") exepath = Utils::findExecutable(m_name); - - insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING, - tr("Path to TTS engine:"),exepath,EncTtsSetting::eBROWSEBTN)); - insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING, - tr("TTS engine options:"),RbSettings::subValue(m_name,RbSettings::TtsOptions))); + loadSettings(); + insertSetting(eEXEPATH, new EncTtsSetting(this, EncTtsSetting::eSTRING, + tr("Path to TTS engine:"), m_TTSexec, EncTtsSetting::eBROWSEBTN)); + insertSetting(eOPTIONS, new EncTtsSetting(this, EncTtsSetting::eSTRING, + tr("TTS engine options:"), m_TTSOpts)); } void TTSExes::saveSettings() @@ -55,11 +53,18 @@ void TTSExes::saveSettings() RbSettings::sync(); } -bool TTSExes::start(QString *errStr) + +void TTSExes::loadSettings(void) { m_TTSexec = RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); + if(m_TTSexec.isEmpty()) m_TTSexec = Utils::findExecutable(m_name); m_TTSOpts = RbSettings::subValue(m_name,RbSettings::TtsOptions).toString(); +} + +bool TTSExes::start(QString *errStr) +{ + loadSettings(); m_TTSTemplate = m_TemplateMap.value(m_name); QFileInfo tts(m_TTSexec); @@ -96,10 +101,10 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr) bool TTSExes::configOk() { - QString path = RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); - - if (QFileInfo(path).exists()) + loadSettings(); + if (QFileInfo(m_TTSexec).exists()) return true; - - return false; + else + return false; } + diff --git a/rbutil/rbutilqt/base/ttsexes.h b/rbutil/rbutilqt/base/ttsexes.h index fe8e5e8b8d..6f9152ef4b 100644 --- a/rbutil/rbutilqt/base/ttsexes.h +++ b/rbutil/rbutilqt/base/ttsexes.h @@ -46,6 +46,7 @@ class TTSExes : public TTSBase bool configOk(); private: + void loadSettings(void); QString m_name; QString m_TTSexec; QString m_TTSOpts;