summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/ttsgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/ttsgui.cpp')
-rw-r--r--rbutil/rbutilqt/ttsgui.cpp341
1 files changed, 0 insertions, 341 deletions
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
26TTSSapiGui::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
36void 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
70void TTSSapiGui::reset()
71{
72 ui.ttsoptions->setText("");
73 ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english"));
74}
75
76
77
78void 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
95void TTSSapiGui::reject(void)
96{
97 this->done(0);
98}
99
100void TTSSapiGui::updateVoices(QString language)
101{
102 QStringList Voices = m_sapi->getVoiceList(language);
103 ui.voicecombo->clear();
104 ui.voicecombo->addItems(Voices);
105
106}
107
108void 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
120TTSExesGui::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
129void TTSExesGui::reset()
130{
131 ui.ttspath->setText("");
132 ui.ttsoptions->setText("");
133}
134
135void 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
148void 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
159void TTSExesGui::reject(void)
160{
161 this->done(0);
162}
163
164
165void 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
184TTSFestivalGui::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
200void 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
221void 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
234void TTSFestivalGui::reject(void)
235{
236 this->done(0);
237}
238
239void 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
263void 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
287void 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
310void TTSFestivalGui::onShowDescription(int state)
311{
312 if(state == Qt::Unchecked)
313 ui.descriptionLabel->setText("");
314 else
315 updateDescription(ui.voicesBox->currentText());
316}
317
318void 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
333void 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