1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: tts.cpp 15212 2007-10-19 21:49:07Z domonoky $
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "rbsettings.h"
24 #include "browsedirtree.h"
26 TTSSapiGui::TTSSapiGui(TTSSapi
* sapi
,QDialog
* parent
) : QDialog(parent
)
31 connect(ui
.reset
,SIGNAL(clicked()),this,SLOT(reset()));
32 connect(ui
.languagecombo
,SIGNAL(currentIndexChanged(QString
)),this,SLOT(updateVoices(QString
)));
36 void TTSSapiGui::showCfg()
38 // try to get config from settings
39 ui
.ttsoptions
->setText(settings
->ttsOptions("sapi"));
40 QString selLang
= settings
->ttsLang("sapi");
41 QString selVoice
= settings
->ttsVoice("sapi");
42 ui
.speed
->setValue(settings
->ttsSpeed("sapi"));
45 // fill in language combobox
46 QStringList languages
= settings
->allLanguages();
49 ui
.languagecombo
->clear();
50 ui
.languagecombo
->addItems(languages
);
53 ui
.languagecombo
->setCurrentIndex(ui
.languagecombo
->findText(selLang
));
55 // fill in voice combobox
56 updateVoices(selLang
);
59 ui
.voicecombo
->setCurrentIndex(ui
.voicecombo
->findText(selVoice
));
67 void TTSSapiGui::reset()
69 ui
.ttsoptions
->setText("");
70 ui
.languagecombo
->setCurrentIndex(ui
.languagecombo
->findText("english"));
75 void TTSSapiGui::accept(void)
77 //save settings in user config
78 settings
->setTTSOptions("sapi",ui
.ttsoptions
->text());
79 settings
->setTTSLang("sapi",ui
.languagecombo
->currentText());
80 settings
->setTTSVoice("sapi",ui
.voicecombo
->currentText());
81 settings
->setTTSSpeed("sapi",ui
.speed
->value());
88 void TTSSapiGui::reject(void)
93 void TTSSapiGui::updateVoices(QString language
)
95 QStringList Voices
= m_sapi
->getVoiceList(language
);
96 ui
.voicecombo
->clear();
97 ui
.voicecombo
->addItems(Voices
);
101 TTSExesGui::TTSExesGui(QDialog
* parent
) : QDialog(parent
)
105 connect(ui
.reset
,SIGNAL(clicked()),this,SLOT(reset()));
106 connect(ui
.browse
,SIGNAL(clicked()),this,SLOT(browse()));
110 void TTSExesGui::reset()
112 ui
.ttspath
->setText("");
113 ui
.ttsoptions
->setText("");
116 void TTSExesGui::showCfg(QString name
)
119 // try to get config from settings
120 QString exepath
=settings
->ttsPath(m_name
);
121 ui
.ttsoptions
->setText(settings
->ttsOptions(m_name
));
127 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
128 QStringList path
= QString(getenv("PATH")).split(":", QString::SkipEmptyParts
);
129 #elif defined(Q_OS_WIN)
130 QStringList path
= QString(getenv("PATH")).split(";", QString::SkipEmptyParts
);
133 for(int i
= 0; i
< path
.size(); i
++)
135 QString executable
= QDir::fromNativeSeparators(path
.at(i
)) + "/" + m_name
;
136 #if defined(Q_OS_WIN)
137 executable
+= ".exe";
138 QStringList ex
= executable
.split("\"", QString::SkipEmptyParts
);
139 executable
= ex
.join("");
141 qDebug() << executable
;
142 if(QFileInfo(executable
).isExecutable())
144 exepath
= QDir::toNativeSeparators(executable
);
151 ui
.ttspath
->setText(exepath
);
158 void TTSExesGui::accept(void)
160 //save settings in user config
161 settings
->setTTSPath(m_name
,ui
.ttspath
->text());
162 settings
->setTTSOptions(m_name
,ui
.ttsoptions
->text());
169 void TTSExesGui::reject(void)
175 void TTSExesGui::browse()
177 BrowseDirtree
browser(this);
178 browser
.setFilter(QDir::Dirs
| QDir::Files
| QDir::NoDotAndDotDot
);
180 if(QFileInfo(ui
.ttspath
->text()).isDir())
182 browser
.setDir(ui
.ttspath
->text());
184 if(browser
.exec() == QDialog::Accepted
)
186 qDebug() << browser
.getSelected();
187 QString exe
= browser
.getSelected();
188 if(!QFileInfo(exe
).isExecutable())
190 ui
.ttspath
->setText(exe
);