diff options
Diffstat (limited to 'rbutil/rbutilqt/ttsgui.cpp')
-rw-r--r-- | rbutil/rbutilqt/ttsgui.cpp | 235 |
1 files changed, 118 insertions, 117 deletions
diff --git a/rbutil/rbutilqt/ttsgui.cpp b/rbutil/rbutilqt/ttsgui.cpp index 45dd3a86ef..cd4dab1fcf 100644 --- a/rbutil/rbutilqt/ttsgui.cpp +++ b/rbutil/rbutilqt/ttsgui.cpp | |||
@@ -16,13 +16,13 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "ttsgui.h" | 20 | #include "ttsgui.h" |
21 | 21 | ||
22 | #include "rbsettings.h" | 22 | #include "rbsettings.h" |
23 | #include "tts.h" | 23 | #include "tts.h" |
24 | #include "browsedirtree.h" | 24 | #include "browsedirtree.h" |
25 | 25 | ||
26 | TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent) | 26 | TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent) |
27 | { | 27 | { |
28 | m_sapi= sapi; | 28 | m_sapi= sapi; |
@@ -31,46 +31,46 @@ TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent) | |||
31 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); | 31 | connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset())); |
32 | connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString))); | 32 | connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString))); |
33 | connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int))); | 33 | connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int))); |
34 | } | 34 | } |
35 | 35 | ||
36 | void TTSSapiGui::showCfg() | 36 | void TTSSapiGui::showCfg() |
37 | { | 37 | { |
38 | // try to get config from settings | 38 | // try to get config from settings |
39 | ui.ttsoptions->setText(settings->ttsOptions("sapi")); | 39 | ui.ttsoptions->setText(settings->ttsOptions("sapi")); |
40 | QString selLang = settings->ttsLang("sapi"); | 40 | QString selLang = settings->ttsLang("sapi"); |
41 | QString selVoice = settings->ttsVoice("sapi"); | 41 | QString selVoice = settings->ttsVoice("sapi"); |
42 | ui.speed->setValue(settings->ttsSpeed("sapi")); | 42 | ui.speed->setValue(settings->ttsSpeed("sapi")); |
43 | if(settings->ttsUseSapi4()) | 43 | if(settings->ttsUseSapi4()) |
44 | ui.usesapi4->setCheckState(Qt::Checked); | 44 | ui.usesapi4->setCheckState(Qt::Checked); |
45 | else | 45 | else |
46 | ui.usesapi4->setCheckState(Qt::Unchecked); | 46 | ui.usesapi4->setCheckState(Qt::Unchecked); |
47 | 47 | ||
48 | // fill in language combobox | 48 | // fill in language combobox |
49 | QStringList languages = settings->allLanguages(); | 49 | QStringList languages = settings->allLanguages(); |
50 | 50 | ||
51 | languages.sort(); | 51 | languages.sort(); |
52 | ui.languagecombo->clear(); | 52 | ui.languagecombo->clear(); |
53 | ui.languagecombo->addItems(languages); | 53 | ui.languagecombo->addItems(languages); |
54 | 54 | ||
55 | // set saved lang | 55 | // set saved lang |
56 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang)); | 56 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang)); |
57 | 57 | ||
58 | // fill in voice combobox | 58 | // fill in voice combobox |
59 | updateVoices(selLang); | 59 | updateVoices(selLang); |
60 | 60 | ||
61 | // set saved lang | 61 | // set saved lang |
62 | ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice)); | 62 | ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice)); |
63 | 63 | ||
64 | //show dialog | 64 | //show dialog |
65 | this->exec(); | 65 | this->exec(); |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | void TTSSapiGui::reset() | 70 | void TTSSapiGui::reset() |
71 | { | 71 | { |
72 | ui.ttsoptions->setText(""); | 72 | ui.ttsoptions->setText(""); |
73 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english")); | 73 | ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english")); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
@@ -101,7 +101,7 @@ void TTSSapiGui::updateVoices(QString language) | |||
101 | { | 101 | { |
102 | QStringList Voices = m_sapi->getVoiceList(language); | 102 | QStringList Voices = m_sapi->getVoiceList(language); |
103 | ui.voicecombo->clear(); | 103 | ui.voicecombo->clear(); |
104 | ui.voicecombo->addItems(Voices); | 104 | ui.voicecombo->addItems(Voices); |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
@@ -114,7 +114,7 @@ void TTSSapiGui::useSapi4Changed(int) | |||
114 | // sync settings | 114 | // sync settings |
115 | settings->sync(); | 115 | settings->sync(); |
116 | updateVoices(ui.languagecombo->currentText()); | 116 | updateVoices(ui.languagecombo->currentText()); |
117 | 117 | ||
118 | } | 118 | } |
119 | 119 | ||
120 | TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent) | 120 | TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent) |
@@ -129,7 +129,7 @@ TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent) | |||
129 | void TTSExesGui::reset() | 129 | void TTSExesGui::reset() |
130 | { | 130 | { |
131 | ui.ttspath->setText(""); | 131 | ui.ttspath->setText(""); |
132 | ui.ttsoptions->setText(""); | 132 | ui.ttsoptions->setText(""); |
133 | } | 133 | } |
134 | 134 | ||
135 | void TTSExesGui::showCfg(QString name) | 135 | void TTSExesGui::showCfg(QString name) |
@@ -137,12 +137,12 @@ void TTSExesGui::showCfg(QString name) | |||
137 | m_name = name; | 137 | m_name = name; |
138 | // try to get config from settings | 138 | // try to get config from settings |
139 | QString exepath =settings->ttsPath(m_name); | 139 | QString exepath =settings->ttsPath(m_name); |
140 | ui.ttsoptions->setText(settings->ttsOptions(m_name)); | 140 | ui.ttsoptions->setText(settings->ttsOptions(m_name)); |
141 | ui.ttspath->setText(exepath); | 141 | ui.ttspath->setText(exepath); |
142 | 142 | ||
143 | //show dialog | 143 | //show dialog |
144 | this->exec(); | 144 | this->exec(); |
145 | 145 | ||
146 | } | 146 | } |
147 | 147 | ||
148 | void TTSExesGui::accept(void) | 148 | void TTSExesGui::accept(void) |
@@ -152,7 +152,7 @@ void TTSExesGui::accept(void) | |||
152 | settings->setTTSOptions(m_name,ui.ttsoptions->text()); | 152 | settings->setTTSOptions(m_name,ui.ttsoptions->text()); |
153 | // sync settings | 153 | // sync settings |
154 | settings->sync(); | 154 | settings->sync(); |
155 | 155 | ||
156 | this->done(0); | 156 | this->done(0); |
157 | } | 157 | } |
158 | 158 | ||
@@ -182,7 +182,7 @@ void TTSExesGui::browse() | |||
182 | } | 182 | } |
183 | 183 | ||
184 | TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) : | 184 | TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) : |
185 | QDialog(parent), festival(api) | 185 | QDialog(parent), festival(api) |
186 | { | 186 | { |
187 | ui.setupUi(this); | 187 | ui.setupUi(this); |
188 | this->setModal(true); | 188 | this->setModal(true); |
@@ -199,31 +199,31 @@ TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) : | |||
199 | 199 | ||
200 | void TTSFestivalGui::showCfg() | 200 | void TTSFestivalGui::showCfg() |
201 | { | 201 | { |
202 | qDebug() << "show\tpaths: " << settings->ttsPath("festival") << "\n" | 202 | qDebug() << "show\tpaths: " << settings->ttsPath("festival") << "\n" |
203 | << "\tvoice: " << settings->ttsVoice("festival"); | 203 | << "\tvoice: " << settings->ttsVoice("festival"); |
204 | 204 | ||
205 | // will populate the voices if the paths are correct, | 205 | // will populate the voices if the paths are correct, |
206 | // otherwise, it will require the user to press Refresh | 206 | // otherwise, it will require the user to press Refresh |
207 | updateVoices(); | 207 | updateVoices(); |
208 | 208 | ||
209 | // try to get config from settings | 209 | // try to get config from settings |
210 | QStringList paths = settings->ttsPath("festival").split(":"); | 210 | QStringList paths = settings->ttsPath("festival").split(":"); |
211 | if(paths.size() == 2) | 211 | if(paths.size() == 2) |
212 | { | 212 | { |
213 | ui.serverPath->setText(paths[0]); | 213 | ui.serverPath->setText(paths[0]); |
214 | ui.clientPath->setText(paths[1]); | 214 | ui.clientPath->setText(paths[1]); |
215 | } | 215 | } |
216 | 216 | ||
217 | this->setEnabled(true); | 217 | this->setEnabled(true); |
218 | this->exec(); | 218 | this->exec(); |
219 | } | 219 | } |
220 | 220 | ||
221 | void TTSFestivalGui::accept(void) | 221 | void TTSFestivalGui::accept(void) |
222 | { | 222 | { |
223 | //save settings in user config | 223 | //save settings in user config |
224 | QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); | 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(); | 225 | qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText(); |
226 | settings->setTTSPath("festival", newPath); | 226 | settings->setTTSPath("festival", newPath); |
227 | settings->setTTSVoice("festival", ui.voicesBox->currentText()); | 227 | settings->setTTSVoice("festival", ui.voicesBox->currentText()); |
228 | 228 | ||
229 | settings->sync(); | 229 | settings->sync(); |
@@ -238,102 +238,103 @@ void TTSFestivalGui::reject(void) | |||
238 | 238 | ||
239 | void TTSFestivalGui::onBrowseClient() | 239 | void TTSFestivalGui::onBrowseClient() |
240 | { | 240 | { |
241 | BrowseDirtree browser(this); | 241 | BrowseDirtree browser(this); |
242 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | 242 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); |
243 | 243 | ||
244 | QFileInfo currentPath(ui.clientPath->text().trimmed()); | 244 | QFileInfo currentPath(ui.clientPath->text().trimmed()); |
245 | if(currentPath.isDir()) | 245 | if(currentPath.isDir()) |
246 | { | 246 | { |
247 | browser.setDir(ui.clientPath->text()); | 247 | browser.setDir(ui.clientPath->text()); |
248 | } | 248 | } |
249 | else if (currentPath.isFile()) | 249 | else if (currentPath.isFile()) |
250 | { | 250 | { |
251 | browser.setDir(currentPath.dir().absolutePath()); | 251 | browser.setDir(currentPath.dir().absolutePath()); |
252 | } | 252 | } |
253 | if(browser.exec() == QDialog::Accepted) | 253 | if(browser.exec() == QDialog::Accepted) |
254 | { | 254 | { |
255 | qDebug() << browser.getSelected(); | 255 | qDebug() << browser.getSelected(); |
256 | QString exe = browser.getSelected(); | 256 | QString exe = browser.getSelected(); |
257 | if(!QFileInfo(exe).isExecutable()) | 257 | if(!QFileInfo(exe).isExecutable()) |
258 | return; | 258 | return; |
259 | ui.clientPath->setText(exe); | 259 | ui.clientPath->setText(exe); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | void TTSFestivalGui::onBrowseServer() | 263 | void TTSFestivalGui::onBrowseServer() |
264 | { | 264 | { |
265 | BrowseDirtree browser(this); | 265 | BrowseDirtree browser(this); |
266 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); | 266 | browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); |
267 | 267 | ||
268 | QFileInfo currentPath(ui.serverPath->text().trimmed()); | 268 | QFileInfo currentPath(ui.serverPath->text().trimmed()); |
269 | if(currentPath.isDir()) | 269 | if(currentPath.isDir()) |
270 | { | 270 | { |
271 | browser.setDir(ui.serverPath->text()); | 271 | browser.setDir(ui.serverPath->text()); |
272 | } | 272 | } |
273 | else if (currentPath.isFile()) | 273 | else if (currentPath.isFile()) |
274 | { | 274 | { |
275 | browser.setDir(currentPath.dir().absolutePath()); | 275 | browser.setDir(currentPath.dir().absolutePath()); |
276 | } | 276 | } |
277 | if(browser.exec() == QDialog::Accepted) | 277 | if(browser.exec() == QDialog::Accepted) |
278 | { | 278 | { |
279 | qDebug() << browser.getSelected(); | 279 | qDebug() << browser.getSelected(); |
280 | QString exe = browser.getSelected(); | 280 | QString exe = browser.getSelected(); |
281 | if(!QFileInfo(exe).isExecutable()) | 281 | if(!QFileInfo(exe).isExecutable()) |
282 | return; | 282 | return; |
283 | ui.serverPath->setText(exe); | 283 | ui.serverPath->setText(exe); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void TTSFestivalGui::onRefreshButton() | 287 | void TTSFestivalGui::onRefreshButton() |
288 | { | 288 | { |
289 | /* Temporarily commit the settings so that we get the new path when we check for voices */ | 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()); | 290 | QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed()); |
291 | QString oldPath = settings->ttsPath("festival"); | 291 | QString oldPath = settings->ttsPath("festival"); |
292 | qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath); | 292 | qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath); |
293 | 293 | ||
294 | if(newPath != oldPath) | 294 | if(newPath != oldPath) |
295 | { | 295 | { |
296 | qDebug() << "Using new paths for getVoiceList"; | 296 | qDebug() << "Using new paths for getVoiceList"; |
297 | settings->setTTSPath("festival", newPath); | 297 | settings->setTTSPath("festival", newPath); |
298 | settings->sync(); | 298 | settings->sync(); |
299 | } | 299 | } |
300 | 300 | ||
301 | updateVoices(); | 301 | updateVoices(); |
302 | 302 | ||
303 | if(newPath != oldPath) | 303 | if(newPath != oldPath) |
304 | { | 304 | { |
305 | settings->setTTSPath("festival", oldPath); | 305 | settings->setTTSPath("festival", oldPath); |
306 | settings->sync(); | 306 | settings->sync(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | void TTSFestivalGui::onShowDescription(int state) | 310 | void TTSFestivalGui::onShowDescription(int state) |
311 | { | 311 | { |
312 | if(state == Qt::Unchecked) | 312 | if(state == Qt::Unchecked) |
313 | ui.descriptionLabel->setText(""); | 313 | ui.descriptionLabel->setText(""); |
314 | else | 314 | else |
315 | updateDescription(ui.voicesBox->currentText()); | 315 | updateDescription(ui.voicesBox->currentText()); |
316 | } | 316 | } |
317 | 317 | ||
318 | void TTSFestivalGui::updateVoices() | 318 | void TTSFestivalGui::updateVoices() |
319 | { | 319 | { |
320 | ui.voicesBox->clear(); | 320 | ui.voicesBox->clear(); |
321 | ui.voicesBox->addItem(tr("Loading..")); | 321 | ui.voicesBox->addItem(tr("Loading..")); |
322 | 322 | ||
323 | QStringList voiceList = festival->getVoiceList(); | 323 | QStringList voiceList = festival->getVoiceList(); |
324 | ui.voicesBox->clear(); | 324 | ui.voicesBox->clear(); |
325 | ui.voicesBox->addItems(voiceList); | 325 | ui.voicesBox->addItems(voiceList); |
326 | 326 | ||
327 | ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(settings->ttsVoice("festival"))); | 327 | ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(settings->ttsVoice("festival"))); |
328 | 328 | ||
329 | updateDescription(settings->ttsVoice("festival")); | 329 | updateDescription(settings->ttsVoice("festival")); |
330 | } | 330 | } |
331 | 331 | ||
332 | void TTSFestivalGui::updateDescription(QString value) | 332 | void TTSFestivalGui::updateDescription(QString value) |
333 | { | 333 | { |
334 | if(ui.showDescriptionCheckbox->checkState() == Qt::Checked) | 334 | if(ui.showDescriptionCheckbox->checkState() == Qt::Checked) |
335 | { | 335 | { |
336 | ui.descriptionLabel->setText(tr("Querying festival")); | 336 | ui.descriptionLabel->setText(tr("Querying festival")); |
337 | ui.descriptionLabel->setText(festival->getVoiceInfo(value)); | 337 | ui.descriptionLabel->setText(festival->getVoiceInfo(value)); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | |||