diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2009-04-29 21:27:01 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2009-04-29 21:27:01 +0000 |
commit | 5b85ef6006ae8e88694c62806f7f178eab4d3ba9 (patch) | |
tree | 19555e6dd782823b5329e871d6d8bea5bca7980d | |
parent | 3d2e42ab4cc6306db4036983badea0c92750210b (diff) | |
download | rockbox-5b85ef6006ae8e88694c62806f7f178eab4d3ba9.tar.gz rockbox-5b85ef6006ae8e88694c62806f7f178eab4d3ba9.zip |
rbutil: completely rework how tts and encoders are configured. (FS#10070)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20824 a1c6a512-1295-4272-9138-f99709370657
27 files changed, 1283 insertions, 2038 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 4b76c6497a..966ce335ea 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -130,6 +130,35 @@ qulonglong filesystemFree(QString path) | |||
130 | return size; | 130 | return size; |
131 | } | 131 | } |
132 | 132 | ||
133 | //! \brief searches for a Executable in the Environement Path | ||
134 | QString findExecutable(QString name) | ||
135 | { | ||
136 | QString exepath; | ||
137 | //try autodetect tts | ||
138 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD) | ||
139 | QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts); | ||
140 | #elif defined(Q_OS_WIN) | ||
141 | QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts); | ||
142 | #endif | ||
143 | qDebug() << path; | ||
144 | for(int i = 0; i < path.size(); i++) | ||
145 | { | ||
146 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + name; | ||
147 | #if defined(Q_OS_WIN) | ||
148 | executable += ".exe"; | ||
149 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); | ||
150 | executable = ex.join(""); | ||
151 | #endif | ||
152 | qDebug() << executable; | ||
153 | if(QFileInfo(executable).isExecutable()) | ||
154 | { | ||
155 | return QDir::toNativeSeparators(executable); | ||
156 | } | ||
157 | } | ||
158 | return ""; | ||
159 | } | ||
160 | |||
161 | |||
133 | RockboxInfo::RockboxInfo(QString mountpoint) | 162 | RockboxInfo::RockboxInfo(QString mountpoint) |
134 | { | 163 | { |
135 | m_path = mountpoint +"/.rockbox/rockbox-info.txt"; | 164 | m_path = mountpoint +"/.rockbox/rockbox-info.txt"; |
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h index caaf13eb41..49fca85df6 100644 --- a/rbutil/rbutilqt/base/utils.h +++ b/rbutil/rbutilqt/base/utils.h | |||
@@ -29,6 +29,7 @@ | |||
29 | bool recRmdir( const QString &dirName ); | 29 | bool recRmdir( const QString &dirName ); |
30 | QString resolvePathCase(QString path); | 30 | QString resolvePathCase(QString path); |
31 | qulonglong filesystemFree(QString path); | 31 | qulonglong filesystemFree(QString path); |
32 | QString findExecutable(QString name); | ||
32 | 33 | ||
33 | class RockboxInfo | 34 | class RockboxInfo |
34 | { | 35 | { |
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 5731dbe78a..00a899abb4 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "encoders.h" | 27 | #include "encoders.h" |
28 | #include "tts.h" | 28 | #include "tts.h" |
29 | #include "detect.h" | 29 | #include "detect.h" |
30 | #include "encttscfggui.h" | ||
30 | 31 | ||
31 | #include <stdio.h> | 32 | #include <stdio.h> |
32 | #if defined(Q_OS_WIN32) | 33 | #if defined(Q_OS_WIN32) |
@@ -356,7 +357,7 @@ void Config::setDevices() | |||
356 | void Config::updateTtsState(int index) | 357 | void Config::updateTtsState(int index) |
357 | { | 358 | { |
358 | QString ttsName = ui.comboTts->itemData(index).toString(); | 359 | QString ttsName = ui.comboTts->itemData(index).toString(); |
359 | TTSBase* tts = TTSBase::getTTS(ttsName); | 360 | TTSBase* tts = TTSBase::getTTS(this,ttsName); |
360 | tts->setCfg(settings); | 361 | tts->setCfg(settings); |
361 | 362 | ||
362 | if(tts->configOk()) | 363 | if(tts->configOk()) |
@@ -386,7 +387,7 @@ void Config::updateEncState() | |||
386 | ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString())); | 387 | ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString())); |
387 | settings->setValue(RbSettings::Platform, olddevice); | 388 | settings->setValue(RbSettings::Platform, olddevice); |
388 | 389 | ||
389 | EncBase* enc = EncBase::getEncoder(encoder); | 390 | EncBase* enc = EncBase::getEncoder(this,encoder); |
390 | enc->setCfg(settings); | 391 | enc->setCfg(settings); |
391 | 392 | ||
392 | if(enc->configOk()) | 393 | if(enc->configOk()) |
@@ -666,19 +667,36 @@ void Config::cacheClear() | |||
666 | void Config::configTts() | 667 | void Config::configTts() |
667 | { | 668 | { |
668 | int index = ui.comboTts->currentIndex(); | 669 | int index = ui.comboTts->currentIndex(); |
669 | TTSBase* tts = TTSBase::getTTS(ui.comboTts->itemData(index).toString()); | 670 | TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString()); |
670 | 671 | ||
671 | tts->setCfg(settings); | 672 | tts->setCfg(settings); |
672 | tts->showCfg(); | 673 | EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(settings->value(RbSettings::Tts).toString())); |
674 | gui.exec(); | ||
673 | updateTtsState(ui.comboTts->currentIndex()); | 675 | updateTtsState(ui.comboTts->currentIndex()); |
674 | } | 676 | } |
675 | 677 | ||
676 | 678 | ||
677 | void Config::configEnc() | 679 | void Config::configEnc() |
678 | { | 680 | { |
679 | EncBase* enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString()); | 681 | // FIXME: this is a workaround to make the encoder follow the device selection |
682 | // even with the settings (and thus the device) being saved. Needs to be redone | ||
683 | // properly later by extending the settings object | ||
684 | if(ui.treeDevices->selectedItems().size() == 0) | ||
685 | return; | ||
686 | |||
687 | QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); | ||
688 | QString olddevice = settings->value(RbSettings::CurrentPlatform).toString(); | ||
689 | settings->setValue(RbSettings::CurrentPlatform,devname); | ||
690 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); | ||
691 | ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString())); | ||
692 | settings->setValue(RbSettings::CurrentPlatform,olddevice); | ||
693 | |||
694 | |||
695 | EncBase* enc = EncBase::getEncoder(this,encoder); | ||
680 | 696 | ||
681 | enc->setCfg(settings); | 697 | enc->setCfg(settings); |
682 | enc->showCfg(); | 698 | EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder)); |
699 | gui.exec(); | ||
700 | |||
683 | updateEncState(); | 701 | updateEncState(); |
684 | } | 702 | } |
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp index 2b45386589..efd9f6a93f 100644 --- a/rbutil/rbutilqt/createvoicewindow.cpp +++ b/rbutil/rbutilqt/createvoicewindow.cpp | |||
@@ -98,7 +98,7 @@ void CreateVoiceWindow::updateSettings(void) | |||
98 | ui.comboLanguage->setCurrentIndex(sel); | 98 | ui.comboLanguage->setCurrentIndex(sel); |
99 | 99 | ||
100 | QString ttsName = settings->value(RbSettings::Tts).toString(); | 100 | QString ttsName = settings->value(RbSettings::Tts).toString(); |
101 | TTSBase* tts = TTSBase::getTTS(ttsName); | 101 | TTSBase* tts = TTSBase::getTTS(this,ttsName); |
102 | tts->setCfg(settings); | 102 | tts->setCfg(settings); |
103 | if(tts->configOk()) | 103 | if(tts->configOk()) |
104 | ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") | 104 | ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") |
@@ -109,7 +109,7 @@ void CreateVoiceWindow::updateSettings(void) | |||
109 | 109 | ||
110 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); | 110 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); |
111 | // only proceed if encoder setting is set | 111 | // only proceed if encoder setting is set |
112 | EncBase* enc = EncBase::getEncoder(encoder); | 112 | EncBase* enc = EncBase::getEncoder(this,encoder); |
113 | if(enc != NULL) { | 113 | if(enc != NULL) { |
114 | enc->setCfg(settings); | 114 | enc->setCfg(settings); |
115 | if(enc->configOk()) | 115 | if(enc->configOk()) |
diff --git a/rbutil/rbutilqt/createvoicewindow.h b/rbutil/rbutilqt/createvoicewindow.h index 9384c85abc..ab98bf985b 100644 --- a/rbutil/rbutilqt/createvoicewindow.h +++ b/rbutil/rbutilqt/createvoicewindow.h | |||
@@ -33,7 +33,7 @@ class CreateVoiceWindow : public QDialog | |||
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | CreateVoiceWindow(QWidget *parent = 0); | 36 | CreateVoiceWindow(QWidget *parent); |
37 | void setSettings(RbSettings* sett); | 37 | void setSettings(RbSettings* sett); |
38 | void setProxy(QUrl proxy){m_proxy = proxy;} | 38 | void setProxy(QUrl proxy){m_proxy = proxy;} |
39 | 39 | ||
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp index a822b932f7..6ff1185c82 100644 --- a/rbutil/rbutilqt/encoders.cpp +++ b/rbutil/rbutilqt/encoders.cpp | |||
@@ -18,18 +18,17 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "encoders.h" | 20 | #include "encoders.h" |
21 | #include "utils.h" | ||
21 | 22 | ||
22 | #ifndef CONSOLE | 23 | /********************************************************************* |
23 | #include "encodersgui.h" | 24 | * Encoder Base |
24 | #include "browsedirtree.h" | 25 | **********************************************************************/ |
25 | #else | ||
26 | #include "encodersguicli.h" | ||
27 | #endif | ||
28 | |||
29 | |||
30 | QMap<QString,QString> EncBase::encoderList; | 26 | QMap<QString,QString> EncBase::encoderList; |
31 | QMap<QString,EncBase*> EncBase::encoderCache; | ||
32 | 27 | ||
28 | EncBase::EncBase(QObject *parent): EncTtsSettingInterface(parent) | ||
29 | { | ||
30 | |||
31 | } | ||
33 | 32 | ||
34 | // initialize list of encoders | 33 | // initialize list of encoders |
35 | void EncBase::initEncodernamesList() | 34 | void EncBase::initEncodernamesList() |
@@ -49,23 +48,17 @@ QString EncBase::getEncoderName(QString encoder) | |||
49 | 48 | ||
50 | 49 | ||
51 | // get a specific encoder object | 50 | // get a specific encoder object |
52 | EncBase* EncBase::getEncoder(QString encoder) | 51 | EncBase* EncBase::getEncoder(QObject* parent,QString encoder) |
53 | { | 52 | { |
54 | // check cache | ||
55 | if(encoderCache.contains(encoder)) | ||
56 | return encoderCache.value(encoder); | ||
57 | |||
58 | EncBase* enc; | 53 | EncBase* enc; |
59 | if(encoder == "lame") | 54 | if(encoder == "lame") |
60 | { | 55 | { |
61 | enc = new EncExes(encoder); | 56 | enc = new EncExes(encoder,parent); |
62 | encoderCache[encoder] = enc; | ||
63 | return enc; | 57 | return enc; |
64 | } | 58 | } |
65 | else // rbspeex is default | 59 | else // rbspeex is default |
66 | { | 60 | { |
67 | enc = new EncRbSpeex(); | 61 | enc = new EncRbSpeex(parent); |
68 | encoderCache[encoder] = enc; | ||
69 | return enc; | 62 | return enc; |
70 | } | 63 | } |
71 | } | 64 | } |
@@ -80,14 +73,6 @@ QStringList EncBase::getEncoderList() | |||
80 | 73 | ||
81 | 74 | ||
82 | /********************************************************************* | 75 | /********************************************************************* |
83 | * Encoder Base | ||
84 | **********************************************************************/ | ||
85 | EncBase::EncBase(QObject *parent): QObject(parent) | ||
86 | { | ||
87 | |||
88 | } | ||
89 | |||
90 | /********************************************************************* | ||
91 | * GEneral Exe Encoder | 76 | * GEneral Exe Encoder |
92 | **********************************************************************/ | 77 | **********************************************************************/ |
93 | EncExes::EncExes(QString name,QObject *parent) : EncBase(parent) | 78 | EncExes::EncExes(QString name,QObject *parent) : EncBase(parent) |
@@ -95,6 +80,25 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent) | |||
95 | m_name = name; | 80 | m_name = name; |
96 | 81 | ||
97 | m_TemplateMap["lame"] = "\"%exe\" %options \"%input\" \"%output\""; | 82 | m_TemplateMap["lame"] = "\"%exe\" %options \"%input\" \"%output\""; |
83 | |||
84 | } | ||
85 | |||
86 | |||
87 | |||
88 | void EncExes::generateSettings() | ||
89 | { | ||
90 | QString exepath =settings->subValue(m_name,RbSettings::EncoderPath).toString(); | ||
91 | if(exepath == "") exepath = findExecutable(m_name); | ||
92 | |||
93 | insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Encoder:",exepath,EncTtsSetting::eBROWSEBTN)); | ||
94 | insertSetting(eEXEOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Encoder options:",settings->subValue(m_name,RbSettings::EncoderOptions))); | ||
95 | } | ||
96 | |||
97 | void EncExes::saveSettings() | ||
98 | { | ||
99 | settings->setSubValue(m_name,RbSettings::EncoderPath,getSetting(eEXEPATH)->current().toString()); | ||
100 | settings->setSubValue(m_name,RbSettings::EncoderOptions,getSetting(eEXEOPTIONS)->current().toString()); | ||
101 | settings->sync(); | ||
98 | } | 102 | } |
99 | 103 | ||
100 | bool EncExes::start() | 104 | bool EncExes::start() |
@@ -130,18 +134,6 @@ bool EncExes::encode(QString input,QString output) | |||
130 | } | 134 | } |
131 | 135 | ||
132 | 136 | ||
133 | |||
134 | void EncExes::showCfg() | ||
135 | { | ||
136 | #ifndef CONSOLE | ||
137 | EncExesGui gui; | ||
138 | #else | ||
139 | EncExesGuiCli gui; | ||
140 | #endif | ||
141 | gui.setCfg(settings); | ||
142 | gui.showCfg(m_name); | ||
143 | } | ||
144 | |||
145 | bool EncExes::configOk() | 137 | bool EncExes::configOk() |
146 | { | 138 | { |
147 | QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString(); | 139 | QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString(); |
@@ -152,20 +144,32 @@ bool EncExes::configOk() | |||
152 | return false; | 144 | return false; |
153 | } | 145 | } |
154 | 146 | ||
155 | |||
156 | |||
157 | /********************************************************************* | 147 | /********************************************************************* |
158 | * RB SPEEX ENCODER | 148 | * RB SPEEX ENCODER |
159 | **********************************************************************/ | 149 | **********************************************************************/ |
160 | EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent) | 150 | EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent) |
161 | { | 151 | { |
162 | 152 | ||
163 | defaultQuality = 8.f; | ||
164 | defaultVolume = 1.f; | ||
165 | defaultComplexity = 10; | ||
166 | defaultBand = false; | ||
167 | } | 153 | } |
168 | 154 | ||
155 | void EncRbSpeex::generateSettings() | ||
156 | { | ||
157 | insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Volume:",settings->subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0)); | ||
158 | insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Quality:",settings->subValue("rbspeex",RbSettings::EncoderQuality),0,10.0)); | ||
159 | insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,"Complexity:",settings->subValue("rbspeex",RbSettings::EncoderComplexity),0,10)); | ||
160 | insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,"Use Narrowband:",settings->subValue("rbspeex",RbSettings::EncoderNarrowBand))); | ||
161 | } | ||
162 | |||
163 | void EncRbSpeex::saveSettings() | ||
164 | { | ||
165 | //save settings in user config | ||
166 | settings->setSubValue("rbspeex",RbSettings::EncoderVolume,getSetting(eVOLUME)->current().toDouble()); | ||
167 | settings->setSubValue("rbspeex",RbSettings::EncoderQuality,getSetting(eQUALITY)->current().toDouble()); | ||
168 | settings->setSubValue("rbspeex",RbSettings::EncoderComplexity,getSetting(eCOMPLEXITY)->current().toInt()); | ||
169 | settings->setSubValue("rbspeex",RbSettings::EncoderNarrowBand,getSetting(eNARROWBAND)->current().toBool()); | ||
170 | |||
171 | settings->sync(); | ||
172 | } | ||
169 | 173 | ||
170 | bool EncRbSpeex::start() | 174 | bool EncRbSpeex::start() |
171 | { | 175 | { |
@@ -210,18 +214,6 @@ bool EncRbSpeex::encode(QString input,QString output) | |||
210 | return true; | 214 | return true; |
211 | } | 215 | } |
212 | 216 | ||
213 | |||
214 | void EncRbSpeex::showCfg() | ||
215 | { | ||
216 | #ifndef CONSOLE | ||
217 | EncRbSpeexGui gui; | ||
218 | #else | ||
219 | EncRbSpeexGuiCli gui; | ||
220 | #endif | ||
221 | gui.setCfg(settings); | ||
222 | gui.showCfg(defaultQuality,defaultVolume,defaultComplexity,defaultBand); | ||
223 | } | ||
224 | |||
225 | bool EncRbSpeex::configOk() | 217 | bool EncRbSpeex::configOk() |
226 | { | 218 | { |
227 | bool result=true; | 219 | bool result=true; |
diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h index 8a1805545f..d5d1723a46 100644 --- a/rbutil/rbutilqt/encoders.h +++ b/rbutil/rbutilqt/encoders.h | |||
@@ -25,32 +25,38 @@ | |||
25 | #include <QtCore> | 25 | #include <QtCore> |
26 | 26 | ||
27 | #include "rbsettings.h" | 27 | #include "rbsettings.h" |
28 | 28 | #include "encttssettings.h" | |
29 | #include "rbspeex.h" | 29 | #include "rbspeex.h" |
30 | 30 | ||
31 | 31 | ||
32 | class EncBase : public QObject | 32 | class EncBase : public EncTtsSettingInterface |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | EncBase(QObject *parent ); | 36 | EncBase(QObject *parent ); |
37 | 37 | ||
38 | virtual bool encode(QString input,QString output) | 38 | //! Child class should encode a wav file |
39 | {(void)input; (void)output; return false;} | 39 | virtual bool encode(QString input,QString output) =0; |
40 | virtual bool start(){return false;} | 40 | //! Child class should do startup |
41 | virtual bool stop(){return false;} | 41 | virtual bool start()=0; |
42 | virtual void showCfg(){} | 42 | //! Child class should stop |
43 | virtual bool configOk(){return false;} | 43 | virtual bool stop()=0; |
44 | 44 | ||
45 | void setCfg(RbSettings *sett){settings = sett;} | 45 | // settings |
46 | static QString getEncoderName(QString); | 46 | //! Child class should return true when configuration is ok |
47 | static EncBase* getEncoder(QString); | 47 | virtual bool configOk()=0; |
48 | //! Child class should fill in the setttingsList | ||
49 | virtual void generateSettings() = 0; | ||
50 | //! Chlid class should commit the from SettingsList to permanent storage | ||
51 | virtual void saveSettings() = 0; | ||
52 | |||
53 | // static functions | ||
54 | static QString getEncoderName(QString name); | ||
55 | static EncBase* getEncoder(QObject* parent,QString name); | ||
48 | static QStringList getEncoderList(void); | 56 | static QStringList getEncoderList(void); |
49 | 57 | ||
50 | public slots: | 58 | //set the config. users of Encoder classes, always have to call this first |
51 | virtual void accept(void){} | 59 | void setCfg(RbSettings *sett){settings = sett;} |
52 | virtual void reject(void){} | ||
53 | virtual void reset(void){} | ||
54 | private: | 60 | private: |
55 | static void initEncodernamesList(void); | 61 | static void initEncodernamesList(void); |
56 | 62 | ||
@@ -58,22 +64,29 @@ class EncBase : public QObject | |||
58 | RbSettings* settings; | 64 | RbSettings* settings; |
59 | 65 | ||
60 | static QMap<QString,QString> encoderList; | 66 | static QMap<QString,QString> encoderList; |
61 | static QMap<QString,EncBase*> encoderCache; | ||
62 | }; | 67 | }; |
63 | 68 | ||
64 | 69 | ||
65 | |||
66 | class EncExes : public EncBase | 70 | class EncExes : public EncBase |
67 | { | 71 | { |
72 | enum ESettings | ||
73 | { | ||
74 | eEXEPATH, | ||
75 | eEXEOPTIONS | ||
76 | }; | ||
77 | |||
68 | Q_OBJECT | 78 | Q_OBJECT |
69 | public: | 79 | public: |
70 | EncExes(QString name,QObject *parent = NULL); | 80 | EncExes(QString name,QObject *parent = NULL); |
71 | virtual bool encode(QString input,QString output); | 81 | bool encode(QString input,QString output); |
72 | virtual bool start(); | 82 | bool start(); |
73 | virtual bool stop() {return true;} | 83 | bool stop() {return true;} |
74 | virtual void showCfg(); | ||
75 | virtual bool configOk(); | ||
76 | 84 | ||
85 | // setting | ||
86 | bool configOk(); | ||
87 | void generateSettings(); | ||
88 | void saveSettings(); | ||
89 | |||
77 | private: | 90 | private: |
78 | QString m_name; | 91 | QString m_name; |
79 | QString m_EncExec; | 92 | QString m_EncExec; |
@@ -84,15 +97,26 @@ private: | |||
84 | 97 | ||
85 | class EncRbSpeex : public EncBase | 98 | class EncRbSpeex : public EncBase |
86 | { | 99 | { |
100 | enum ESettings | ||
101 | { | ||
102 | eVOLUME, | ||
103 | eQUALITY, | ||
104 | eCOMPLEXITY, | ||
105 | eNARROWBAND | ||
106 | }; | ||
107 | |||
87 | Q_OBJECT | 108 | Q_OBJECT |
88 | public: | 109 | public: |
89 | EncRbSpeex(QObject *parent = NULL); | 110 | EncRbSpeex(QObject *parent = NULL); |
90 | virtual bool encode(QString input,QString output); | 111 | bool encode(QString input,QString output); |
91 | virtual bool start(); | 112 | bool start(); |
92 | virtual bool stop() {return true;} | 113 | bool stop() {return true;} |
93 | virtual void showCfg(); | 114 | |
94 | virtual bool configOk(); | 115 | // for settings view |
95 | 116 | bool configOk(); | |
117 | void generateSettings(); | ||
118 | void saveSettings(); | ||
119 | |||
96 | private: | 120 | private: |
97 | float quality; | 121 | float quality; |
98 | float volume; | 122 | float volume; |
diff --git a/rbutil/rbutilqt/encodersgui.cpp b/rbutil/rbutilqt/encodersgui.cpp deleted file mode 100644 index 3d1619f807..0000000000 --- a/rbutil/rbutilqt/encodersgui.cpp +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id$ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "encodersgui.h" | ||
21 | |||
22 | #include "rbsettings.h" | ||
23 | #include "browsedirtree.h" | ||
24 | |||
25 | EncExesGui::EncExesGui(QDialog* parent) : QDialog(parent) | ||
26 | { | ||
27 | ui.setupUi(this); | ||
28 | this->hide(); | ||
29 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); | ||
30 | connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse())); | ||
31 | } | ||
32 | |||
33 | void EncExesGui::showCfg(QString name) | ||
34 | { | ||
35 | m_name = name; | ||
36 | // try to get config from settings | ||
37 | QString exepath =settings->subValue(m_name, RbSettings::EncoderPath).toString(); | ||
38 | ui.encoderoptions->setText(settings->subValue(m_name, RbSettings::EncoderOptions).toString()); | ||
39 | |||
40 | if(exepath == "") | ||
41 | { | ||
42 | |||
43 | // try to autodetect encoder | ||
44 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD) | ||
45 | QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts); | ||
46 | #elif defined(Q_OS_WIN) | ||
47 | QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts); | ||
48 | #endif | ||
49 | qDebug() << path; | ||
50 | |||
51 | for(int i = 0; i < path.size(); i++) | ||
52 | { | ||
53 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name; | ||
54 | #if defined(Q_OS_WIN) | ||
55 | executable += ".exe"; | ||
56 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); | ||
57 | executable = ex.join(""); | ||
58 | #endif | ||
59 | if(QFileInfo(executable).isExecutable()) | ||
60 | { | ||
61 | qDebug() << "found:" << executable; | ||
62 | exepath = QDir::toNativeSeparators(executable); | ||
63 | break; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | ui.encoderpath->setText(exepath); | ||
69 | |||
70 | //show dialog | ||
71 | this->exec(); | ||
72 | |||
73 | } | ||
74 | |||
75 | void EncExesGui::accept(void) | ||
76 | { | ||
77 | //save settings in user config | ||
78 | settings->setSubValue(m_name, RbSettings::EncoderPath, ui.encoderpath->text()); | ||
79 | settings->setSubValue(m_name, RbSettings::EncoderOptions, ui.encoderoptions->text()); | ||
80 | |||
81 | // sync settings | ||
82 | settings->sync(); | ||
83 | this->done(0); | ||
84 | } | ||
85 | |||
86 | void EncExesGui::reject(void) | ||
87 | { | ||
88 | this->done(0); | ||
89 | } | ||
90 | |||
91 | void EncExesGui::reset() | ||
92 | { | ||
93 | ui.encoderpath->setText(""); | ||
94 | ui.encoderoptions->setText(""); | ||
95 | } | ||
96 | |||
97 | void EncExesGui::browse() | ||
98 | { | ||
99 | BrowseDirtree browser(this); | ||
100 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | ||
101 | |||
102 | if(QFileInfo(ui.encoderpath->text()).isDir()) | ||
103 | { | ||
104 | browser.setDir(ui.encoderpath->text()); | ||
105 | } | ||
106 | if(browser.exec() == QDialog::Accepted) | ||
107 | { | ||
108 | qDebug() << browser.getSelected(); | ||
109 | QString exe = browser.getSelected(); | ||
110 | if(!QFileInfo(exe).isExecutable()) | ||
111 | return; | ||
112 | ui.encoderpath->setText(exe); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | EncRbSpeexGui::EncRbSpeexGui(QDialog* parent) : QDialog(parent) | ||
118 | { | ||
119 | ui.setupUi(this); | ||
120 | this->hide(); | ||
121 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); | ||
122 | |||
123 | } | ||
124 | |||
125 | void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB) | ||
126 | { | ||
127 | defaultQuality =defQ; | ||
128 | defaultVolume = defV; | ||
129 | defaultComplexity = defC; | ||
130 | defaultBand =defB; | ||
131 | |||
132 | //fill in the usersettings | ||
133 | ui.volume->setValue(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble()); | ||
134 | ui.quality->setValue(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble()); | ||
135 | ui.complexity->setValue(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt()); | ||
136 | |||
137 | if(settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool()) | ||
138 | ui.narrowband->setCheckState(Qt::Checked); | ||
139 | else | ||
140 | ui.narrowband->setCheckState(Qt::Unchecked); | ||
141 | |||
142 | //show dialog | ||
143 | this->exec(); | ||
144 | } | ||
145 | |||
146 | void EncRbSpeexGui::accept(void) | ||
147 | { | ||
148 | //save settings in user config | ||
149 | settings->setSubValue("rbspeex", RbSettings::EncoderVolume, ui.volume->value()); | ||
150 | settings->setSubValue("rbspeex", RbSettings::EncoderQuality, ui.quality->value()); | ||
151 | settings->setSubValue("rbspeex", RbSettings::EncoderComplexity, ui.complexity->value()); | ||
152 | settings->setSubValue("rbspeex", RbSettings::EncoderNarrowBand, ui.narrowband->isChecked() ? true : false); | ||
153 | |||
154 | // sync settings | ||
155 | settings->sync(); | ||
156 | this->done(0); | ||
157 | } | ||
158 | |||
159 | void EncRbSpeexGui::reject(void) | ||
160 | { | ||
161 | this->done(0); | ||
162 | } | ||
163 | |||
164 | void EncRbSpeexGui::reset() | ||
165 | { | ||
166 | ui.volume->setValue(defaultVolume); | ||
167 | ui.quality->setValue(defaultQuality); | ||
168 | ui.complexity->setValue(defaultComplexity); | ||
169 | ui.narrowband->setChecked(Qt::Unchecked); | ||
170 | } | ||
171 | |||
diff --git a/rbutil/rbutilqt/encodersgui.h b/rbutil/rbutilqt/encodersgui.h deleted file mode 100644 index 0c53549f80..0000000000 --- a/rbutil/rbutilqt/encodersgui.h +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef ENCODERSGUI_H | ||
23 | #define ENCODERSGUI_H | ||
24 | |||
25 | #include <QtGui> | ||
26 | |||
27 | class RbSettings; | ||
28 | |||
29 | #include "ui_rbspeexcfgfrm.h" | ||
30 | #include "ui_encexescfgfrm.h" | ||
31 | |||
32 | |||
33 | class EncExesGui : public QDialog | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | public: | ||
37 | EncExesGui(QDialog* parent = NULL); | ||
38 | |||
39 | void showCfg(QString m_name); | ||
40 | void setCfg(RbSettings* sett){settings = sett;} | ||
41 | |||
42 | public slots: | ||
43 | virtual void accept(void); | ||
44 | virtual void reject(void); | ||
45 | virtual void reset(void); | ||
46 | void browse(void); | ||
47 | |||
48 | private: | ||
49 | Ui::EncExesCfgFrm ui; | ||
50 | RbSettings* settings; | ||
51 | QString m_name; | ||
52 | }; | ||
53 | |||
54 | class EncRbSpeexGui : public QDialog | ||
55 | { | ||
56 | Q_OBJECT | ||
57 | public: | ||
58 | EncRbSpeexGui(QDialog* parent = NULL); | ||
59 | |||
60 | void showCfg(float defQ,float defV,int defC, bool defB); | ||
61 | void setCfg(RbSettings* sett){settings = sett;} | ||
62 | |||
63 | public slots: | ||
64 | virtual void accept(void); | ||
65 | virtual void reject(void); | ||
66 | virtual void reset(void); | ||
67 | |||
68 | private: | ||
69 | Ui::RbSpeexCfgFrm ui; | ||
70 | RbSettings* settings; | ||
71 | float defaultQuality; | ||
72 | float defaultVolume; | ||
73 | int defaultComplexity; | ||
74 | bool defaultBand; | ||
75 | }; | ||
76 | |||
77 | |||
78 | |||
79 | #endif | ||
diff --git a/rbutil/rbutilqt/encttscfggui.cpp b/rbutil/rbutilqt/encttscfggui.cpp new file mode 100644 index 0000000000..25089873fc --- /dev/null +++ b/rbutil/rbutilqt/encttscfggui.cpp | |||
@@ -0,0 +1,361 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "encttscfggui.h" | ||
23 | #include "browsedirtree.h" | ||
24 | |||
25 | EncTtsCfgGui::EncTtsCfgGui(QDialog* parent,EncTtsSettingInterface* interface,QString name) : QDialog(parent) | ||
26 | { | ||
27 | m_settingInterface = interface; | ||
28 | |||
29 | m_busyCnt=0; | ||
30 | // create a busy Dialog | ||
31 | m_busyDlg= new QProgressDialog(tr(""), tr(""), 0, 0,this); | ||
32 | m_busyDlg->setWindowTitle(tr("Waiting for engine...")); | ||
33 | m_busyDlg->setModal(true); | ||
34 | m_busyDlg->setLabel(0); | ||
35 | m_busyDlg->setCancelButton(0); | ||
36 | m_busyDlg->hide(); | ||
37 | connect(interface,SIGNAL(busy()),this,SLOT(showBusy())); | ||
38 | connect(interface,SIGNAL(busyEnd()),this,SLOT(hideBusy())); | ||
39 | |||
40 | //setup the window | ||
41 | setWindowTitle(name); | ||
42 | setUpWindow(); | ||
43 | } | ||
44 | |||
45 | void EncTtsCfgGui::setUpWindow() | ||
46 | { | ||
47 | m_settingsList = m_settingInterface->getSettings(); | ||
48 | |||
49 | //layout | ||
50 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
51 | |||
52 | // groupbox | ||
53 | QGroupBox *groupBox = new QGroupBox(this); | ||
54 | QFormLayout *formlayout = new QFormLayout; | ||
55 | // setting widgets | ||
56 | for(int i = 0; i < m_settingsList.size(); i++) | ||
57 | { | ||
58 | formlayout->addRow(m_settingsList.at(i)->name(),createWidgets(m_settingsList.at(i))); | ||
59 | } | ||
60 | groupBox->setLayout(formlayout); | ||
61 | mainLayout->addWidget(groupBox); | ||
62 | |||
63 | // connect browse btn | ||
64 | connect(&m_browseBtnMap,SIGNAL(mapped(QObject*)),this,SLOT(browse(QObject*))); | ||
65 | |||
66 | // ok - cancel buttons | ||
67 | QPushButton* okBtn = new QPushButton(tr("Ok"),this); | ||
68 | okBtn->setDefault(true); | ||
69 | okBtn->setIcon(QIcon(":icons/go-next.png")); | ||
70 | QPushButton* cancelBtn = new QPushButton(tr("Cancel"),this); | ||
71 | cancelBtn->setIcon(QIcon(":icons/process-stop.png")); | ||
72 | connect(okBtn,SIGNAL(clicked()),this,SLOT(accept())); | ||
73 | connect(cancelBtn,SIGNAL(clicked()),this,SLOT(reject())); | ||
74 | |||
75 | QHBoxLayout *btnbox = new QHBoxLayout; | ||
76 | btnbox->addWidget(okBtn); | ||
77 | btnbox->addWidget(cancelBtn); | ||
78 | btnbox->insertStretch(0,1); | ||
79 | |||
80 | mainLayout->addLayout(btnbox); | ||
81 | |||
82 | this->setLayout(mainLayout); | ||
83 | } | ||
84 | |||
85 | QLayout* EncTtsCfgGui::createWidgets(EncTtsSetting* setting) | ||
86 | { | ||
87 | // value display | ||
88 | QWidget* value = NULL; | ||
89 | switch(setting->type()) | ||
90 | { | ||
91 | case EncTtsSetting::eDOUBLE: | ||
92 | { | ||
93 | QDoubleSpinBox *spinBox = new QDoubleSpinBox(this); | ||
94 | spinBox->setMinimum(setting->min().toDouble()); | ||
95 | spinBox->setMaximum(setting->max().toDouble()); | ||
96 | spinBox->setSingleStep(0.01); | ||
97 | spinBox->setValue(setting->current().toDouble()); | ||
98 | connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting())); | ||
99 | value = spinBox; | ||
100 | break; | ||
101 | } | ||
102 | case EncTtsSetting::eINT: | ||
103 | { | ||
104 | QSpinBox *spinBox = new QSpinBox(this); | ||
105 | spinBox->setMinimum(setting->min().toInt()); | ||
106 | spinBox->setMaximum(setting->max().toInt()); | ||
107 | spinBox->setValue(setting->current().toInt()); | ||
108 | connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting())); | ||
109 | value = spinBox; | ||
110 | break; | ||
111 | } | ||
112 | case EncTtsSetting::eSTRING: | ||
113 | { | ||
114 | QLineEdit *lineEdit = new QLineEdit(this); | ||
115 | lineEdit->setText(setting->current().toString()); | ||
116 | connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting())); | ||
117 | value = lineEdit; | ||
118 | break; | ||
119 | } | ||
120 | case EncTtsSetting::eREADONLYSTRING: | ||
121 | { | ||
122 | value = new QLabel(setting->current().toString(),this); | ||
123 | break; | ||
124 | } | ||
125 | case EncTtsSetting::eSTRINGLIST: | ||
126 | { | ||
127 | QComboBox *comboBox = new QComboBox(this); | ||
128 | comboBox->addItems(setting->list()); | ||
129 | int index = comboBox->findText(setting->current().toString()); | ||
130 | comboBox->setCurrentIndex(index); | ||
131 | connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting())); | ||
132 | value = comboBox; | ||
133 | break; | ||
134 | } | ||
135 | case EncTtsSetting::eBOOL: | ||
136 | { | ||
137 | QCheckBox *checkbox = new QCheckBox(this); | ||
138 | checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked); | ||
139 | connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting())); | ||
140 | value = checkbox; | ||
141 | break; | ||
142 | } | ||
143 | default: | ||
144 | { | ||
145 | qDebug() << "Warning: unknown EncTTsSetting type" << setting->type(); | ||
146 | break; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | // remeber widget | ||
151 | if(value != NULL) | ||
152 | { | ||
153 | m_settingsWidgetsMap.insert(setting,value); | ||
154 | connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget())); | ||
155 | } | ||
156 | |||
157 | // buttons ? | ||
158 | QWidget* btn = createButton(setting); | ||
159 | |||
160 | // add to layout | ||
161 | QHBoxLayout *hbox = new QHBoxLayout; | ||
162 | if(value != NULL)hbox->addWidget(value); | ||
163 | if(btn != NULL) hbox->addWidget(btn); | ||
164 | |||
165 | return hbox; | ||
166 | |||
167 | } | ||
168 | |||
169 | QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting) | ||
170 | { | ||
171 | if(setting->button() == EncTtsSetting::eBROWSEBTN) | ||
172 | { | ||
173 | QPushButton* browsebtn = new QPushButton(tr("Browse"),this); | ||
174 | browsebtn->setFixedWidth(50); //all buttons the same size, or it looks ugly | ||
175 | m_browseBtnMap.setMapping(browsebtn,setting); | ||
176 | connect(browsebtn,SIGNAL(clicked()),&m_browseBtnMap,SLOT(map())); | ||
177 | return browsebtn; | ||
178 | } | ||
179 | else if(setting->button() == EncTtsSetting::eREFRESHBTN) | ||
180 | { | ||
181 | QPushButton* refreshbtn = new QPushButton(tr("Refresh"),this); | ||
182 | refreshbtn->setFixedWidth(50); //all buttons the same size, or it looks ugly | ||
183 | connect(refreshbtn,SIGNAL(clicked()),setting,SIGNAL(refresh())); | ||
184 | return refreshbtn; | ||
185 | } | ||
186 | else | ||
187 | return NULL; | ||
188 | } | ||
189 | |||
190 | void EncTtsCfgGui::updateSetting() | ||
191 | { | ||
192 | //cast and get the sender widget | ||
193 | QWidget* widget = qobject_cast<QWidget*>(QObject::sender()); | ||
194 | if(widget == NULL) return; | ||
195 | // get the corresponding setting | ||
196 | EncTtsSetting* setting = m_settingsWidgetsMap.key(widget); | ||
197 | |||
198 | // update widget based on setting type | ||
199 | switch(setting->type()) | ||
200 | { | ||
201 | case EncTtsSetting::eDOUBLE: | ||
202 | { | ||
203 | setting->setCurrent(((QDoubleSpinBox*)widget)->value(),false); | ||
204 | break; | ||
205 | } | ||
206 | case EncTtsSetting::eINT: | ||
207 | { | ||
208 | setting->setCurrent(((QSpinBox*)widget)->value(),false); | ||
209 | break; | ||
210 | } | ||
211 | case EncTtsSetting::eSTRING: | ||
212 | { | ||
213 | setting->setCurrent(((QLineEdit*)widget)->text(),false); | ||
214 | break; | ||
215 | } | ||
216 | case EncTtsSetting::eREADONLYSTRING: | ||
217 | { | ||
218 | setting->setCurrent(((QLabel*)widget)->text(),false); | ||
219 | break; | ||
220 | } | ||
221 | case EncTtsSetting::eSTRINGLIST: | ||
222 | { | ||
223 | setting->setCurrent(((QComboBox*)widget)->currentText(),false); | ||
224 | break; | ||
225 | } | ||
226 | case EncTtsSetting::eBOOL: | ||
227 | { | ||
228 | setting->setCurrent(((QCheckBox*)widget)->isChecked(),false); | ||
229 | } | ||
230 | default: | ||
231 | { | ||
232 | qDebug() << "unknown Settingtype !!"; | ||
233 | break; | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
238 | void EncTtsCfgGui::updateWidget() | ||
239 | { | ||
240 | // get sender setting | ||
241 | EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender()); | ||
242 | if(setting == NULL) return; | ||
243 | // get corresponding widget | ||
244 | QWidget* widget = m_settingsWidgetsMap.value(setting); | ||
245 | |||
246 | // update Widget based on setting type | ||
247 | switch(setting->type()) | ||
248 | { | ||
249 | case EncTtsSetting::eDOUBLE: | ||
250 | { | ||
251 | QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget; | ||
252 | spinbox->setMinimum(setting->min().toDouble()); | ||
253 | spinbox->setMaximum(setting->max().toDouble()); | ||
254 | spinbox->blockSignals(true); | ||
255 | spinbox->setValue(setting->current().toDouble()); | ||
256 | spinbox->blockSignals(false); | ||
257 | break; | ||
258 | } | ||
259 | case EncTtsSetting::eINT: | ||
260 | { | ||
261 | QSpinBox* spinbox = (QSpinBox*) widget; | ||
262 | spinbox->setMinimum(setting->min().toInt()); | ||
263 | spinbox->setMaximum(setting->max().toInt()); | ||
264 | spinbox->blockSignals(true); | ||
265 | spinbox->setValue(setting->current().toInt()); | ||
266 | spinbox->blockSignals(false); | ||
267 | break; | ||
268 | } | ||
269 | case EncTtsSetting::eSTRING: | ||
270 | { | ||
271 | QLineEdit* lineedit = (QLineEdit*) widget; | ||
272 | |||
273 | lineedit->blockSignals(true); | ||
274 | lineedit->setText(setting->current().toString()); | ||
275 | lineedit->blockSignals(false); | ||
276 | break; | ||
277 | } | ||
278 | case EncTtsSetting::eREADONLYSTRING: | ||
279 | { | ||
280 | QLabel* label = (QLabel*) widget; | ||
281 | |||
282 | label->blockSignals(true); | ||
283 | label->setText(setting->current().toString()); | ||
284 | label->blockSignals(false); | ||
285 | break; | ||
286 | } | ||
287 | case EncTtsSetting::eSTRINGLIST: | ||
288 | { | ||
289 | QComboBox* combobox = (QComboBox*) widget; | ||
290 | |||
291 | combobox->blockSignals(true); | ||
292 | combobox->clear(); | ||
293 | combobox->addItems(setting->list()); | ||
294 | int index = combobox->findText(setting->current().toString()); | ||
295 | combobox->setCurrentIndex(index); | ||
296 | combobox->blockSignals(false); | ||
297 | |||
298 | break; | ||
299 | } | ||
300 | case EncTtsSetting::eBOOL: | ||
301 | { | ||
302 | QCheckBox* checkbox = (QCheckBox*) widget; | ||
303 | |||
304 | checkbox->blockSignals(true); | ||
305 | checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked); | ||
306 | checkbox->blockSignals(false); | ||
307 | break; | ||
308 | } | ||
309 | default: | ||
310 | { | ||
311 | qDebug() << "unknown EncTTsSetting"; | ||
312 | break; | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | |||
317 | void EncTtsCfgGui::showBusy() | ||
318 | { | ||
319 | if(m_busyCnt == 0) m_busyDlg->show(); | ||
320 | |||
321 | m_busyCnt++; | ||
322 | } | ||
323 | |||
324 | void EncTtsCfgGui::hideBusy() | ||
325 | { | ||
326 | m_busyCnt--; | ||
327 | |||
328 | if(m_busyCnt == 0) m_busyDlg->hide(); | ||
329 | } | ||
330 | |||
331 | |||
332 | void EncTtsCfgGui::accept(void) | ||
333 | { | ||
334 | m_settingInterface->saveSettings(); | ||
335 | this->done(0); | ||
336 | } | ||
337 | |||
338 | void EncTtsCfgGui::reject(void) | ||
339 | { | ||
340 | this->done(0); | ||
341 | } | ||
342 | |||
343 | //! takes a QObject because of QsignalMapper | ||
344 | void EncTtsCfgGui::browse(QObject* settingObj) | ||
345 | { | ||
346 | // cast top setting | ||
347 | EncTtsSetting* setting= qobject_cast<EncTtsSetting*>(settingObj); | ||
348 | if(setting == NULL) return; | ||
349 | |||
350 | //current path | ||
351 | QString curPath = setting->current().toString(); | ||
352 | // show file dialog | ||
353 | QString exe = QFileDialog::getOpenFileName(this, tr("Select excutable"), curPath, "*"); | ||
354 | if(!QFileInfo(exe).isExecutable()) | ||
355 | return; | ||
356 | // set new value, gui will update automatically | ||
357 | setting->setCurrent(exe); | ||
358 | } | ||
359 | |||
360 | |||
361 | |||
diff --git a/rbutil/rbutilqt/encttscfggui.h b/rbutil/rbutilqt/encttscfggui.h new file mode 100644 index 0000000000..45b151ce23 --- /dev/null +++ b/rbutil/rbutilqt/encttscfggui.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef ENCTTSCFGGUI_H | ||
23 | #define ENCTTSCFGGUI_H | ||
24 | |||
25 | #include <QtGui> | ||
26 | #include "encttssettings.h" | ||
27 | |||
28 | //! \brief Shows and manages a configuration gui for encoders and tts enignes | ||
29 | //! | ||
30 | class EncTtsCfgGui: public QDialog | ||
31 | { | ||
32 | Q_OBJECT | ||
33 | public: | ||
34 | //! Creates the UI. give it a endoer or tts engine with already set config. uses show() or exec() to show it. | ||
35 | EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* interface,QString name); | ||
36 | |||
37 | private slots: | ||
38 | //! accept current configuration values and close window | ||
39 | void accept(void); | ||
40 | //! close window and dont save configuration | ||
41 | void reject(void); | ||
42 | //! updates the corresponding setting from the sending Widget | ||
43 | void updateSetting(); | ||
44 | //! updates corresponding Widget from the sending Setting. | ||
45 | void updateWidget(); | ||
46 | //! shows a busy dialog. counts calls. | ||
47 | void showBusy(); | ||
48 | //! hides the busy dialog, counts calls | ||
49 | void hideBusy(); | ||
50 | //! used via the SignalMapper for all Browse buttons | ||
51 | void browse(QObject*); | ||
52 | |||
53 | private: | ||
54 | //! creates all dynamic window content | ||
55 | void setUpWindow(); | ||
56 | //! creates the Widgets needed for one setting. returns a Layout with the widgets | ||
57 | QLayout* createWidgets(EncTtsSetting* setting); | ||
58 | //! creates a button when needed by the setting. | ||
59 | QWidget* createButton(EncTtsSetting* setting); | ||
60 | //! name of the Encoder or TTS for which this UI is | ||
61 | QString m_name; | ||
62 | //! the interface pointer to the TTS or encoder | ||
63 | EncTtsSettingInterface* m_settingInterface; | ||
64 | //! Dialog, shown when enc or tts is busy | ||
65 | QProgressDialog* m_busyDlg; | ||
66 | //! List of settings from the TTS or Encoder | ||
67 | QList<EncTtsSetting*> m_settingsList; | ||
68 | //! Maps settings and the correspondig Widget | ||
69 | QMap<EncTtsSetting*,QWidget*> m_settingsWidgetsMap; | ||
70 | //! Maps all browse buttons to the corresponding Setting | ||
71 | QSignalMapper m_browseBtnMap; | ||
72 | //! counter how often busyShow() is called, | ||
73 | int m_busyCnt; | ||
74 | }; | ||
75 | |||
76 | |||
77 | #endif | ||
78 | |||
diff --git a/rbutil/rbutilqt/encttssettings.cpp b/rbutil/rbutilqt/encttssettings.cpp new file mode 100644 index 0000000000..fa7cfb39c2 --- /dev/null +++ b/rbutil/rbutilqt/encttssettings.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "encttssettings.h" | ||
23 | |||
24 | |||
25 | EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current, EButton btn) | ||
26 | { | ||
27 | m_btn = btn; | ||
28 | m_name =name; | ||
29 | m_type =type; | ||
30 | m_currentValue = current; | ||
31 | } | ||
32 | |||
33 | EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn) | ||
34 | { | ||
35 | m_btn = btn; | ||
36 | m_name =name; | ||
37 | m_type =type; | ||
38 | m_currentValue = current; | ||
39 | m_list = list; | ||
40 | } | ||
41 | |||
42 | EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max, EButton btn) | ||
43 | { | ||
44 | m_btn = btn; | ||
45 | m_name =name; | ||
46 | m_type =type; | ||
47 | m_currentValue = current; | ||
48 | m_minValue = min; | ||
49 | m_maxValue = max; | ||
50 | } | ||
51 | |||
52 | void EncTtsSetting::setCurrent(QVariant current,bool noticeGui) | ||
53 | { | ||
54 | m_currentValue = current; | ||
55 | emit dataChanged(); | ||
56 | |||
57 | if(noticeGui) emit updateGui(); | ||
58 | } | ||
59 | |||
60 | //! insert a setting | ||
61 | void EncTtsSettingInterface::insertSetting(int id,EncTtsSetting* setting) | ||
62 | { | ||
63 | settingsList.insert(id,setting); | ||
64 | } | ||
65 | |||
66 | //! retrieve a specific setting | ||
67 | EncTtsSetting* EncTtsSettingInterface::getSetting(int id) | ||
68 | { | ||
69 | return settingsList.at(id); | ||
70 | } | ||
diff --git a/rbutil/rbutilqt/encttssettings.h b/rbutil/rbutilqt/encttssettings.h new file mode 100644 index 0000000000..843829a815 --- /dev/null +++ b/rbutil/rbutilqt/encttssettings.h | |||
@@ -0,0 +1,129 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef ENCTTSSETTINGS_H | ||
23 | #define ENCTTSSETTINGS_H | ||
24 | |||
25 | #include <QtCore> | ||
26 | |||
27 | //! \brief This class stores everything needed to display a Setting. | ||
28 | //! | ||
29 | class EncTtsSetting : public QObject | ||
30 | { | ||
31 | Q_OBJECT | ||
32 | public: | ||
33 | enum ESettingType | ||
34 | { | ||
35 | eBASE, | ||
36 | eBOOL, | ||
37 | eDOUBLE, | ||
38 | eINT, | ||
39 | eSTRING, | ||
40 | eREADONLYSTRING, | ||
41 | eSTRINGLIST, | ||
42 | }; | ||
43 | enum EButton | ||
44 | { | ||
45 | eNOBTN, | ||
46 | eBROWSEBTN, | ||
47 | eREFRESHBTN | ||
48 | }; | ||
49 | |||
50 | //! constructor for a String or Bool setting | ||
51 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN); | ||
52 | //! contructor for a Stringlist setting, ie a enumeration | ||
53 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN); | ||
54 | //! constructor for a setting with a min-max range | ||
55 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN); | ||
56 | |||
57 | //! get currentValue | ||
58 | QVariant current() {return m_currentValue;} | ||
59 | //! set currentValue | ||
60 | void setCurrent(QVariant current,bool noticeGui=true); | ||
61 | |||
62 | //! get name of the Setting | ||
63 | QString name() {return m_name;} | ||
64 | //! get the type of the setting | ||
65 | ESettingType type() {return m_type;} | ||
66 | //! get what type of button this setting needs | ||
67 | EButton button() {return m_btn;} | ||
68 | //! get the minValue (only valid for a range setting, ie eDOUBLE or eINT) | ||
69 | QVariant min() {return m_minValue; } | ||
70 | //! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT) | ||
71 | QVariant max() {return m_maxValue; } | ||
72 | //! get the enumerationlist (only valid for eSTRINGLIST settings) | ||
73 | QStringList list() {return m_list;} | ||
74 | //! set the enumeration list | ||
75 | void setList(QStringList list){m_list = list;} | ||
76 | |||
77 | signals: | ||
78 | //! connect to this signal if you want to get noticed when the data changes | ||
79 | void dataChanged(); | ||
80 | //! connect to this if you want to react on refresh button | ||
81 | void refresh(); | ||
82 | //! will be emited when the gui should update this setting | ||
83 | void updateGui(); | ||
84 | |||
85 | private: | ||
86 | ESettingType m_type; | ||
87 | EButton m_btn; | ||
88 | QString m_name; | ||
89 | QVariant m_currentValue; | ||
90 | QVariant m_minValue; | ||
91 | QVariant m_maxValue; | ||
92 | QStringList m_list; | ||
93 | }; | ||
94 | |||
95 | |||
96 | //! \brief this class is the Interface for Encoder and TTS engines, to display settings | ||
97 | //! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented | ||
98 | //! | ||
99 | class EncTtsSettingInterface : public QObject | ||
100 | { | ||
101 | Q_OBJECT | ||
102 | public: | ||
103 | EncTtsSettingInterface(QObject* parent) : QObject(parent) {} | ||
104 | |||
105 | //! get the Settings list | ||
106 | QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;} | ||
107 | |||
108 | //! Chlid class should commit the from SettingsList to permanent storage | ||
109 | virtual void saveSettings() = 0; | ||
110 | |||
111 | signals: | ||
112 | void busy(); // emit this if a operation takes time | ||
113 | void busyEnd(); // emit this at the end of a busy section | ||
114 | |||
115 | protected: | ||
116 | //! Child class should fill in the setttingsList | ||
117 | virtual void generateSettings() = 0; | ||
118 | |||
119 | //! insert a setting | ||
120 | void insertSetting(int id,EncTtsSetting* setting); | ||
121 | //! retrieve a specific setting | ||
122 | EncTtsSetting* getSetting(int id); | ||
123 | |||
124 | private: | ||
125 | //! The setting storage. | ||
126 | QList<EncTtsSetting*> settingsList; | ||
127 | |||
128 | }; | ||
129 | #endif | ||
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp index 4caaa4fbc7..041b8f2885 100644 --- a/rbutil/rbutilqt/installtalkwindow.cpp +++ b/rbutil/rbutilqt/installtalkwindow.cpp | |||
@@ -116,7 +116,7 @@ void InstallTalkWindow::setSettings(RbSettings* sett) | |||
116 | void InstallTalkWindow::updateSettings(void) | 116 | void InstallTalkWindow::updateSettings(void) |
117 | { | 117 | { |
118 | QString ttsName = settings->value(RbSettings::Tts).toString(); | 118 | QString ttsName = settings->value(RbSettings::Tts).toString(); |
119 | TTSBase* tts = TTSBase::getTTS(ttsName); | 119 | TTSBase* tts = TTSBase::getTTS(this,ttsName); |
120 | tts->setCfg(settings); | 120 | tts->setCfg(settings); |
121 | if(tts->configOk()) | 121 | if(tts->configOk()) |
122 | ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") | 122 | ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>") |
@@ -126,7 +126,7 @@ void InstallTalkWindow::updateSettings(void) | |||
126 | .arg("Invalid TTS configuration!")); | 126 | .arg("Invalid TTS configuration!")); |
127 | 127 | ||
128 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); | 128 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); |
129 | EncBase* enc = EncBase::getEncoder(encoder); | 129 | EncBase* enc = EncBase::getEncoder(this,encoder); |
130 | if(enc != NULL) { | 130 | if(enc != NULL) { |
131 | enc->setCfg(settings); | 131 | enc->setCfg(settings); |
132 | if(enc->configOk()) | 132 | if(enc->configOk()) |
diff --git a/rbutil/rbutilqt/rbspeexcfgfrm.ui b/rbutil/rbutilqt/rbspeexcfgfrm.ui deleted file mode 100644 index 0134817fec..0000000000 --- a/rbutil/rbutilqt/rbspeexcfgfrm.ui +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>RbSpeexCfgFrm</class> | ||
3 | <widget class="QDialog" name="RbSpeexCfgFrm" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>408</width> | ||
9 | <height>173</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Configuration</string> | ||
14 | </property> | ||
15 | <layout class="QGridLayout" > | ||
16 | <item row="0" column="0" colspan="4" > | ||
17 | <widget class="QGroupBox" name="groupBox" > | ||
18 | <property name="title" > | ||
19 | <string>Configure RbSpeex Encoder</string> | ||
20 | </property> | ||
21 | <layout class="QGridLayout" > | ||
22 | <item row="0" column="0" > | ||
23 | <widget class="QDoubleSpinBox" name="volume" > | ||
24 | <property name="maximum" > | ||
25 | <double>10.000000000000000</double> | ||
26 | </property> | ||
27 | <property name="singleStep" > | ||
28 | <double>0.010000000000000</double> | ||
29 | </property> | ||
30 | <property name="value" > | ||
31 | <double>1.000000000000000</double> | ||
32 | </property> | ||
33 | </widget> | ||
34 | </item> | ||
35 | <item row="0" column="1" > | ||
36 | <widget class="QLabel" name="label_2" > | ||
37 | <property name="text" > | ||
38 | <string>Volume</string> | ||
39 | </property> | ||
40 | </widget> | ||
41 | </item> | ||
42 | <item row="0" column="2" > | ||
43 | <widget class="QCheckBox" name="narrowband" > | ||
44 | <property name="text" > | ||
45 | <string>Narrowband</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | </item> | ||
49 | <item row="1" column="0" > | ||
50 | <widget class="QDoubleSpinBox" name="quality" > | ||
51 | <property name="decimals" > | ||
52 | <number>1</number> | ||
53 | </property> | ||
54 | <property name="maximum" > | ||
55 | <double>10.000000000000000</double> | ||
56 | </property> | ||
57 | <property name="singleStep" > | ||
58 | <double>1.000000000000000</double> | ||
59 | </property> | ||
60 | <property name="value" > | ||
61 | <double>8.000000000000000</double> | ||
62 | </property> | ||
63 | </widget> | ||
64 | </item> | ||
65 | <item row="1" column="1" colspan="2" > | ||
66 | <widget class="QLabel" name="label" > | ||
67 | <property name="text" > | ||
68 | <string>Quality</string> | ||
69 | </property> | ||
70 | </widget> | ||
71 | </item> | ||
72 | <item row="2" column="0" > | ||
73 | <widget class="QSpinBox" name="complexity" > | ||
74 | <property name="maximum" > | ||
75 | <number>10</number> | ||
76 | </property> | ||
77 | <property name="value" > | ||
78 | <number>10</number> | ||
79 | </property> | ||
80 | </widget> | ||
81 | </item> | ||
82 | <item row="2" column="1" colspan="2" > | ||
83 | <widget class="QLabel" name="label_3" > | ||
84 | <property name="text" > | ||
85 | <string>Complexity</string> | ||
86 | </property> | ||
87 | </widget> | ||
88 | </item> | ||
89 | </layout> | ||
90 | </widget> | ||
91 | </item> | ||
92 | <item row="1" column="0" > | ||
93 | <widget class="QPushButton" name="reset" > | ||
94 | <property name="text" > | ||
95 | <string>Reset</string> | ||
96 | </property> | ||
97 | </widget> | ||
98 | </item> | ||
99 | <item row="1" column="1" > | ||
100 | <spacer> | ||
101 | <property name="orientation" > | ||
102 | <enum>Qt::Horizontal</enum> | ||
103 | </property> | ||
104 | <property name="sizeHint" > | ||
105 | <size> | ||
106 | <width>40</width> | ||
107 | <height>20</height> | ||
108 | </size> | ||
109 | </property> | ||
110 | </spacer> | ||
111 | </item> | ||
112 | <item row="1" column="2" > | ||
113 | <widget class="QPushButton" name="buttonOk" > | ||
114 | <property name="text" > | ||
115 | <string>&Ok</string> | ||
116 | </property> | ||
117 | <property name="icon" > | ||
118 | <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset> | ||
119 | </property> | ||
120 | </widget> | ||
121 | </item> | ||
122 | <item row="1" column="3" > | ||
123 | <widget class="QPushButton" name="buttonCancel" > | ||
124 | <property name="text" > | ||
125 | <string>&Cancel</string> | ||
126 | </property> | ||
127 | <property name="icon" > | ||
128 | <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset> | ||
129 | </property> | ||
130 | </widget> | ||
131 | </item> | ||
132 | </layout> | ||
133 | </widget> | ||
134 | <resources> | ||
135 | <include location="rbutilqt.qrc" /> | ||
136 | </resources> | ||
137 | <connections> | ||
138 | <connection> | ||
139 | <sender>buttonOk</sender> | ||
140 | <signal>clicked()</signal> | ||
141 | <receiver>RbSpeexCfgFrm</receiver> | ||
142 | <slot>accept()</slot> | ||
143 | <hints> | ||
144 | <hint type="sourcelabel" > | ||
145 | <x>253</x> | ||
146 | <y>147</y> | ||
147 | </hint> | ||
148 | <hint type="destinationlabel" > | ||
149 | <x>203</x> | ||
150 | <y>86</y> | ||
151 | </hint> | ||
152 | </hints> | ||
153 | </connection> | ||
154 | <connection> | ||
155 | <sender>buttonCancel</sender> | ||
156 | <signal>clicked()</signal> | ||
157 | <receiver>RbSpeexCfgFrm</receiver> | ||
158 | <slot>reject()</slot> | ||
159 | <hints> | ||
160 | <hint type="sourcelabel" > | ||
161 | <x>352</x> | ||
162 | <y>147</y> | ||
163 | </hint> | ||
164 | <hint type="destinationlabel" > | ||
165 | <x>203</x> | ||
166 | <y>86</y> | ||
167 | </hint> | ||
168 | </hints> | ||
169 | </connection> | ||
170 | </connections> | ||
171 | </ui> | ||
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index 2838213b33..27ab920e0f 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro | |||
@@ -64,9 +64,9 @@ SOURCES += rbutilqt.cpp \ | |||
64 | base/utils.cpp \ | 64 | base/utils.cpp \ |
65 | preview.cpp \ | 65 | preview.cpp \ |
66 | encoders.cpp \ | 66 | encoders.cpp \ |
67 | encodersgui.cpp \ | 67 | encttscfggui.cpp \ |
68 | encttssettings.cpp \ | ||
68 | tts.cpp \ | 69 | tts.cpp \ |
69 | ttsgui.cpp \ | ||
70 | ../../tools/wavtrim.c \ | 70 | ../../tools/wavtrim.c \ |
71 | ../../tools/voicefont.c \ | 71 | ../../tools/voicefont.c \ |
72 | voicefile.cpp \ | 72 | voicefile.cpp \ |
@@ -116,9 +116,9 @@ HEADERS += rbutilqt.h \ | |||
116 | base/utils.h \ | 116 | base/utils.h \ |
117 | preview.h \ | 117 | preview.h \ |
118 | encoders.h \ | 118 | encoders.h \ |
119 | encodersgui.h \ | 119 | encttscfggui.h \ |
120 | encttssettings.h \ | ||
120 | tts.h \ | 121 | tts.h \ |
121 | ttsgui.h \ | ||
122 | ../../tools/wavtrim.h \ | 122 | ../../tools/wavtrim.h \ |
123 | ../../tools/voicefont.h \ | 123 | ../../tools/voicefont.h \ |
124 | voicefile.h \ | 124 | voicefile.h \ |
@@ -167,11 +167,6 @@ FORMS += rbutilqtfrm.ui \ | |||
167 | themesinstallfrm.ui \ | 167 | themesinstallfrm.ui \ |
168 | uninstallfrm.ui \ | 168 | uninstallfrm.ui \ |
169 | previewfrm.ui \ | 169 | previewfrm.ui \ |
170 | rbspeexcfgfrm.ui \ | ||
171 | encexescfgfrm.ui \ | ||
172 | ttsexescfgfrm.ui \ | ||
173 | sapicfgfrm.ui \ | ||
174 | ttsfestivalcfgform.ui \ | ||
175 | createvoicefrm.ui \ | 170 | createvoicefrm.ui \ |
176 | sysinfofrm.ui | 171 | sysinfofrm.ui |
177 | 172 | ||
diff --git a/rbutil/rbutilqt/sapicfgfrm.ui b/rbutil/rbutilqt/sapicfgfrm.ui deleted file mode 100644 index 4d77c51ea7..0000000000 --- a/rbutil/rbutilqt/sapicfgfrm.ui +++ /dev/null | |||
@@ -1,175 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>SapiCfgFrm</class> | ||
3 | <widget class="QDialog" name="SapiCfgFrm" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>511</width> | ||
9 | <height>242</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Configuration</string> | ||
14 | </property> | ||
15 | <layout class="QHBoxLayout" > | ||
16 | <item> | ||
17 | <widget class="QGroupBox" name="groupBox" > | ||
18 | <property name="title" > | ||
19 | <string>Configure TTS Engine</string> | ||
20 | </property> | ||
21 | <layout class="QGridLayout" > | ||
22 | <item row="0" column="0" > | ||
23 | <widget class="QLabel" name="label_3" > | ||
24 | <property name="text" > | ||
25 | <string>Language</string> | ||
26 | </property> | ||
27 | </widget> | ||
28 | </item> | ||
29 | <item row="0" column="1" > | ||
30 | <widget class="QComboBox" name="languagecombo" /> | ||
31 | </item> | ||
32 | <item row="1" column="0" > | ||
33 | <widget class="QLabel" name="label" > | ||
34 | <property name="text" > | ||
35 | <string>Voice</string> | ||
36 | </property> | ||
37 | </widget> | ||
38 | </item> | ||
39 | <item row="1" column="1" > | ||
40 | <widget class="QComboBox" name="voicecombo" /> | ||
41 | </item> | ||
42 | <item row="2" column="0" > | ||
43 | <widget class="QLabel" name="label_4" > | ||
44 | <property name="text" > | ||
45 | <string>Speed</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | </item> | ||
49 | <item row="2" column="1" > | ||
50 | <widget class="QSpinBox" name="speed" > | ||
51 | <property name="minimum" > | ||
52 | <number>-10</number> | ||
53 | </property> | ||
54 | <property name="maximum" > | ||
55 | <number>10</number> | ||
56 | </property> | ||
57 | </widget> | ||
58 | </item> | ||
59 | <item row="3" column="0" > | ||
60 | <widget class="QLabel" name="label_2" > | ||
61 | <property name="text" > | ||
62 | <string>TTS options</string> | ||
63 | </property> | ||
64 | </widget> | ||
65 | </item> | ||
66 | <item row="3" column="1" > | ||
67 | <widget class="QLineEdit" name="ttsoptions" /> | ||
68 | </item> | ||
69 | <item row="5" column="0" colspan="2" > | ||
70 | <spacer> | ||
71 | <property name="orientation" > | ||
72 | <enum>Qt::Vertical</enum> | ||
73 | </property> | ||
74 | <property name="sizeHint" > | ||
75 | <size> | ||
76 | <width>473</width> | ||
77 | <height>21</height> | ||
78 | </size> | ||
79 | </property> | ||
80 | </spacer> | ||
81 | </item> | ||
82 | <item row="6" column="0" colspan="2" > | ||
83 | <layout class="QHBoxLayout" > | ||
84 | <item> | ||
85 | <widget class="QPushButton" name="reset" > | ||
86 | <property name="text" > | ||
87 | <string>Reset</string> | ||
88 | </property> | ||
89 | </widget> | ||
90 | </item> | ||
91 | <item> | ||
92 | <spacer> | ||
93 | <property name="orientation" > | ||
94 | <enum>Qt::Horizontal</enum> | ||
95 | </property> | ||
96 | <property name="sizeHint" > | ||
97 | <size> | ||
98 | <width>40</width> | ||
99 | <height>20</height> | ||
100 | </size> | ||
101 | </property> | ||
102 | </spacer> | ||
103 | </item> | ||
104 | <item> | ||
105 | <widget class="QPushButton" name="buttonOk" > | ||
106 | <property name="text" > | ||
107 | <string>&Ok</string> | ||
108 | </property> | ||
109 | <property name="icon" > | ||
110 | <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset> | ||
111 | </property> | ||
112 | </widget> | ||
113 | </item> | ||
114 | <item> | ||
115 | <widget class="QPushButton" name="buttonCancel" > | ||
116 | <property name="text" > | ||
117 | <string>&Cancel</string> | ||
118 | </property> | ||
119 | <property name="icon" > | ||
120 | <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset> | ||
121 | </property> | ||
122 | </widget> | ||
123 | </item> | ||
124 | </layout> | ||
125 | </item> | ||
126 | <item row="4" column="0" colspan="2" > | ||
127 | <widget class="QCheckBox" name="usesapi4" > | ||
128 | <property name="text" > | ||
129 | <string>Use Sapi 4</string> | ||
130 | </property> | ||
131 | </widget> | ||
132 | </item> | ||
133 | </layout> | ||
134 | </widget> | ||
135 | </item> | ||
136 | </layout> | ||
137 | </widget> | ||
138 | <resources> | ||
139 | <include location="rbutilqt.qrc" /> | ||
140 | </resources> | ||
141 | <connections> | ||
142 | <connection> | ||
143 | <sender>buttonOk</sender> | ||
144 | <signal>clicked()</signal> | ||
145 | <receiver>SapiCfgFrm</receiver> | ||
146 | <slot>accept()</slot> | ||
147 | <hints> | ||
148 | <hint type="sourcelabel" > | ||
149 | <x>253</x> | ||
150 | <y>147</y> | ||
151 | </hint> | ||
152 | <hint type="destinationlabel" > | ||
153 | <x>203</x> | ||
154 | <y>86</y> | ||
155 | </hint> | ||
156 | </hints> | ||
157 | </connection> | ||
158 | <connection> | ||
159 | <sender>buttonCancel</sender> | ||
160 | <signal>clicked()</signal> | ||
161 | <receiver>SapiCfgFrm</receiver> | ||
162 | <slot>reject()</slot> | ||
163 | <hints> | ||
164 | <hint type="sourcelabel" > | ||
165 | <x>352</x> | ||
166 | <y>147</y> | ||
167 | </hint> | ||
168 | <hint type="destinationlabel" > | ||
169 | <x>203</x> | ||
170 | <y>86</y> | ||
171 | </hint> | ||
172 | </hints> | ||
173 | </connection> | ||
174 | </connections> | ||
175 | </ui> | ||
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 6e872ad281..fd6f4a2109 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp | |||
@@ -40,7 +40,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); | 40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); |
41 | 41 | ||
42 | //tts | 42 | //tts |
43 | m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString()); | 43 | m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString()); |
44 | m_tts->setCfg(settings); | 44 | m_tts->setCfg(settings); |
45 | 45 | ||
46 | if(!m_tts->start(&errStr)) | 46 | if(!m_tts->start(&errStr)) |
@@ -52,7 +52,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
52 | } | 52 | } |
53 | 53 | ||
54 | // Encoder | 54 | // Encoder |
55 | m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString()); | 55 | m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString()); |
56 | m_enc->setCfg(settings); | 56 | m_enc->setCfg(settings); |
57 | 57 | ||
58 | if(!m_enc->start()) | 58 | if(!m_enc->start()) |
diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h index 08c076132d..ae69acfd78 100644 --- a/rbutil/rbutilqt/talkfile.h +++ b/rbutil/rbutilqt/talkfile.h | |||
@@ -34,7 +34,7 @@ class TalkFileCreator :public QObject | |||
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | public: | 36 | public: |
37 | TalkFileCreator(QObject* parent=0); | 37 | TalkFileCreator(QObject* parent); |
38 | 38 | ||
39 | bool createTalkFiles(ProgressloggerInterface* logger); | 39 | bool createTalkFiles(ProgressloggerInterface* logger); |
40 | 40 | ||
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp index 277022b9a1..d55ba9e739 100644 --- a/rbutil/rbutilqt/tts.cpp +++ b/rbutil/rbutilqt/tts.cpp | |||
@@ -18,11 +18,16 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "tts.h" | 20 | #include "tts.h" |
21 | #include "utils.h" | ||
22 | /********************************************************************* | ||
23 | * TTS Base | ||
24 | **********************************************************************/ | ||
25 | QMap<QString,QString> TTSBase::ttsList; | ||
21 | 26 | ||
27 | TTSBase::TTSBase(QObject* parent): EncTtsSettingInterface(parent) | ||
28 | { | ||
22 | 29 | ||
23 | // static variables | 30 | } |
24 | QMap<QString,QString> TTSBase::ttsList; | ||
25 | QMap<QString,TTSBase*> TTSBase::ttsCache; | ||
26 | 31 | ||
27 | // static functions | 32 | // static functions |
28 | void TTSBase::initTTSList() | 33 | void TTSBase::initTTSList() |
@@ -39,35 +44,29 @@ void TTSBase::initTTSList() | |||
39 | } | 44 | } |
40 | 45 | ||
41 | // function to get a specific encoder | 46 | // function to get a specific encoder |
42 | TTSBase* TTSBase::getTTS(QString ttsName) | 47 | TTSBase* TTSBase::getTTS(QObject* parent,QString ttsName) |
43 | { | 48 | { |
44 | // check cache | 49 | |
45 | if(ttsCache.contains(ttsName)) | ||
46 | return ttsCache.value(ttsName); | ||
47 | |||
48 | TTSBase* tts; | 50 | TTSBase* tts; |
49 | #if defined(Q_OS_WIN) | 51 | #if defined(Q_OS_WIN) |
50 | if(ttsName == "sapi") | 52 | if(ttsName == "sapi") |
51 | { | 53 | { |
52 | tts = new TTSSapi(); | 54 | tts = new TTSSapi(parent); |
53 | ttsCache[ttsName] = tts; | ||
54 | return tts; | 55 | return tts; |
55 | } | 56 | } |
56 | else | 57 | else |
57 | #endif | 58 | #endif |
58 | #if defined(Q_OS_LINUX) | 59 | #if defined(Q_OS_LINUX) |
59 | if (ttsName == "festival") | 60 | if (ttsName == "festival") |
60 | { | 61 | { |
61 | tts = new TTSFestival(); | 62 | tts = new TTSFestival(parent); |
62 | ttsCache[ttsName] = tts; | 63 | return tts; |
63 | return tts; | ||
64 | } | 64 | } |
65 | else | 65 | else |
66 | #endif | 66 | #endif |
67 | if (true) // fix for OS other than WIN or LINUX | 67 | if (true) // fix for OS other than WIN or LINUX |
68 | { | 68 | { |
69 | tts = new TTSExes(ttsName); | 69 | tts = new TTSExes(ttsName,parent); |
70 | ttsCache[ttsName] = tts; | ||
71 | return tts; | 70 | return tts; |
72 | } | 71 | } |
73 | } | 72 | } |
@@ -90,69 +89,41 @@ QString TTSBase::getTTSName(QString tts) | |||
90 | return ttsList.value(tts); | 89 | return ttsList.value(tts); |
91 | } | 90 | } |
92 | 91 | ||
93 | /********************************************************************* | ||
94 | * TTS Base | ||
95 | **********************************************************************/ | ||
96 | TTSBase::TTSBase(): QObject() | ||
97 | { | ||
98 | |||
99 | } | ||
100 | 92 | ||
101 | /********************************************************************* | 93 | /********************************************************************* |
102 | * General TTS Exes | 94 | * General TTS Exes |
103 | **********************************************************************/ | 95 | **********************************************************************/ |
104 | TTSExes::TTSExes(QString name) : TTSBase() | 96 | TTSExes::TTSExes(QString name,QObject* parent) : TTSBase(parent) |
105 | { | 97 | { |
106 | m_name = name; | 98 | m_name = name; |
107 | 99 | ||
108 | m_TemplateMap["espeak"] = "\"%exe\" %options -w \"%wavfile\" \"%text\""; | 100 | m_TemplateMap["espeak"] = "\"%exe\" %options -w \"%wavfile\" \"%text\""; |
109 | m_TemplateMap["flite"] = "\"%exe\" %options -o \"%wavfile\" -t \"%text\""; | 101 | m_TemplateMap["flite"] = "\"%exe\" %options -o \"%wavfile\" -t \"%text\""; |
110 | m_TemplateMap["swift"] = "\"%exe\" %options -o \"%wavfile\" \"%text\""; | 102 | m_TemplateMap["swift"] = "\"%exe\" %options -o \"%wavfile\" \"%text\""; |
111 | 103 | ||
112 | } | 104 | } |
113 | 105 | ||
114 | void TTSExes::setCfg(RbSettings* sett) | 106 | void TTSExes::generateSettings() |
115 | { | 107 | { |
116 | // call function of base class | 108 | QString exepath =settings->subValue(m_name,RbSettings::TtsPath).toString(); |
117 | TTSBase::setCfg(sett); | 109 | if(exepath == "") exepath = findExecutable(m_name); |
118 | 110 | ||
119 | // if the config isnt OK, try to autodetect | 111 | insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to TTS engine:",exepath,EncTtsSetting::eBROWSEBTN)); |
120 | if(!configOk()) | 112 | insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"TTS enginge options:",settings->subValue(m_name,RbSettings::TtsOptions))); |
121 | { | 113 | } |
122 | QString exepath; | ||
123 | //try autodetect tts | ||
124 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD) | ||
125 | QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts); | ||
126 | #elif defined(Q_OS_WIN) | ||
127 | QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts); | ||
128 | #endif | ||
129 | qDebug() << path; | ||
130 | for(int i = 0; i < path.size(); i++) | ||
131 | { | ||
132 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name; | ||
133 | #if defined(Q_OS_WIN) | ||
134 | executable += ".exe"; | ||
135 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); | ||
136 | executable = ex.join(""); | ||
137 | #endif | ||
138 | qDebug() << executable; | ||
139 | if(QFileInfo(executable).isExecutable()) | ||
140 | { | ||
141 | exepath= QDir::toNativeSeparators(executable); | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | settings->setSubValue(m_name, RbSettings::TtsPath, exepath); | ||
146 | settings->sync(); | ||
147 | } | ||
148 | 114 | ||
115 | void TTSExes::saveSettings() | ||
116 | { | ||
117 | settings->setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString()); | ||
118 | settings->setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString()); | ||
119 | settings->sync(); | ||
149 | } | 120 | } |
150 | 121 | ||
151 | bool TTSExes::start(QString *errStr) | 122 | bool TTSExes::start(QString *errStr) |
152 | { | 123 | { |
153 | m_TTSexec = settings->subValue(m_name, RbSettings::TtsPath).toString(); | 124 | m_TTSexec = settings->subValue(m_name,RbSettings::TtsPath).toString(); |
154 | m_TTSOpts = settings->subValue(m_name, RbSettings::TtsOptions).toString(); | 125 | m_TTSOpts = settings->subValue(m_name,RbSettings::TtsOptions).toString(); |
155 | 126 | ||
156 | m_TTSTemplate = m_TemplateMap.value(m_name); | 127 | m_TTSTemplate = m_TemplateMap.value(m_name); |
157 | 128 | ||
158 | QFileInfo tts(m_TTSexec); | 129 | QFileInfo tts(m_TTSexec); |
@@ -169,7 +140,7 @@ bool TTSExes::start(QString *errStr) | |||
169 | 140 | ||
170 | TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr) | 141 | TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr) |
171 | { | 142 | { |
172 | (void) errStr; | 143 | (void) errStr; |
173 | QString execstring = m_TTSTemplate; | 144 | QString execstring = m_TTSTemplate; |
174 | 145 | ||
175 | execstring.replace("%exe",m_TTSexec); | 146 | execstring.replace("%exe",m_TTSexec); |
@@ -182,57 +153,84 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr) | |||
182 | 153 | ||
183 | } | 154 | } |
184 | 155 | ||
185 | void TTSExes::showCfg() | ||
186 | { | ||
187 | #ifndef CONSOLE | ||
188 | TTSExesGui gui; | ||
189 | #else | ||
190 | TTSExesGuiCli gui; | ||
191 | #endif | ||
192 | gui.setCfg(settings); | ||
193 | gui.showCfg(m_name); | ||
194 | } | ||
195 | |||
196 | bool TTSExes::configOk() | 156 | bool TTSExes::configOk() |
197 | { | 157 | { |
198 | QString path = settings->subValue(m_name, RbSettings::TtsPath).toString(); | 158 | QString path = settings->subValue(m_name,RbSettings::TtsPath).toString(); |
199 | 159 | ||
200 | if (QFileInfo(path).exists()) | 160 | if (QFileInfo(path).exists()) |
201 | return true; | 161 | return true; |
202 | 162 | ||
203 | return false; | 163 | return false; |
204 | } | 164 | } |
205 | 165 | ||
206 | /********************************************************************* | 166 | /********************************************************************* |
207 | * TTS Sapi | 167 | * TTS Sapi |
208 | **********************************************************************/ | 168 | **********************************************************************/ |
209 | TTSSapi::TTSSapi() : TTSBase() | 169 | TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent) |
210 | { | 170 | { |
211 | m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\" /speed:%speed \"%options\""; | 171 | m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\" /speed:%speed \"%options\""; |
212 | defaultLanguage ="english"; | 172 | defaultLanguage ="english"; |
213 | m_sapi4 =false; | 173 | m_sapi4 =false; |
214 | } | 174 | } |
215 | 175 | ||
176 | void TTSSapi::generateSettings() | ||
177 | { | ||
178 | // language | ||
179 | QStringList languages = settings->languages(); | ||
180 | languages.sort(); | ||
181 | EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Language:",settings->subValue("sapi",RbSettings::TtsLanguage),languages); | ||
182 | connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList())); | ||
183 | insertSetting(eLANGUAGE,setting); | ||
184 | // voice | ||
185 | setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("sapi",RbSettings::TtsVoice),getVoiceList(settings->subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN); | ||
186 | connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList())); | ||
187 | insertSetting(eVOICE,setting); | ||
188 | //speed | ||
189 | insertSetting(eSPEED,new EncTtsSetting(this,EncTtsSetting::eINT,"Speed:",settings->subValue("sapi",RbSettings::TtsSpeed),-10,10)); | ||
190 | // options | ||
191 | insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Options:",settings->subValue("sapi",RbSettings::TtsOptions))); | ||
216 | 192 | ||
217 | bool TTSSapi::start(QString *errStr) | 193 | } |
194 | |||
195 | void TTSSapi::saveSettings() | ||
196 | { | ||
197 | //save settings in user config | ||
198 | settings->setSubValue("sapi",RbSettings::TtsLanguage,getSetting(eLANGUAGE)->current().toString()); | ||
199 | settings->setSubValue("sapi",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString()); | ||
200 | settings->setSubValue("sapi",RbSettings::TtsSpeed,getSetting(eSPEED)->current().toInt()); | ||
201 | settings->setSubValue("sapi",RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString()); | ||
202 | |||
203 | settings->sync(); | ||
204 | } | ||
205 | |||
206 | void TTSSapi::updateVoiceList() | ||
218 | { | 207 | { |
208 | qDebug() << "update voiceList"; | ||
209 | QStringList voiceList = getVoiceList(getSetting(eLANGUAGE)->current().toString()); | ||
210 | getSetting(eVOICE)->setList(voiceList); | ||
211 | if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0)); | ||
212 | else getSetting(eVOICE)->setCurrent(""); | ||
213 | } | ||
214 | |||
215 | bool TTSSapi::start(QString *errStr) | ||
216 | { | ||
219 | 217 | ||
220 | m_TTSOpts = settings->subValue("sapi", RbSettings::TtsOptions).toString(); | 218 | m_TTSOpts = settings->subValue("sapi",RbSettings::TtsOptions).toString(); |
221 | m_TTSLanguage =settings->subValue("sapi", RbSettings::TtsLanguage).toString(); | 219 | m_TTSLanguage =settings->subValue("sapi",RbSettings::TtsLanguage).toString(); |
222 | m_TTSVoice=settings->subValue("sapi", RbSettings::TtsVoice).toString(); | 220 | m_TTSVoice=settings->subValue("sapi",RbSettings::TtsVoice).toString(); |
223 | m_TTSSpeed=QString("%1").arg(settings->subValue("sapi", RbSettings::TtsSpeed).toInt()); | 221 | m_TTSSpeed=settings->subValue("sapi",RbSettings::TtsSpeed).toString(); |
224 | m_sapi4 = settings->value(RbSettings::TtsUseSapi4).toBool(); | 222 | m_sapi4 = settings->subValue("sapi",RbSettings::TtsUseSapi4).toBool(); |
225 | 223 | ||
226 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); | 224 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); |
227 | QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs"); | 225 | QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs"); |
228 | m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs"; | 226 | m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs"; |
229 | 227 | ||
230 | QFileInfo tts(m_TTSexec); | 228 | QFileInfo tts(m_TTSexec); |
231 | if(!tts.exists()) | 229 | if(!tts.exists()) |
232 | { | 230 | { |
233 | *errStr = tr("Could not copy the Sapi-script"); | 231 | *errStr = tr("Could not copy the Sapi-script"); |
234 | return false; | 232 | return false; |
235 | } | 233 | } |
236 | // create the voice process | 234 | // create the voice process |
237 | QString execstring = m_TTSTemplate; | 235 | QString execstring = m_TTSTemplate; |
238 | execstring.replace("%exe",m_TTSexec); | 236 | execstring.replace("%exe",m_TTSexec); |
@@ -240,31 +238,31 @@ bool TTSSapi::start(QString *errStr) | |||
240 | execstring.replace("%lang",m_TTSLanguage); | 238 | execstring.replace("%lang",m_TTSLanguage); |
241 | execstring.replace("%voice",m_TTSVoice); | 239 | execstring.replace("%voice",m_TTSVoice); |
242 | execstring.replace("%speed",m_TTSSpeed); | 240 | execstring.replace("%speed",m_TTSSpeed); |
243 | 241 | ||
244 | if(m_sapi4) | 242 | if(m_sapi4) |
245 | execstring.append(" /sapi4 "); | 243 | execstring.append(" /sapi4 "); |
246 | 244 | ||
247 | qDebug() << "init" << execstring; | 245 | qDebug() << "init" << execstring; |
248 | voicescript = new QProcess(NULL); | 246 | voicescript = new QProcess(NULL); |
249 | //connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error())); | 247 | //connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error())); |
250 | 248 | ||
251 | voicescript->start(execstring); | 249 | voicescript->start(execstring); |
252 | if(!voicescript->waitForStarted()) | 250 | if(!voicescript->waitForStarted()) |
253 | { | 251 | { |
254 | *errStr = tr("Could not start the Sapi-script"); | 252 | *errStr = tr("Could not start the Sapi-script"); |
255 | return false; | 253 | return false; |
256 | } | 254 | } |
257 | 255 | ||
258 | if(!voicescript->waitForReadyRead(300)) | 256 | if(!voicescript->waitForReadyRead(300)) |
259 | { | 257 | { |
260 | *errStr = voicescript->readAllStandardError(); | 258 | *errStr = voicescript->readAllStandardError(); |
261 | if(*errStr != "") | 259 | if(*errStr != "") |
262 | return false; | 260 | return false; |
263 | } | 261 | } |
264 | 262 | ||
265 | voicestream = new QTextStream(voicescript); | 263 | voicestream = new QTextStream(voicescript); |
266 | voicestream->setCodec("UTF16-LE"); | 264 | voicestream->setCodec("UTF16-LE"); |
267 | 265 | ||
268 | return true; | 266 | return true; |
269 | } | 267 | } |
270 | 268 | ||
@@ -272,14 +270,14 @@ bool TTSSapi::start(QString *errStr) | |||
272 | QStringList TTSSapi::getVoiceList(QString language) | 270 | QStringList TTSSapi::getVoiceList(QString language) |
273 | { | 271 | { |
274 | QStringList result; | 272 | QStringList result; |
275 | 273 | ||
276 | QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs"); | 274 | QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs"); |
277 | m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs"; | 275 | m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs"; |
278 | 276 | ||
279 | QFileInfo tts(m_TTSexec); | 277 | QFileInfo tts(m_TTSexec); |
280 | if(!tts.exists()) | 278 | if(!tts.exists()) |
281 | return result; | 279 | return result; |
282 | 280 | ||
283 | // create the voice process | 281 | // create the voice process |
284 | QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices"; | 282 | QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices"; |
285 | execstring.replace("%exe",m_TTSexec); | 283 | execstring.replace("%exe",m_TTSexec); |
@@ -287,34 +285,34 @@ QStringList TTSSapi::getVoiceList(QString language) | |||
287 | 285 | ||
288 | if(settings->value(RbSettings::TtsUseSapi4).toBool()) | 286 | if(settings->value(RbSettings::TtsUseSapi4).toBool()) |
289 | execstring.append(" /sapi4 "); | 287 | execstring.append(" /sapi4 "); |
290 | 288 | ||
291 | qDebug() << "init" << execstring; | 289 | qDebug() << "init" << execstring; |
292 | voicescript = new QProcess(NULL); | 290 | voicescript = new QProcess(NULL); |
293 | voicescript->start(execstring); | 291 | voicescript->start(execstring); |
294 | qDebug() << "wait for started"; | 292 | qDebug() << "wait for started"; |
295 | if(!voicescript->waitForStarted()) | 293 | if(!voicescript->waitForStarted()) |
296 | return result; | 294 | return result; |
297 | voicescript->closeWriteChannel(); | 295 | voicescript->closeWriteChannel(); |
298 | voicescript->waitForReadyRead(); | 296 | voicescript->waitForReadyRead(); |
299 | 297 | ||
300 | QString dataRaw = voicescript->readAllStandardError().data(); | 298 | QString dataRaw = voicescript->readAllStandardError().data(); |
301 | result = dataRaw.split(",",QString::SkipEmptyParts); | 299 | result = dataRaw.split(",",QString::SkipEmptyParts); |
302 | result.sort(); | 300 | if(result.size() > 0) |
303 | result.removeFirst(); | ||
304 | for(int i = 0; i< result.size();i++) | ||
305 | { | 301 | { |
306 | result[i] = result.at(i).simplified(); | 302 | result.sort(); |
307 | } | 303 | result.removeFirst(); |
308 | 304 | for(int i = 0; i< result.size();i++) | |
309 | 305 | { | |
306 | result[i] = result.at(i).simplified(); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | delete voicescript; | 310 | delete voicescript; |
311 | QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs", | 311 | QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner |
312 | QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner | 312 | |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser |
313 | |QFile::ReadUser |QFile::WriteUser |QFile::ExeUser | 313 | |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup |
314 | |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup | 314 | |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther ); |
315 | |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther); | ||
316 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); | 315 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); |
317 | |||
318 | return result; | 316 | return result; |
319 | } | 317 | } |
320 | 318 | ||
@@ -322,7 +320,7 @@ QStringList TTSSapi::getVoiceList(QString language) | |||
322 | 320 | ||
323 | TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr) | 321 | TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr) |
324 | { | 322 | { |
325 | (void) errStr; | 323 | (void) errStr; |
326 | QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n"; | 324 | QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n"; |
327 | qDebug() << "voicing" << query; | 325 | qDebug() << "voicing" << query; |
328 | *voicestream << query; | 326 | *voicestream << query; |
@@ -333,37 +331,24 @@ TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr) | |||
333 | } | 331 | } |
334 | 332 | ||
335 | bool TTSSapi::stop() | 333 | bool TTSSapi::stop() |
336 | { | 334 | { |
337 | 335 | ||
338 | *voicestream << "QUIT\r\n"; | 336 | *voicestream << "QUIT\r\n"; |
339 | voicestream->flush(); | 337 | voicestream->flush(); |
340 | voicescript->waitForFinished(); | 338 | voicescript->waitForFinished(); |
341 | delete voicestream; | 339 | delete voicestream; |
342 | delete voicescript; | 340 | delete voicescript; |
343 | QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs", | 341 | QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner |
344 | QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner | 342 | |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser |
345 | |QFile::ReadUser |QFile::WriteUser |QFile::ExeUser | 343 | |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup |
346 | |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup | 344 | |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther ); |
347 | |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther); | ||
348 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); | 345 | QFile::remove(QDir::tempPath() +"/sapi_voice.vbs"); |
349 | return true; | 346 | return true; |
350 | } | 347 | } |
351 | 348 | ||
352 | |||
353 | void TTSSapi::showCfg() | ||
354 | { | ||
355 | #ifndef CONSOLE | ||
356 | TTSSapiGui gui(this); | ||
357 | #else | ||
358 | TTSSapiGuiCli gui(this); | ||
359 | #endif | ||
360 | gui.setCfg(settings); | ||
361 | gui.showCfg(); | ||
362 | } | ||
363 | |||
364 | bool TTSSapi::configOk() | 349 | bool TTSSapi::configOk() |
365 | { | 350 | { |
366 | if(settings->subValue("sapi", RbSettings::TtsVoice).toString().isEmpty()) | 351 | if(settings->subValue("sapi",RbSettings::TtsVoice).toString().isEmpty()) |
367 | return false; | 352 | return false; |
368 | return true; | 353 | return true; |
369 | } | 354 | } |
@@ -372,252 +357,300 @@ bool TTSSapi::configOk() | |||
372 | **********************************************************************/ | 357 | **********************************************************************/ |
373 | TTSFestival::~TTSFestival() | 358 | TTSFestival::~TTSFestival() |
374 | { | 359 | { |
375 | stop(); | 360 | stop(); |
376 | } | 361 | } |
377 | 362 | ||
378 | void TTSFestival::startServer() | 363 | void TTSFestival::generateSettings() |
379 | { | 364 | { |
380 | if(!configOk()) | 365 | // server path |
381 | return; | 366 | QString exepath = settings->subValue("festival-server",RbSettings::TtsPath).toString(); |
367 | if(exepath == "" ) exepath = findExecutable("festival"); | ||
368 | insertSetting(eSERVERPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival server:",exepath,EncTtsSetting::eBROWSEBTN)); | ||
369 | |||
370 | // client path | ||
371 | QString clientpath = settings->subValue("festival-client",RbSettings::TtsPath).toString(); | ||
372 | if(clientpath == "" ) clientpath = findExecutable("festival_client"); | ||
373 | insertSetting(eCLIENTPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival client:",clientpath,EncTtsSetting::eBROWSEBTN)); | ||
374 | |||
375 | // voice | ||
376 | EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN); | ||
377 | connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList())); | ||
378 | connect(setting,SIGNAL(dataChanged()),this,SLOT(clearVoiceDescription())); | ||
379 | insertSetting(eVOICE,setting); | ||
380 | |||
381 | //voice description | ||
382 | setting = new EncTtsSetting(this,EncTtsSetting::eREADONLYSTRING,"Voice description:","",EncTtsSetting::eREFRESHBTN); | ||
383 | connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceDescription())); | ||
384 | insertSetting(eVOICEDESC,setting); | ||
385 | } | ||
382 | 386 | ||
383 | QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":"); | 387 | void TTSFestival::saveSettings() |
388 | { | ||
389 | //save settings in user config | ||
390 | settings->setSubValue("festival-server",RbSettings::TtsPath,getSetting(eSERVERPATH)->current().toString()); | ||
391 | settings->setSubValue("festival-client",RbSettings::TtsPath,getSetting(eCLIENTPATH)->current().toString()); | ||
392 | settings->setSubValue("festival",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString()); | ||
393 | |||
394 | settings->sync(); | ||
395 | } | ||
384 | 396 | ||
385 | serverProcess.start(QString("%1 --server").arg(paths[0])); | 397 | void TTSFestival::updateVoiceDescription() |
386 | serverProcess.waitForStarted(); | 398 | { |
399 | // get voice Info with current voice and path | ||
400 | QString info = getVoiceInfo(getSetting(eVOICE)->current().toString(),getSetting(eSERVERPATH)->current().toString()); | ||
401 | getSetting(eVOICEDESC)->setCurrent(info); | ||
402 | } | ||
387 | 403 | ||
388 | queryServer("(getpid)"); | 404 | void TTSFestival::clearVoiceDescription() |
389 | if(serverProcess.state() == QProcess::Running) | 405 | { |
390 | qDebug() << "Festival is up and running"; | 406 | getSetting(eVOICEDESC)->setCurrent(""); |
391 | else | ||
392 | qDebug() << "Festival failed to start"; | ||
393 | } | 407 | } |
394 | 408 | ||
395 | void TTSFestival::ensureServerRunning() | 409 | void TTSFestival::updateVoiceList() |
396 | { | 410 | { |
397 | if(serverProcess.state() != QProcess::Running) | 411 | QStringList voiceList = getVoiceList(getSetting(eSERVERPATH)->current().toString()); |
398 | { | 412 | getSetting(eVOICE)->setList(voiceList); |
399 | // least common denominator for all the server startup code paths | 413 | if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0)); |
400 | QProgressDialog progressDialog(tr(""), tr(""), 0, 0); | 414 | else getSetting(eVOICE)->setCurrent(""); |
401 | progressDialog.setWindowTitle(tr("Starting festival")); | 415 | } |
402 | progressDialog.setModal(true); | 416 | |
403 | progressDialog.setLabel(0); | 417 | void TTSFestival::startServer(QString path) |
404 | progressDialog.setCancelButton(0); | 418 | { |
405 | progressDialog.show(); | 419 | if(!configOk()) |
420 | return; | ||
421 | |||
422 | if(path == "") | ||
423 | path = settings->subValue("festival-server",RbSettings::TtsPath).toString(); | ||
424 | |||
425 | serverProcess.start(QString("%1 --server").arg(path)); | ||
426 | serverProcess.waitForStarted(); | ||
406 | 427 | ||
407 | QApplication::processEvents(); // actually show the dialog | 428 | queryServer("(getpid)",300,path); |
429 | if(serverProcess.state() == QProcess::Running) | ||
430 | qDebug() << "Festival is up and running"; | ||
431 | else | ||
432 | qDebug() << "Festival failed to start"; | ||
433 | } | ||
408 | 434 | ||
409 | startServer(); | 435 | void TTSFestival::ensureServerRunning(QString path) |
436 | { | ||
437 | if(serverProcess.state() != QProcess::Running) | ||
438 | { | ||
439 | startServer(path); | ||
410 | } | 440 | } |
411 | } | 441 | } |
412 | 442 | ||
413 | bool TTSFestival::start(QString* errStr) | 443 | bool TTSFestival::start(QString* errStr) |
414 | { | 444 | { |
415 | (void) errStr; | 445 | (void) errStr; |
416 | ensureServerRunning(); | 446 | ensureServerRunning(); |
417 | if (!settings->subValue("festival", RbSettings::TtsVoice).toString().isEmpty()) | 447 | if (!settings->subValue("festival",RbSettings::TtsVoice).toString().isEmpty()) |
418 | queryServer(QString("(voice.select '%1)") | 448 | queryServer(QString("(voice.select '%1)") |
419 | .arg(settings->subValue("festival", RbSettings::TtsVoice).toString())); | 449 | .arg(settings->subValue("festival", RbSettings::TtsVoice).toString())); |
420 | 450 | ||
421 | return true; | 451 | return true; |
422 | } | 452 | } |
423 | 453 | ||
424 | bool TTSFestival::stop() | 454 | bool TTSFestival::stop() |
425 | { | 455 | { |
426 | serverProcess.terminate(); | 456 | serverProcess.terminate(); |
427 | serverProcess.kill(); | 457 | serverProcess.kill(); |
428 | 458 | ||
429 | return true; | 459 | return true; |
430 | } | 460 | } |
431 | 461 | ||
432 | TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) | 462 | TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) |
433 | { | 463 | { |
434 | qDebug() << text << "->" << wavfile; | 464 | qDebug() << text << "->" << wavfile; |
435 | 465 | ||
436 | QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":"); | 466 | QString path = settings->subValue("festival-client",RbSettings::TtsPath).toString(); |
437 | QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(paths[1]).arg(wavfile); | 467 | QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(path).arg(wavfile); |
438 | qDebug() << cmd; | 468 | qDebug() << cmd; |
439 | 469 | ||
440 | QProcess clientProcess; | 470 | QProcess clientProcess; |
441 | clientProcess.start(cmd); | 471 | clientProcess.start(cmd); |
442 | clientProcess.write(QString("%1.\n").arg(text).toAscii()); | 472 | clientProcess.write(QString("%1.\n").arg(text).toAscii()); |
443 | clientProcess.waitForBytesWritten(); | 473 | clientProcess.waitForBytesWritten(); |
444 | clientProcess.closeWriteChannel(); | 474 | clientProcess.closeWriteChannel(); |
445 | clientProcess.waitForReadyRead(); | 475 | clientProcess.waitForReadyRead(); |
446 | QString response = clientProcess.readAll(); | 476 | QString response = clientProcess.readAll(); |
447 | response = response.trimmed(); | 477 | response = response.trimmed(); |
448 | if(!response.contains("Utterance")) | 478 | if(!response.contains("Utterance")) |
449 | { | 479 | { |
450 | qDebug() << "Could not voice string: " << response; | 480 | qDebug() << "Could not voice string: " << response; |
451 | *errStr = tr("engine could not voice string"); | 481 | *errStr = tr("engine could not voice string"); |
452 | return Warning; | 482 | return Warning; |
453 | /* do not stop the voicing process because of a single string | 483 | /* do not stop the voicing process because of a single string |
454 | TODO: needs proper settings */ | 484 | TODO: needs proper settings */ |
455 | } | 485 | } |
456 | clientProcess.closeReadChannel(QProcess::StandardError); | 486 | clientProcess.closeReadChannel(QProcess::StandardError); |
457 | clientProcess.closeReadChannel(QProcess::StandardOutput); | 487 | clientProcess.closeReadChannel(QProcess::StandardOutput); |
458 | clientProcess.terminate(); | 488 | clientProcess.terminate(); |
459 | clientProcess.kill(); | 489 | clientProcess.kill(); |
460 | 490 | ||
461 | return NoError; | 491 | return NoError; |
462 | } | 492 | } |
463 | 493 | ||
464 | bool TTSFestival::configOk() | 494 | bool TTSFestival::configOk() |
465 | { | 495 | { |
466 | QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":"); | 496 | QString serverPath = settings->subValue("festival-server",RbSettings::TtsPath).toString(); |
467 | if(paths.size() != 2) | 497 | QString clientPath = settings->subValue("festival-client",RbSettings::TtsVoice).toString(); |
468 | return false; | 498 | |
469 | bool ret = QFileInfo(paths[0]).isExecutable() && | 499 | bool ret = QFileInfo(serverPath).isExecutable() && |
470 | QFileInfo(paths[1]).isExecutable(); | 500 | QFileInfo(clientPath).isExecutable(); |
471 | if(settings->subValue("festival", RbSettings::TtsVoice).toString().size() > 0 | 501 | if(settings->subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0) |
472 | && voices.size() > 0) | 502 | ret = ret && (voices.indexOf(settings->subValue("festival",RbSettings::TtsVoice).toString()) != -1); |
473 | ret = ret && (voices.indexOf(settings->subValue("festival", | 503 | return ret; |
474 | RbSettings::TtsVoice).toString()) != -1); | ||
475 | return ret; | ||
476 | } | ||
477 | |||
478 | void TTSFestival::showCfg() | ||
479 | { | ||
480 | #ifndef CONSOLE | ||
481 | TTSFestivalGui gui(this); | ||
482 | #endif | ||
483 | gui.setCfg(settings); | ||
484 | gui.showCfg(); | ||
485 | } | 504 | } |
486 | 505 | ||
487 | QStringList TTSFestival::getVoiceList() | 506 | QStringList TTSFestival::getVoiceList(QString path) |
488 | { | 507 | { |
489 | if(!configOk()) | 508 | if(!configOk()) |
490 | return QStringList(); | 509 | return QStringList(); |
491 | 510 | ||
492 | if(voices.size() > 0) | 511 | if(voices.size() > 0) |
493 | { | 512 | { |
494 | qDebug() << "Using voice cache"; | 513 | qDebug() << "Using voice cache"; |
495 | return voices; | 514 | return voices; |
496 | } | 515 | } |
497 | QString response = queryServer("(voice.list)"); | 516 | |
498 | 517 | QString response = queryServer("(voice.list)",3000,path); | |
499 | // get the 2nd line. It should be (<voice_name>, <voice_name>) | 518 | |
500 | response = response.mid(response.indexOf('\n') + 1, -1); | 519 | // get the 2nd line. It should be (<voice_name>, <voice_name>) |
501 | response = response.left(response.indexOf('\n')).trimmed(); | 520 | response = response.mid(response.indexOf('\n') + 1, -1); |
502 | 521 | response = response.left(response.indexOf('\n')).trimmed(); | |
503 | voices = response.mid(1, response.size()-2).split(' '); | 522 | |
504 | 523 | voices = response.mid(1, response.size()-2).split(' '); | |
505 | voices.sort(); | 524 | |
506 | if (voices.size() == 1 && voices[0].size() == 0) | 525 | voices.sort(); |
507 | voices.removeAt(0); | 526 | if (voices.size() == 1 && voices[0].size() == 0) |
508 | if (voices.size() > 0) | 527 | voices.removeAt(0); |
509 | qDebug() << "Voices: " << voices; | 528 | if (voices.size() > 0) |
510 | else | 529 | qDebug() << "Voices: " << voices; |
511 | qDebug() << "No voices."; | 530 | else |
512 | return voices; | 531 | qDebug() << "No voices."; |
532 | |||
533 | return voices; | ||
513 | } | 534 | } |
514 | 535 | ||
515 | QString TTSFestival::getVoiceInfo(QString voice) | 536 | QString TTSFestival::getVoiceInfo(QString voice,QString path) |
516 | { | 537 | { |
517 | if(!configOk()) | 538 | if(!configOk()) |
518 | return ""; | 539 | return ""; |
519 | 540 | ||
520 | if(!getVoiceList().contains(voice)) | 541 | if(!getVoiceList().contains(voice)) |
521 | return ""; | 542 | return ""; |
522 | 543 | ||
523 | if(voiceDescriptions.contains(voice)) | 544 | if(voiceDescriptions.contains(voice)) |
524 | return voiceDescriptions[voice]; | 545 | return voiceDescriptions[voice]; |
525 | 546 | ||
526 | QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000); | 547 | QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000,path); |
527 | 548 | ||
528 | if (response == "") | 549 | if (response == "") |
529 | { | 550 | { |
530 | voiceDescriptions[voice]=tr("No description available"); | 551 | voiceDescriptions[voice]=tr("No description available"); |
531 | } | 552 | } |
532 | else | 553 | else |
533 | { | 554 | { |
534 | response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard)); | 555 | response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard)); |
535 | qDebug() << "voiceInfo w/o descr: " << response; | 556 | qDebug() << "voiceInfo w/o descr: " << response; |
536 | response = response.remove(')'); | 557 | response = response.remove(')'); |
537 | QStringList responseLines = response.split('(', QString::SkipEmptyParts); | 558 | QStringList responseLines = response.split('(', QString::SkipEmptyParts); |
538 | responseLines.removeAt(0); // the voice name itself | 559 | responseLines.removeAt(0); // the voice name itself |
539 | 560 | ||
540 | QString description; | 561 | QString description; |
541 | foreach(QString line, responseLines) | 562 | foreach(QString line, responseLines) |
542 | { | 563 | { |
543 | line = line.remove('('); | 564 | line = line.remove('('); |
544 | line = line.simplified(); | 565 | line = line.simplified(); |
545 | 566 | ||
546 | line[0] = line[0].toUpper(); // capitalize the key | 567 | line[0] = line[0].toUpper(); // capitalize the key |
547 | 568 | ||
548 | int firstSpace = line.indexOf(' '); | 569 | int firstSpace = line.indexOf(' '); |
549 | if (firstSpace > 0) | 570 | if (firstSpace > 0) |
550 | { | 571 | { |
551 | line = line.insert(firstSpace, ':'); // add a colon between the key and the value | 572 | line = line.insert(firstSpace, ':'); // add a colon between the key and the value |
552 | line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value | 573 | line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value |
553 | } | 574 | } |
554 | 575 | ||
555 | description += line + "\n"; | 576 | description += line + "\n"; |
556 | } | 577 | } |
557 | voiceDescriptions[voice] = description.trimmed(); | 578 | voiceDescriptions[voice] = description.trimmed(); |
558 | } | 579 | } |
559 | return voiceDescriptions[voice]; | 580 | |
581 | return voiceDescriptions[voice]; | ||
560 | } | 582 | } |
561 | 583 | ||
562 | QString TTSFestival::queryServer(QString query, int timeout) | 584 | QString TTSFestival::queryServer(QString query, int timeout,QString path) |
563 | { | 585 | { |
564 | if(!configOk()) | 586 | if(!configOk()) |
565 | return ""; | 587 | return ""; |
566 | 588 | ||
567 | ensureServerRunning(); | 589 | // this operation could take some time |
568 | 590 | emit busy(); | |
569 | qDebug() << "queryServer with " << query; | 591 | |
570 | QString response; | 592 | ensureServerRunning(path); |
571 | 593 | ||
572 | QDateTime endTime; | 594 | qDebug() << "queryServer with " << query; |
573 | if(timeout > 0) | 595 | QString response; |
574 | endTime = QDateTime::currentDateTime().addMSecs(timeout); | 596 | |
575 | 597 | QDateTime endTime; | |
576 | /* Festival is *extremely* unreliable. Although at this | 598 | if(timeout > 0) |
577 | * point we are sure that SIOD is accepting commands, | 599 | endTime = QDateTime::currentDateTime().addMSecs(timeout); |
578 | * we might end up with an empty response. Hence, the loop. | 600 | |
579 | */ | 601 | /* Festival is *extremely* unreliable. Although at this |
580 | while(true) | 602 | * point we are sure that SIOD is accepting commands, |
581 | { | 603 | * we might end up with an empty response. Hence, the loop. |
582 | QApplication::processEvents(QEventLoop::AllEvents, 50); | 604 | */ |
583 | QTcpSocket socket; | 605 | while(true) |
584 | 606 | { | |
585 | socket.connectToHost("localhost", 1314); | 607 | QCoreApplication::processEvents(QEventLoop::AllEvents, 50); |
586 | socket.waitForConnected(); | 608 | QTcpSocket socket; |
587 | 609 | ||
588 | if(socket.state() == QAbstractSocket::ConnectedState) | 610 | socket.connectToHost("localhost", 1314); |
611 | socket.waitForConnected(); | ||
612 | |||
613 | if(socket.state() == QAbstractSocket::ConnectedState) | ||
614 | { | ||
615 | socket.write(QString("%1\n").arg(query).toAscii()); | ||
616 | socket.waitForBytesWritten(); | ||
617 | socket.waitForReadyRead(); | ||
618 | |||
619 | response = socket.readAll().trimmed(); | ||
620 | |||
621 | if (response != "LP" && response != "") | ||
622 | break; | ||
623 | } | ||
624 | socket.abort(); | ||
625 | socket.disconnectFromHost(); | ||
626 | |||
627 | if(timeout > 0 && QDateTime::currentDateTime() >= endTime) | ||
589 | { | 628 | { |
590 | socket.write(QString("%1\n").arg(query).toAscii()); | 629 | emit busyEnd(); |
591 | socket.waitForBytesWritten(); | 630 | return ""; |
592 | socket.waitForReadyRead(); | ||
593 | |||
594 | response = socket.readAll().trimmed(); | ||
595 | |||
596 | if (response != "LP" && response != "") | ||
597 | break; | ||
598 | } | 631 | } |
599 | socket.abort(); | 632 | /* make sure we wait a little as we don't want to flood the server with requests */ |
600 | socket.disconnectFromHost(); | 633 | QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500); |
601 | 634 | while(QDateTime::currentDateTime() < tmpEndTime) | |
602 | if(timeout > 0 && QDateTime::currentDateTime() >= endTime) | 635 | QCoreApplication::processEvents(QEventLoop::AllEvents); |
603 | return ""; | 636 | } |
604 | 637 | if(response == "nil") | |
605 | /* make sure we wait a little as we don't want to flood the server with requests */ | ||
606 | QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500); | ||
607 | while(QDateTime::currentDateTime() < tmpEndTime) | ||
608 | QApplication::processEvents(QEventLoop::AllEvents); | ||
609 | } | ||
610 | if(response == "nil") | ||
611 | return ""; | ||
612 | |||
613 | QStringList lines = response.split('\n'); | ||
614 | if(lines.size() > 2) | ||
615 | { | 638 | { |
616 | lines.removeFirst(); | 639 | emit busyEnd(); |
617 | lines.removeLast(); | 640 | return ""; |
618 | } | 641 | } |
619 | else | 642 | |
620 | qDebug() << "Response too short: " << response; | 643 | QStringList lines = response.split('\n'); |
644 | if(lines.size() > 2) | ||
645 | { | ||
646 | lines.removeFirst(); | ||
647 | lines.removeLast(); | ||
648 | } | ||
649 | else | ||
650 | qDebug() << "Response too short: " << response; | ||
651 | |||
652 | emit busyEnd(); | ||
621 | return lines.join("\n"); | 653 | return lines.join("\n"); |
654 | |||
622 | } | 655 | } |
623 | 656 | ||
diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h index c9262b74c6..093ccd6138 100644 --- a/rbutil/rbutilqt/tts.h +++ b/rbutil/rbutilqt/tts.h | |||
@@ -19,52 +19,49 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #ifndef TTS_H | 23 | #ifndef TTS_H |
24 | #define TTS_H | 24 | #define TTS_H |
25 | 25 | ||
26 | #include "rbsettings.h" | 26 | #include "rbsettings.h" |
27 | #include <QtCore> | 27 | #include <QtCore> |
28 | #include <QProcess> | 28 | #include <QProcess> |
29 | #include <QProgressDialog> | ||
30 | #include <QDateTime> | 29 | #include <QDateTime> |
31 | #include <QRegExp> | 30 | #include <QRegExp> |
32 | #include <QTcpSocket> | 31 | #include <QTcpSocket> |
33 | 32 | ||
34 | #ifndef CONSOLE | 33 | #include "encttssettings.h" |
35 | #include "ttsgui.h" | ||
36 | #else | ||
37 | #include "ttsguicli.h" | ||
38 | #endif | ||
39 | 34 | ||
40 | enum TTSStatus{ FatalError, NoError, Warning }; | 35 | enum TTSStatus{ FatalError, NoError, Warning }; |
41 | class TTSSapi; | 36 | |
42 | #if defined(Q_OS_LINUX) | 37 | class TTSBase : public EncTtsSettingInterface |
43 | class TTSFestival; | ||
44 | #endif | ||
45 | class TTSBase : public QObject | ||
46 | { | 38 | { |
47 | Q_OBJECT | 39 | Q_OBJECT |
48 | public: | 40 | public: |
49 | TTSBase(); | 41 | TTSBase(QObject *parent); |
50 | virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) | 42 | //! Child class should generate a clip |
51 | { (void) text; (void) wavfile; (void) errStr; return FatalError;} | 43 | virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) =0; |
52 | virtual bool start(QString *errStr) { (void)errStr; return false; } | 44 | //! Child class should do startup |
53 | virtual bool stop() { return false; } | 45 | virtual bool start(QString *errStr) =0; |
54 | virtual void showCfg(){} | 46 | //! child class should stop |
55 | virtual bool configOk() { return false; } | 47 | virtual bool stop() =0; |
56 | 48 | ||
57 | virtual void setCfg(RbSettings* sett) { settings = sett; } | 49 | // configuration |
58 | 50 | //! Child class should return true, when configuration is good | |
59 | static TTSBase* getTTS(QString ttsname); | 51 | virtual bool configOk()=0; |
52 | //! Child class should generate and insertSetting(..) its settings | ||
53 | virtual void generateSettings() = 0; | ||
54 | //! Chlid class should commit the Settings to permanent storage | ||
55 | virtual void saveSettings() = 0; | ||
56 | |||
57 | // static functions | ||
58 | static TTSBase* getTTS(QObject* parent,QString ttsname); | ||
60 | static QStringList getTTSList(); | 59 | static QStringList getTTSList(); |
61 | static QString getTTSName(QString tts); | 60 | static QString getTTSName(QString tts); |
62 | 61 | ||
63 | public slots: | 62 | // sets the config. Users of TTS classes, always have to call this first |
64 | virtual void accept(void){} | 63 | void setCfg(RbSettings* sett) { settings = sett; } |
65 | virtual void reject(void){} | 64 | |
66 | virtual void reset(void){} | ||
67 | |||
68 | private: | 65 | private: |
69 | //inits the tts List | 66 | //inits the tts List |
70 | static void initTTSList(); | 67 | static void initTTSList(); |
@@ -72,26 +69,42 @@ class TTSBase : public QObject | |||
72 | protected: | 69 | protected: |
73 | RbSettings* settings; | 70 | RbSettings* settings; |
74 | static QMap<QString,QString> ttsList; | 71 | static QMap<QString,QString> ttsList; |
75 | static QMap<QString,TTSBase*> ttsCache; | ||
76 | }; | 72 | }; |
77 | 73 | ||
78 | class TTSSapi : public TTSBase | 74 | class TTSSapi : public TTSBase |
79 | { | 75 | { |
80 | Q_OBJECT | 76 | //! Enum to identify the settings |
77 | enum ESettings | ||
78 | { | ||
79 | eLANGUAGE, | ||
80 | eVOICE, | ||
81 | eSPEED, | ||
82 | eOPTIONS | ||
83 | }; | ||
84 | |||
85 | Q_OBJECT | ||
81 | public: | 86 | public: |
82 | TTSSapi(); | 87 | TTSSapi(QObject* parent=NULL); |
83 | virtual TTSStatus voice(QString text,QString wavfile, QString *errStr); | 88 | |
84 | virtual bool start(QString *errStr); | 89 | TTSStatus voice(QString text,QString wavfile, QString *errStr); |
85 | virtual bool stop(); | 90 | bool start(QString *errStr); |
86 | virtual void showCfg(); | 91 | bool stop(); |
87 | virtual bool configOk(); | 92 | |
88 | 93 | // for settings | |
94 | bool configOk(); | ||
95 | void generateSettings(); | ||
96 | void saveSettings(); | ||
97 | |||
98 | private slots: | ||
99 | void updateVoiceList(); | ||
100 | |||
101 | private: | ||
89 | QStringList getVoiceList(QString language); | 102 | QStringList getVoiceList(QString language); |
90 | private: | 103 | |
91 | QProcess* voicescript; | 104 | QProcess* voicescript; |
92 | QTextStream* voicestream; | 105 | QTextStream* voicestream; |
93 | QString defaultLanguage; | 106 | QString defaultLanguage; |
94 | 107 | ||
95 | QString m_TTSexec; | 108 | QString m_TTSexec; |
96 | QString m_TTSOpts; | 109 | QString m_TTSOpts; |
97 | QString m_TTSTemplate; | 110 | QString m_TTSTemplate; |
@@ -104,16 +117,23 @@ class TTSSapi : public TTSBase | |||
104 | 117 | ||
105 | class TTSExes : public TTSBase | 118 | class TTSExes : public TTSBase |
106 | { | 119 | { |
120 | enum ESettings | ||
121 | { | ||
122 | eEXEPATH, | ||
123 | eOPTIONS | ||
124 | }; | ||
125 | |||
107 | Q_OBJECT | 126 | Q_OBJECT |
108 | public: | 127 | public: |
109 | TTSExes(QString name); | 128 | TTSExes(QString name,QObject* parent=NULL); |
110 | virtual TTSStatus voice(QString text,QString wavfile, QString *errStr); | 129 | TTSStatus voice(QString text,QString wavfile, QString *errStr); |
111 | virtual bool start(QString *errStr); | 130 | bool start(QString *errStr); |
112 | virtual bool stop() {return true;} | 131 | bool stop() {return true;} |
113 | virtual void showCfg(); | 132 | |
114 | virtual bool configOk(); | 133 | // for settings |
115 | 134 | void generateSettings(); | |
116 | virtual void setCfg(RbSettings* sett); | 135 | void saveSettings(); |
136 | bool configOk(); | ||
117 | 137 | ||
118 | private: | 138 | private: |
119 | QString m_name; | 139 | QString m_name; |
@@ -125,24 +145,41 @@ class TTSExes : public TTSBase | |||
125 | 145 | ||
126 | class TTSFestival : public TTSBase | 146 | class TTSFestival : public TTSBase |
127 | { | 147 | { |
128 | Q_OBJECT | 148 | enum ESettings |
129 | public: | 149 | { |
130 | ~TTSFestival(); | 150 | eSERVERPATH, |
131 | virtual bool configOk(); | 151 | eCLIENTPATH, |
132 | virtual bool start(QString *errStr); | 152 | eVOICE, |
133 | virtual bool stop(); | 153 | eVOICEDESC |
134 | virtual void showCfg(); | 154 | }; |
135 | virtual TTSStatus voice(QString text,QString wavfile, QString *errStr); | 155 | |
136 | 156 | Q_OBJECT | |
137 | QStringList getVoiceList(); | 157 | public: |
138 | QString getVoiceInfo(QString voice); | 158 | TTSFestival(QObject* parent=NULL) :TTSBase(parent) {} |
139 | private: | 159 | ~TTSFestival(); |
140 | inline void startServer(); | 160 | bool start(QString *errStr); |
141 | inline void ensureServerRunning(); | 161 | bool stop(); |
142 | QString queryServer(QString query, int timeout = -1); | 162 | TTSStatus voice(QString text,QString wavfile, QString *errStr); |
143 | QProcess serverProcess; | 163 | |
144 | QStringList voices; | 164 | // for settings |
145 | QMap<QString, QString> voiceDescriptions; | 165 | bool configOk(); |
166 | void generateSettings(); | ||
167 | void saveSettings(); | ||
168 | |||
169 | private slots: | ||
170 | void updateVoiceList(); | ||
171 | void updateVoiceDescription(); | ||
172 | void clearVoiceDescription(); | ||
173 | private: | ||
174 | QStringList getVoiceList(QString path =""); | ||
175 | QString getVoiceInfo(QString voice,QString path =""); | ||
176 | |||
177 | inline void startServer(QString path=""); | ||
178 | inline void ensureServerRunning(QString path=""); | ||
179 | QString queryServer(QString query, int timeout = -1,QString path=""); | ||
180 | QProcess serverProcess; | ||
181 | QStringList voices; | ||
182 | QMap<QString, QString> voiceDescriptions; | ||
146 | }; | 183 | }; |
147 | 184 | ||
148 | #endif | 185 | #endif |
diff --git a/rbutil/rbutilqt/ttsexescfgfrm.ui b/rbutil/rbutilqt/ttsexescfgfrm.ui deleted file mode 100644 index a8df51c847..0000000000 --- a/rbutil/rbutilqt/ttsexescfgfrm.ui +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>TTSExesCfgFrm</class> | ||
3 | <widget class="QDialog" name="TTSExesCfgFrm" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>463</width> | ||
9 | <height>214</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Configuration</string> | ||
14 | </property> | ||
15 | <layout class="QHBoxLayout" > | ||
16 | <item> | ||
17 | <widget class="QGroupBox" name="groupBox" > | ||
18 | <property name="title" > | ||
19 | <string>Configure TTS Engine</string> | ||
20 | </property> | ||
21 | <layout class="QVBoxLayout" > | ||
22 | <item> | ||
23 | <widget class="QLabel" name="label" > | ||
24 | <property name="sizePolicy" > | ||
25 | <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > | ||
26 | <horstretch>0</horstretch> | ||
27 | <verstretch>255</verstretch> | ||
28 | </sizepolicy> | ||
29 | </property> | ||
30 | <property name="text" > | ||
31 | <string>Path to TTS Engine</string> | ||
32 | </property> | ||
33 | </widget> | ||
34 | </item> | ||
35 | <item> | ||
36 | <layout class="QHBoxLayout" > | ||
37 | <item> | ||
38 | <widget class="QLineEdit" name="ttspath" /> | ||
39 | </item> | ||
40 | <item> | ||
41 | <widget class="QPushButton" name="browse" > | ||
42 | <property name="text" > | ||
43 | <string>&Browse</string> | ||
44 | </property> | ||
45 | </widget> | ||
46 | </item> | ||
47 | </layout> | ||
48 | </item> | ||
49 | <item> | ||
50 | <widget class="QLabel" name="label_2" > | ||
51 | <property name="text" > | ||
52 | <string>TTS options</string> | ||
53 | </property> | ||
54 | </widget> | ||
55 | </item> | ||
56 | <item> | ||
57 | <widget class="QLineEdit" name="ttsoptions" /> | ||
58 | </item> | ||
59 | <item> | ||
60 | <spacer> | ||
61 | <property name="orientation" > | ||
62 | <enum>Qt::Vertical</enum> | ||
63 | </property> | ||
64 | <property name="sizeHint" > | ||
65 | <size> | ||
66 | <width>20</width> | ||
67 | <height>40</height> | ||
68 | </size> | ||
69 | </property> | ||
70 | </spacer> | ||
71 | </item> | ||
72 | <item> | ||
73 | <layout class="QHBoxLayout" > | ||
74 | <item> | ||
75 | <widget class="QPushButton" name="reset" > | ||
76 | <property name="text" > | ||
77 | <string>Reset</string> | ||
78 | </property> | ||
79 | </widget> | ||
80 | </item> | ||
81 | <item> | ||
82 | <spacer> | ||
83 | <property name="orientation" > | ||
84 | <enum>Qt::Horizontal</enum> | ||
85 | </property> | ||
86 | <property name="sizeHint" > | ||
87 | <size> | ||
88 | <width>40</width> | ||
89 | <height>20</height> | ||
90 | </size> | ||
91 | </property> | ||
92 | </spacer> | ||
93 | </item> | ||
94 | <item> | ||
95 | <widget class="QPushButton" name="buttonOk" > | ||
96 | <property name="text" > | ||
97 | <string>&Ok</string> | ||
98 | </property> | ||
99 | <property name="icon" > | ||
100 | <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset> | ||
101 | </property> | ||
102 | </widget> | ||
103 | </item> | ||
104 | <item> | ||
105 | <widget class="QPushButton" name="buttonCancel" > | ||
106 | <property name="text" > | ||
107 | <string>&Cancel</string> | ||
108 | </property> | ||
109 | <property name="icon" > | ||
110 | <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset> | ||
111 | </property> | ||
112 | </widget> | ||
113 | </item> | ||
114 | </layout> | ||
115 | </item> | ||
116 | </layout> | ||
117 | </widget> | ||
118 | </item> | ||
119 | </layout> | ||
120 | </widget> | ||
121 | <resources> | ||
122 | <include location="rbutilqt.qrc" /> | ||
123 | </resources> | ||
124 | <connections> | ||
125 | <connection> | ||
126 | <sender>buttonOk</sender> | ||
127 | <signal>clicked()</signal> | ||
128 | <receiver>TTSExesCfgFrm</receiver> | ||
129 | <slot>accept()</slot> | ||
130 | <hints> | ||
131 | <hint type="sourcelabel" > | ||
132 | <x>253</x> | ||
133 | <y>147</y> | ||
134 | </hint> | ||
135 | <hint type="destinationlabel" > | ||
136 | <x>203</x> | ||
137 | <y>86</y> | ||
138 | </hint> | ||
139 | </hints> | ||
140 | </connection> | ||
141 | <connection> | ||
142 | <sender>buttonCancel</sender> | ||
143 | <signal>clicked()</signal> | ||
144 | <receiver>TTSExesCfgFrm</receiver> | ||
145 | <slot>reject()</slot> | ||
146 | <hints> | ||
147 | <hint type="sourcelabel" > | ||
148 | <x>352</x> | ||
149 | <y>147</y> | ||
150 | </hint> | ||
151 | <hint type="destinationlabel" > | ||
152 | <x>203</x> | ||
153 | <y>86</y> | ||
154 | </hint> | ||
155 | </hints> | ||
156 | </connection> | ||
157 | </connections> | ||
158 | </ui> | ||
diff --git a/rbutil/rbutilqt/ttsfestivalcfgform.ui b/rbutil/rbutilqt/ttsfestivalcfgform.ui deleted file mode 100644 index bdebf3fe93..0000000000 --- a/rbutil/rbutilqt/ttsfestivalcfgform.ui +++ /dev/null | |||
@@ -1,322 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>TTSFestivalCfgFrm</class> | ||
3 | <widget class="QDialog" name="TTSFestivalCfgFrm" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>340</width> | ||
9 | <height>316</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Configuration</string> | ||
14 | </property> | ||
15 | <layout class="QGridLayout" name="gridLayout_4" > | ||
16 | <item row="3" column="1" > | ||
17 | <widget class="QDialogButtonBox" name="buttonBox" > | ||
18 | <property name="sizePolicy" > | ||
19 | <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > | ||
20 | <horstretch>0</horstretch> | ||
21 | <verstretch>0</verstretch> | ||
22 | </sizepolicy> | ||
23 | </property> | ||
24 | <property name="orientation" > | ||
25 | <enum>Qt::Horizontal</enum> | ||
26 | </property> | ||
27 | <property name="standardButtons" > | ||
28 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
29 | </property> | ||
30 | <property name="centerButtons" > | ||
31 | <bool>false</bool> | ||
32 | </property> | ||
33 | </widget> | ||
34 | </item> | ||
35 | <item row="0" column="0" colspan="2" > | ||
36 | <widget class="QGroupBox" name="execsBox" > | ||
37 | <property name="sizePolicy" > | ||
38 | <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > | ||
39 | <horstretch>1</horstretch> | ||
40 | <verstretch>0</verstretch> | ||
41 | </sizepolicy> | ||
42 | </property> | ||
43 | <property name="title" > | ||
44 | <string>Executables</string> | ||
45 | </property> | ||
46 | <layout class="QGridLayout" name="gridLayout_2" > | ||
47 | <property name="topMargin" > | ||
48 | <number>0</number> | ||
49 | </property> | ||
50 | <property name="spacing" > | ||
51 | <number>0</number> | ||
52 | </property> | ||
53 | <item row="0" column="0" > | ||
54 | <layout class="QGridLayout" name="gridLayout" > | ||
55 | <property name="sizeConstraint" > | ||
56 | <enum>QLayout::SetMinimumSize</enum> | ||
57 | </property> | ||
58 | <property name="horizontalSpacing" > | ||
59 | <number>6</number> | ||
60 | </property> | ||
61 | <property name="verticalSpacing" > | ||
62 | <number>0</number> | ||
63 | </property> | ||
64 | <item row="0" column="0" colspan="2" > | ||
65 | <widget class="QLabel" name="label" > | ||
66 | <property name="sizePolicy" > | ||
67 | <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > | ||
68 | <horstretch>0</horstretch> | ||
69 | <verstretch>0</verstretch> | ||
70 | </sizepolicy> | ||
71 | </property> | ||
72 | <property name="text" > | ||
73 | <string>Path to Festival server</string> | ||
74 | </property> | ||
75 | </widget> | ||
76 | </item> | ||
77 | <item row="1" column="0" > | ||
78 | <widget class="QLineEdit" name="serverPath" > | ||
79 | <property name="sizePolicy" > | ||
80 | <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > | ||
81 | <horstretch>1</horstretch> | ||
82 | <verstretch>0</verstretch> | ||
83 | </sizepolicy> | ||
84 | </property> | ||
85 | <property name="minimumSize" > | ||
86 | <size> | ||
87 | <width>215</width> | ||
88 | <height>0</height> | ||
89 | </size> | ||
90 | </property> | ||
91 | </widget> | ||
92 | </item> | ||
93 | <item row="1" column="1" > | ||
94 | <widget class="QPushButton" name="serverButton" > | ||
95 | <property name="text" > | ||
96 | <string>Browse</string> | ||
97 | </property> | ||
98 | </widget> | ||
99 | </item> | ||
100 | <item row="2" column="0" colspan="2" > | ||
101 | <widget class="QLabel" name="label_2" > | ||
102 | <property name="sizePolicy" > | ||
103 | <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > | ||
104 | <horstretch>0</horstretch> | ||
105 | <verstretch>0</verstretch> | ||
106 | </sizepolicy> | ||
107 | </property> | ||
108 | <property name="text" > | ||
109 | <string>Path to Festival client</string> | ||
110 | </property> | ||
111 | </widget> | ||
112 | </item> | ||
113 | <item row="3" column="0" > | ||
114 | <widget class="QLineEdit" name="clientPath" > | ||
115 | <property name="sizePolicy" > | ||
116 | <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > | ||
117 | <horstretch>1</horstretch> | ||
118 | <verstretch>0</verstretch> | ||
119 | </sizepolicy> | ||
120 | </property> | ||
121 | <property name="minimumSize" > | ||
122 | <size> | ||
123 | <width>215</width> | ||
124 | <height>0</height> | ||
125 | </size> | ||
126 | </property> | ||
127 | </widget> | ||
128 | </item> | ||
129 | <item row="3" column="1" > | ||
130 | <widget class="QPushButton" name="clientButton" > | ||
131 | <property name="text" > | ||
132 | <string>Browse</string> | ||
133 | </property> | ||
134 | </widget> | ||
135 | </item> | ||
136 | </layout> | ||
137 | </item> | ||
138 | </layout> | ||
139 | </widget> | ||
140 | </item> | ||
141 | <item row="3" column="0" > | ||
142 | <spacer name="horizontalSpacer" > | ||
143 | <property name="orientation" > | ||
144 | <enum>Qt::Horizontal</enum> | ||
145 | </property> | ||
146 | <property name="sizeHint" stdset="0" > | ||
147 | <size> | ||
148 | <width>70</width> | ||
149 | <height>20</height> | ||
150 | </size> | ||
151 | </property> | ||
152 | </spacer> | ||
153 | </item> | ||
154 | <item row="2" column="0" > | ||
155 | <spacer name="verticalSpacer" > | ||
156 | <property name="orientation" > | ||
157 | <enum>Qt::Vertical</enum> | ||
158 | </property> | ||
159 | <property name="sizeHint" stdset="0" > | ||
160 | <size> | ||
161 | <width>153</width> | ||
162 | <height>43</height> | ||
163 | </size> | ||
164 | </property> | ||
165 | </spacer> | ||
166 | </item> | ||
167 | <item row="1" column="0" colspan="2" > | ||
168 | <widget class="QGroupBox" name="groupBox2" > | ||
169 | <property name="sizePolicy" > | ||
170 | <sizepolicy vsizetype="Minimum" hsizetype="Expanding" > | ||
171 | <horstretch>1</horstretch> | ||
172 | <verstretch>0</verstretch> | ||
173 | </sizepolicy> | ||
174 | </property> | ||
175 | <property name="minimumSize" > | ||
176 | <size> | ||
177 | <width>0</width> | ||
178 | <height>0</height> | ||
179 | </size> | ||
180 | </property> | ||
181 | <property name="title" > | ||
182 | <string>Server voice</string> | ||
183 | </property> | ||
184 | <layout class="QGridLayout" name="gridLayout_3" > | ||
185 | <property name="leftMargin" > | ||
186 | <number>6</number> | ||
187 | </property> | ||
188 | <property name="topMargin" > | ||
189 | <number>6</number> | ||
190 | </property> | ||
191 | <property name="bottomMargin" > | ||
192 | <number>6</number> | ||
193 | </property> | ||
194 | <property name="horizontalSpacing" > | ||
195 | <number>6</number> | ||
196 | </property> | ||
197 | <property name="verticalSpacing" > | ||
198 | <number>0</number> | ||
199 | </property> | ||
200 | <item row="0" column="0" colspan="2" > | ||
201 | <widget class="QLabel" name="voiceLabel" > | ||
202 | <property name="sizePolicy" > | ||
203 | <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > | ||
204 | <horstretch>0</horstretch> | ||
205 | <verstretch>0</verstretch> | ||
206 | </sizepolicy> | ||
207 | </property> | ||
208 | <property name="text" > | ||
209 | <string>Select a voice</string> | ||
210 | </property> | ||
211 | </widget> | ||
212 | </item> | ||
213 | <item row="1" column="0" > | ||
214 | <widget class="QPushButton" name="refreshButton" > | ||
215 | <property name="sizePolicy" > | ||
216 | <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > | ||
217 | <horstretch>0</horstretch> | ||
218 | <verstretch>0</verstretch> | ||
219 | </sizepolicy> | ||
220 | </property> | ||
221 | <property name="text" > | ||
222 | <string>&Refresh</string> | ||
223 | </property> | ||
224 | <property name="icon" > | ||
225 | <iconset resource="rbutilqt.qrc" > | ||
226 | <normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset> | ||
227 | </property> | ||
228 | </widget> | ||
229 | </item> | ||
230 | <item row="1" column="1" > | ||
231 | <widget class="QComboBox" name="voicesBox" > | ||
232 | <property name="sizePolicy" > | ||
233 | <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > | ||
234 | <horstretch>1</horstretch> | ||
235 | <verstretch>0</verstretch> | ||
236 | </sizepolicy> | ||
237 | </property> | ||
238 | <property name="minimumSize" > | ||
239 | <size> | ||
240 | <width>0</width> | ||
241 | <height>0</height> | ||
242 | </size> | ||
243 | </property> | ||
244 | </widget> | ||
245 | </item> | ||
246 | <item row="4" column="1" > | ||
247 | <widget class="QLabel" name="descriptionLabel" > | ||
248 | <property name="sizePolicy" > | ||
249 | <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > | ||
250 | <horstretch>0</horstretch> | ||
251 | <verstretch>0</verstretch> | ||
252 | </sizepolicy> | ||
253 | </property> | ||
254 | <property name="text" > | ||
255 | <string/> | ||
256 | </property> | ||
257 | </widget> | ||
258 | </item> | ||
259 | <item row="3" column="1" > | ||
260 | <widget class="QCheckBox" name="showDescriptionCheckbox" > | ||
261 | <property name="text" > | ||
262 | <string>Show voice description</string> | ||
263 | </property> | ||
264 | </widget> | ||
265 | </item> | ||
266 | </layout> | ||
267 | </widget> | ||
268 | </item> | ||
269 | </layout> | ||
270 | <zorder>buttonBox</zorder> | ||
271 | <zorder>execsBox</zorder> | ||
272 | <zorder>horizontalSpacer</zorder> | ||
273 | <zorder>verticalSpacer</zorder> | ||
274 | <zorder>groupBox2</zorder> | ||
275 | </widget> | ||
276 | <tabstops> | ||
277 | <tabstop>serverPath</tabstop> | ||
278 | <tabstop>serverButton</tabstop> | ||
279 | <tabstop>clientPath</tabstop> | ||
280 | <tabstop>clientButton</tabstop> | ||
281 | <tabstop>refreshButton</tabstop> | ||
282 | <tabstop>voicesBox</tabstop> | ||
283 | <tabstop>buttonBox</tabstop> | ||
284 | </tabstops> | ||
285 | <resources> | ||
286 | <include location="rbutilqt.qrc" /> | ||
287 | </resources> | ||
288 | <connections> | ||
289 | <connection> | ||
290 | <sender>buttonBox</sender> | ||
291 | <signal>accepted()</signal> | ||
292 | <receiver>TTSFestivalCfgFrm</receiver> | ||
293 | <slot>accept()</slot> | ||
294 | <hints> | ||
295 | <hint type="sourcelabel" > | ||
296 | <x>248</x> | ||
297 | <y>254</y> | ||
298 | </hint> | ||
299 | <hint type="destinationlabel" > | ||
300 | <x>157</x> | ||
301 | <y>274</y> | ||
302 | </hint> | ||
303 | </hints> | ||
304 | </connection> | ||
305 | <connection> | ||
306 | <sender>buttonBox</sender> | ||
307 | <signal>rejected()</signal> | ||
308 | <receiver>TTSFestivalCfgFrm</receiver> | ||
309 | <slot>reject()</slot> | ||
310 | <hints> | ||
311 | <hint type="sourcelabel" > | ||
312 | <x>316</x> | ||
313 | <y>260</y> | ||
314 | </hint> | ||
315 | <hint type="destinationlabel" > | ||
316 | <x>286</x> | ||
317 | <y>274</y> | ||
318 | </hint> | ||
319 | </hints> | ||
320 | </connection> | ||
321 | </connections> | ||
322 | </ui> | ||
diff --git a/rbutil/rbutilqt/ttsgui.cpp b/rbutil/rbutilqt/ttsgui.cpp deleted file mode 100644 index ead32f17c3..0000000000 --- a/rbutil/rbutilqt/ttsgui.cpp +++ /dev/null | |||
@@ -1,341 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id$ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "ttsgui.h" | ||
21 | |||
22 | #include "rbsettings.h" | ||
23 | #include "tts.h" | ||
24 | #include "browsedirtree.h" | ||
25 | |||
26 | TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent) | ||
27 | { | ||
28 | m_sapi= sapi; | ||
29 | ui.setupUi(this); | ||
30 | this->hide(); | ||
31 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); | ||
32 | connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString))); | ||
33 | connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int))); | ||
34 | } | ||
35 | |||
36 | void TTSSapiGui::showCfg() | ||
37 | { | ||
38 | // try to get config from settings | ||
39 | ui.ttsoptions->setText(settings->subValue("sapi", RbSettings::TtsOptions).toString()); | ||
40 | QString selLang = settings->subValue("sapi", RbSettings::TtsLanguage).toString(); | ||
41 | QString selVoice = settings->subValue("sapi", RbSettings::TtsVoice).toString(); | ||
42 | ui.speed->setValue(settings->subValue("sapi", RbSettings::TtsSpeed).toInt()); | ||
43 | if(settings->value(RbSettings::TtsUseSapi4).toBool()) | ||
44 | ui.usesapi4->setCheckState(Qt::Checked); | ||
45 | else | ||
46 | ui.usesapi4->setCheckState(Qt::Unchecked); | ||
47 | |||
48 | // fill in language combobox | ||
49 | QStringList languages = settings->languages(); | ||
50 | |||
51 | languages.sort(); | ||
52 | ui.languagecombo->clear(); | ||
53 | ui.languagecombo->addItems(languages); | ||
54 | |||
55 | // set saved lang | ||
56 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang)); | ||
57 | |||
58 | // fill in voice combobox | ||
59 | updateVoices(selLang); | ||
60 | |||
61 | // set saved lang | ||
62 | ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice)); | ||
63 | |||
64 | //show dialog | ||
65 | this->exec(); | ||
66 | |||
67 | } | ||
68 | |||
69 | |||
70 | void TTSSapiGui::reset() | ||
71 | { | ||
72 | ui.ttsoptions->setText(""); | ||
73 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english")); | ||
74 | } | ||
75 | |||
76 | |||
77 | |||
78 | void TTSSapiGui::accept(void) | ||
79 | { | ||
80 | //save settings in user config | ||
81 | settings->setSubValue("sapi", RbSettings::TtsOptions, ui.ttsoptions->text()); | ||
82 | settings->setSubValue("sapi", RbSettings::TtsLanguage, ui.languagecombo->currentText()); | ||
83 | settings->setSubValue("sapi", RbSettings::TtsVoice, ui.voicecombo->currentText()); | ||
84 | settings->setSubValue("sapi", RbSettings::TtsSpeed, ui.speed->value()); | ||
85 | if(ui.usesapi4->checkState() == Qt::Checked) | ||
86 | settings->setValue(RbSettings::TtsUseSapi4, true); | ||
87 | else | ||
88 | settings->setValue(RbSettings::TtsUseSapi4, false); | ||
89 | // sync settings | ||
90 | settings->sync(); | ||
91 | |||
92 | this->done(0); | ||
93 | } | ||
94 | |||
95 | void TTSSapiGui::reject(void) | ||
96 | { | ||
97 | this->done(0); | ||
98 | } | ||
99 | |||
100 | void TTSSapiGui::updateVoices(QString language) | ||
101 | { | ||
102 | QStringList Voices = m_sapi->getVoiceList(language); | ||
103 | ui.voicecombo->clear(); | ||
104 | ui.voicecombo->addItems(Voices); | ||
105 | |||
106 | } | ||
107 | |||
108 | void TTSSapiGui::useSapi4Changed(int) | ||
109 | { | ||
110 | if(ui.usesapi4->checkState() == Qt::Checked) | ||
111 | settings->setValue(RbSettings::TtsUseSapi4, true); | ||
112 | else | ||
113 | settings->setValue(RbSettings::TtsUseSapi4, false); | ||
114 | // sync settings | ||
115 | settings->sync(); | ||
116 | updateVoices(ui.languagecombo->currentText()); | ||
117 | |||
118 | } | ||
119 | |||
120 | TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent) | ||
121 | { | ||
122 | ui.setupUi(this); | ||
123 | this->hide(); | ||
124 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); | ||
125 | connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse())); | ||
126 | } | ||
127 | |||
128 | |||
129 | void TTSExesGui::reset() | ||
130 | { | ||
131 | ui.ttspath->setText(""); | ||
132 | ui.ttsoptions->setText(""); | ||
133 | } | ||
134 | |||
135 | void TTSExesGui::showCfg(QString name) | ||
136 | { | ||
137 | m_name = name; | ||
138 | // try to get config from settings | ||
139 | QString exepath =settings->subValue(m_name, RbSettings::TtsPath).toString(); | ||
140 | ui.ttsoptions->setText(settings->subValue(m_name, RbSettings::TtsOptions).toString()); | ||
141 | ui.ttspath->setText(exepath); | ||
142 | |||
143 | //show dialog | ||
144 | this->exec(); | ||
145 | |||
146 | } | ||
147 | |||
148 | void TTSExesGui::accept(void) | ||
149 | { | ||
150 | //save settings in user config | ||
151 | settings->setSubValue(m_name, RbSettings::TtsPath, ui.ttspath->text()); | ||
152 | settings->setSubValue(m_name, RbSettings::TtsOptions, ui.ttsoptions->text()); | ||
153 | // sync settings | ||
154 | settings->sync(); | ||
155 | |||
156 | this->done(0); | ||
157 | } | ||
158 | |||
159 | void TTSExesGui::reject(void) | ||
160 | { | ||
161 | this->done(0); | ||
162 | } | ||
163 | |||
164 | |||
165 | void TTSExesGui::browse() | ||
166 | { | ||
167 | BrowseDirtree browser(this); | ||
168 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | ||
169 | |||
170 | if(QFileInfo(ui.ttspath->text()).isDir()) | ||
171 | { | ||
172 | browser.setDir(ui.ttspath->text()); | ||
173 | } | ||
174 | if(browser.exec() == QDialog::Accepted) | ||
175 | { | ||
176 | qDebug() << browser.getSelected(); | ||
177 | QString exe = browser.getSelected(); | ||
178 | if(!QFileInfo(exe).isExecutable()) | ||
179 | return; | ||
180 | ui.ttspath->setText(exe); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) : | ||
185 | QDialog(parent), festival(api) | ||
186 | { | ||
187 | ui.setupUi(this); | ||
188 | this->setModal(true); | ||
189 | this->setDisabled(true); | ||
190 | this->show(); | ||
191 | |||
192 | connect(ui.clientButton, SIGNAL(clicked()), this, SLOT(onBrowseClient())); | ||
193 | connect(ui.serverButton, SIGNAL(clicked()), this, SLOT(onBrowseServer())); | ||
194 | |||
195 | connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(onRefreshButton())); | ||
196 | connect(ui.voicesBox, SIGNAL(activated(QString)), this, SLOT(updateDescription(QString))); | ||
197 | connect(ui.showDescriptionCheckbox, SIGNAL(stateChanged(int)), this, SLOT(onShowDescription(int))); | ||
198 | } | ||
199 | |||
200 | void TTSFestivalGui::showCfg() | ||
201 | { | ||
202 | qDebug() << "show\tpaths: " << settings->subValue("festival", RbSettings::TtsPath) << "\n" | ||
203 | << "\tvoice: " << settings->subValue("festival", RbSettings::TtsVoice); | ||
204 | |||
205 | // will populate the voices if the paths are correct, | ||
206 | // otherwise, it will require the user to press Refresh | ||
207 | updateVoices(); | ||
208 | |||
209 | // try to get config from settings | ||
210 | QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":"); | ||
211 | if(paths.size() == 2) | ||
212 | { | ||
213 | ui.serverPath->setText(paths[0]); | ||
214 | ui.clientPath->setText(paths[1]); | ||
215 | } | ||
216 | |||
217 | this->setEnabled(true); | ||
218 | this->exec(); | ||
219 | } | ||
220 | |||
221 | void TTSFestivalGui::accept(void) | ||
222 | { | ||
223 | //save settings in user config | ||
224 | QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); | ||
225 | qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText(); | ||
226 | settings->setSubValue("festival", RbSettings::TtsPath, newPath); | ||
227 | settings->setSubValue("festival", RbSettings::TtsVoice, ui.voicesBox->currentText()); | ||
228 | |||
229 | settings->sync(); | ||
230 | |||
231 | this->done(0); | ||
232 | } | ||
233 | |||
234 | void TTSFestivalGui::reject(void) | ||
235 | { | ||
236 | this->done(0); | ||
237 | } | ||
238 | |||
239 | void TTSFestivalGui::onBrowseClient() | ||
240 | { | ||
241 | BrowseDirtree browser(this); | ||
242 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | ||
243 | |||
244 | QFileInfo currentPath(ui.clientPath->text().trimmed()); | ||
245 | if(currentPath.isDir()) | ||
246 | { | ||
247 | browser.setDir(ui.clientPath->text()); | ||
248 | } | ||
249 | else if (currentPath.isFile()) | ||
250 | { | ||
251 | browser.setDir(currentPath.dir().absolutePath()); | ||
252 | } | ||
253 | if(browser.exec() == QDialog::Accepted) | ||
254 | { | ||
255 | qDebug() << browser.getSelected(); | ||
256 | QString exe = browser.getSelected(); | ||
257 | if(!QFileInfo(exe).isExecutable()) | ||
258 | return; | ||
259 | ui.clientPath->setText(exe); | ||
260 | } | ||
261 | } | ||
262 | |||
263 | void TTSFestivalGui::onBrowseServer() | ||
264 | { | ||
265 | BrowseDirtree browser(this); | ||
266 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | ||
267 | |||
268 | QFileInfo currentPath(ui.serverPath->text().trimmed()); | ||
269 | if(currentPath.isDir()) | ||
270 | { | ||
271 | browser.setDir(ui.serverPath->text()); | ||
272 | } | ||
273 | else if (currentPath.isFile()) | ||
274 | { | ||
275 | browser.setDir(currentPath.dir().absolutePath()); | ||
276 | } | ||
277 | if(browser.exec() == QDialog::Accepted) | ||
278 | { | ||
279 | qDebug() << browser.getSelected(); | ||
280 | QString exe = browser.getSelected(); | ||
281 | if(!QFileInfo(exe).isExecutable()) | ||
282 | return; | ||
283 | ui.serverPath->setText(exe); | ||
284 | } | ||
285 | } | ||
286 | |||
287 | void TTSFestivalGui::onRefreshButton() | ||
288 | { | ||
289 | /* Temporarily commit the settings so that we get the new path when we check for voices */ | ||
290 | QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); | ||
291 | QString oldPath = settings->subValue("festival", RbSettings::TtsPath).toString(); | ||
292 | qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath); | ||
293 | |||
294 | if(newPath != oldPath) | ||
295 | { | ||
296 | qDebug() << "Using new paths for getVoiceList"; | ||
297 | settings->setSubValue("festival", RbSettings::TtsPath, newPath); | ||
298 | settings->sync(); | ||
299 | } | ||
300 | |||
301 | updateVoices(); | ||
302 | |||
303 | if(newPath != oldPath) | ||
304 | { | ||
305 | settings->setSubValue("festival", RbSettings::TtsPath, oldPath); | ||
306 | settings->sync(); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | void TTSFestivalGui::onShowDescription(int state) | ||
311 | { | ||
312 | if(state == Qt::Unchecked) | ||
313 | ui.descriptionLabel->setText(""); | ||
314 | else | ||
315 | updateDescription(ui.voicesBox->currentText()); | ||
316 | } | ||
317 | |||
318 | void TTSFestivalGui::updateVoices() | ||
319 | { | ||
320 | ui.voicesBox->clear(); | ||
321 | ui.voicesBox->addItem(tr("Loading..")); | ||
322 | |||
323 | QStringList voiceList = festival->getVoiceList(); | ||
324 | ui.voicesBox->clear(); | ||
325 | ui.voicesBox->addItems(voiceList); | ||
326 | |||
327 | ui.voicesBox->setCurrentIndex(ui.voicesBox->findText( | ||
328 | settings->subValue("festival", RbSettings::TtsVoice).toString())); | ||
329 | |||
330 | updateDescription(settings->subValue("festival", RbSettings::TtsVoice).toString()); | ||
331 | } | ||
332 | |||
333 | void TTSFestivalGui::updateDescription(QString value) | ||
334 | { | ||
335 | if(ui.showDescriptionCheckbox->checkState() == Qt::Checked) | ||
336 | { | ||
337 | ui.descriptionLabel->setText(tr("Querying festival")); | ||
338 | ui.descriptionLabel->setText(festival->getVoiceInfo(value)); | ||
339 | } | ||
340 | } | ||
341 | |||
diff --git a/rbutil/rbutilqt/ttsgui.h b/rbutil/rbutilqt/ttsgui.h deleted file mode 100644 index 693555cb6c..0000000000 --- a/rbutil/rbutilqt/ttsgui.h +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef TTSGUI_H | ||
23 | #define TTSGUI_H | ||
24 | |||
25 | #include <QtGui> | ||
26 | |||
27 | #include "ui_ttsexescfgfrm.h" | ||
28 | #include "ui_sapicfgfrm.h" | ||
29 | #include "ui_ttsfestivalcfgform.h" | ||
30 | |||
31 | class RbSettings; | ||
32 | class TTSSapi; | ||
33 | class TTSFestival; | ||
34 | |||
35 | class TTSSapiGui : public QDialog | ||
36 | { | ||
37 | Q_OBJECT | ||
38 | public: | ||
39 | TTSSapiGui(TTSSapi* sapi,QDialog* parent = NULL); | ||
40 | |||
41 | void showCfg(); | ||
42 | void setCfg(RbSettings* sett){settings = sett;} | ||
43 | public slots: | ||
44 | |||
45 | virtual void accept(void); | ||
46 | virtual void reject(void); | ||
47 | virtual void reset(void); | ||
48 | void updateVoices(QString language); | ||
49 | void useSapi4Changed(int); | ||
50 | private: | ||
51 | Ui::SapiCfgFrm ui; | ||
52 | RbSettings* settings; | ||
53 | TTSSapi* m_sapi; | ||
54 | }; | ||
55 | |||
56 | class TTSExesGui : public QDialog | ||
57 | { | ||
58 | Q_OBJECT | ||
59 | public: | ||
60 | TTSExesGui(QDialog* parent = NULL); | ||
61 | |||
62 | void showCfg(QString m_name); | ||
63 | void setCfg(RbSettings* sett){settings = sett;} | ||
64 | |||
65 | public slots: | ||
66 | virtual void accept(void); | ||
67 | virtual void reject(void); | ||
68 | virtual void reset(void); | ||
69 | void browse(void); | ||
70 | private: | ||
71 | Ui::TTSExesCfgFrm ui; | ||
72 | RbSettings* settings; | ||
73 | QString m_name; | ||
74 | }; | ||
75 | |||
76 | class TTSFestivalGui : public QDialog | ||
77 | { | ||
78 | Q_OBJECT | ||
79 | public: | ||
80 | TTSFestivalGui(TTSFestival* festival, QDialog* parent = NULL); | ||
81 | |||
82 | void showCfg(); | ||
83 | void setCfg(RbSettings* sett){settings = sett;} | ||
84 | |||
85 | public slots: | ||
86 | virtual void accept(void); | ||
87 | virtual void reject(void); | ||
88 | //virtual void reset(void); | ||
89 | |||
90 | void onRefreshButton(); | ||
91 | void onShowDescription(int state); | ||
92 | void onBrowseServer(); | ||
93 | void onBrowseClient(); | ||
94 | private: | ||
95 | Ui::TTSFestivalCfgFrm ui; | ||
96 | RbSettings* settings; | ||
97 | TTSFestival* festival; | ||
98 | |||
99 | void updateVoices(); | ||
100 | private slots: | ||
101 | void updateDescription(QString value); | ||
102 | }; | ||
103 | |||
104 | #endif | ||
105 | |||
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp index 14af9adb24..c38977af96 100644 --- a/rbutil/rbutilqt/voicefile.cpp +++ b/rbutil/rbutilqt/voicefile.cpp | |||
@@ -128,7 +128,7 @@ void VoiceFileCreator::downloadDone(bool error) | |||
128 | } | 128 | } |
129 | 129 | ||
130 | //tts | 130 | //tts |
131 | m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString()); | 131 | m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString()); |
132 | m_tts->setCfg(settings); | 132 | m_tts->setCfg(settings); |
133 | 133 | ||
134 | QString errStr; | 134 | QString errStr; |
@@ -142,7 +142,7 @@ void VoiceFileCreator::downloadDone(bool error) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | // Encoder | 144 | // Encoder |
145 | m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString()); | 145 | m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString()); |
146 | m_enc->setCfg(settings); | 146 | m_enc->setCfg(settings); |
147 | 147 | ||
148 | if(!m_enc->start()) | 148 | if(!m_enc->start()) |
diff --git a/rbutil/rbutilqt/voicefile.h b/rbutil/rbutilqt/voicefile.h index 39205db756..1a5d267b1f 100644 --- a/rbutil/rbutilqt/voicefile.h +++ b/rbutil/rbutilqt/voicefile.h | |||
@@ -38,7 +38,7 @@ class VoiceFileCreator :public QObject | |||
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | VoiceFileCreator(QObject* parent=0); | 41 | VoiceFileCreator(QObject* parent); |
42 | 42 | ||
43 | //start creation | 43 | //start creation |
44 | bool createVoiceFile(ProgressloggerInterface* logger); | 44 | bool createVoiceFile(ProgressloggerInterface* logger); |