2008-01-29 21:54:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Wenger
|
2008-06-30 22:09:45 +00:00
|
|
|
* $Id$
|
2008-01-29 21:54:43 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "ttsgui.h"
|
|
|
|
|
|
|
|
#include "rbsettings.h"
|
|
|
|
#include "tts.h"
|
|
|
|
#include "browsedirtree.h"
|
|
|
|
|
|
|
|
TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
m_sapi= sapi;
|
|
|
|
ui.setupUi(this);
|
|
|
|
this->hide();
|
|
|
|
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
|
|
connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString)));
|
2008-02-11 17:39:07 +00:00
|
|
|
connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int)));
|
2008-01-29 21:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TTSSapiGui::showCfg()
|
|
|
|
{
|
|
|
|
// try to get config from settings
|
|
|
|
ui.ttsoptions->setText(settings->ttsOptions("sapi"));
|
|
|
|
QString selLang = settings->ttsLang("sapi");
|
|
|
|
QString selVoice = settings->ttsVoice("sapi");
|
|
|
|
ui.speed->setValue(settings->ttsSpeed("sapi"));
|
2008-02-11 17:39:07 +00:00
|
|
|
if(settings->ttsUseSapi4())
|
|
|
|
ui.usesapi4->setCheckState(Qt::Checked);
|
|
|
|
else
|
|
|
|
ui.usesapi4->setCheckState(Qt::Unchecked);
|
2008-01-29 21:54:43 +00:00
|
|
|
|
|
|
|
// fill in language combobox
|
|
|
|
QStringList languages = settings->allLanguages();
|
|
|
|
|
|
|
|
languages.sort();
|
|
|
|
ui.languagecombo->clear();
|
|
|
|
ui.languagecombo->addItems(languages);
|
|
|
|
|
|
|
|
// set saved lang
|
|
|
|
ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang));
|
|
|
|
|
|
|
|
// fill in voice combobox
|
|
|
|
updateVoices(selLang);
|
|
|
|
|
|
|
|
// set saved lang
|
|
|
|
ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice));
|
|
|
|
|
|
|
|
//show dialog
|
|
|
|
this->exec();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TTSSapiGui::reset()
|
|
|
|
{
|
|
|
|
ui.ttsoptions->setText("");
|
|
|
|
ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TTSSapiGui::accept(void)
|
|
|
|
{
|
|
|
|
//save settings in user config
|
|
|
|
settings->setTTSOptions("sapi",ui.ttsoptions->text());
|
|
|
|
settings->setTTSLang("sapi",ui.languagecombo->currentText());
|
|
|
|
settings->setTTSVoice("sapi",ui.voicecombo->currentText());
|
|
|
|
settings->setTTSSpeed("sapi",ui.speed->value());
|
2008-02-11 17:39:07 +00:00
|
|
|
if(ui.usesapi4->checkState() == Qt::Checked)
|
|
|
|
settings->setTTSUseSapi4(true);
|
|
|
|
else
|
|
|
|
settings->setTTSUseSapi4(false);
|
2008-01-29 21:54:43 +00:00
|
|
|
// sync settings
|
|
|
|
settings->sync();
|
2008-06-23 20:08:22 +00:00
|
|
|
|
|
|
|
this->done(0);
|
2008-01-29 21:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TTSSapiGui::reject(void)
|
|
|
|
{
|
2008-06-23 20:08:22 +00:00
|
|
|
this->done(0);
|
2008-01-29 21:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TTSSapiGui::updateVoices(QString language)
|
|
|
|
{
|
2008-06-23 20:08:22 +00:00
|
|
|
QStringList Voices = m_sapi->getVoiceList(language);
|
2008-01-29 21:54:43 +00:00
|
|
|
ui.voicecombo->clear();
|
|
|
|
ui.voicecombo->addItems(Voices);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-02-11 17:39:07 +00:00
|
|
|
void TTSSapiGui::useSapi4Changed(int)
|
|
|
|
{
|
|
|
|
if(ui.usesapi4->checkState() == Qt::Checked)
|
|
|
|
settings->setTTSUseSapi4(true);
|
|
|
|
else
|
|
|
|
settings->setTTSUseSapi4(false);
|
|
|
|
// sync settings
|
|
|
|
settings->sync();
|
|
|
|
updateVoices(ui.languagecombo->currentText());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:54:43 +00:00
|
|
|
TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
this->hide();
|
|
|
|
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
|
|
connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TTSExesGui::reset()
|
|
|
|
{
|
|
|
|
ui.ttspath->setText("");
|
|
|
|
ui.ttsoptions->setText("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TTSExesGui::showCfg(QString name)
|
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
// try to get config from settings
|
|
|
|
QString exepath =settings->ttsPath(m_name);
|
|
|
|
ui.ttsoptions->setText(settings->ttsOptions(m_name));
|
|
|
|
|
|
|
|
if(exepath == "")
|
|
|
|
{
|
|
|
|
|
|
|
|
//try autodetect tts
|
|
|
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
|
|
|
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
|
|
|
#elif defined(Q_OS_WIN)
|
|
|
|
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
|
|
|
#endif
|
|
|
|
qDebug() << path;
|
|
|
|
for(int i = 0; i < path.size(); i++)
|
|
|
|
{
|
|
|
|
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
executable += ".exe";
|
|
|
|
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
|
|
|
executable = ex.join("");
|
|
|
|
#endif
|
|
|
|
qDebug() << executable;
|
|
|
|
if(QFileInfo(executable).isExecutable())
|
|
|
|
{
|
|
|
|
exepath= QDir::toNativeSeparators(executable);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.ttspath->setText(exepath);
|
|
|
|
|
|
|
|
//show dialog
|
|
|
|
this->exec();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TTSExesGui::accept(void)
|
|
|
|
{
|
|
|
|
//save settings in user config
|
|
|
|
settings->setTTSPath(m_name,ui.ttspath->text());
|
|
|
|
settings->setTTSOptions(m_name,ui.ttsoptions->text());
|
|
|
|
// sync settings
|
|
|
|
settings->sync();
|
|
|
|
|
2008-06-23 20:08:22 +00:00
|
|
|
this->done(0);
|
2008-01-29 21:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TTSExesGui::reject(void)
|
|
|
|
{
|
2008-06-23 20:08:22 +00:00
|
|
|
this->done(0);
|
2008-01-29 21:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TTSExesGui::browse()
|
|
|
|
{
|
|
|
|
BrowseDirtree browser(this);
|
|
|
|
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
|
|
|
if(QFileInfo(ui.ttspath->text()).isDir())
|
|
|
|
{
|
|
|
|
browser.setDir(ui.ttspath->text());
|
|
|
|
}
|
|
|
|
if(browser.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
qDebug() << browser.getSelected();
|
|
|
|
QString exe = browser.getSelected();
|
|
|
|
if(!QFileInfo(exe).isExecutable())
|
|
|
|
return;
|
|
|
|
ui.ttspath->setText(exe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|