2008-01-11 23:59:12 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
|
|
|
*
|
|
|
|
* 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 "createvoicewindow.h"
|
|
|
|
#include "ui_createvoicefrm.h"
|
|
|
|
|
|
|
|
#include "configure.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
#include "systeminfo.h"
|
2008-01-11 23:59:12 +00:00
|
|
|
|
|
|
|
CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
voicecreator = new VoiceFileCreator(this);
|
2009-05-09 20:04:08 +00:00
|
|
|
updateSettings();
|
2008-01-11 23:59:12 +00:00
|
|
|
connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVoiceWindow::change()
|
|
|
|
{
|
2010-02-28 11:06:49 +00:00
|
|
|
// save window settings
|
|
|
|
saveSettings();
|
|
|
|
|
|
|
|
// call configuration dialog
|
2008-01-11 23:59:12 +00:00
|
|
|
Config *cw = new Config(this,4);
|
2008-03-14 18:27:39 +00:00
|
|
|
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2008-04-06 19:50:38 +00:00
|
|
|
cw->show();
|
2008-01-11 23:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVoiceWindow::accept()
|
|
|
|
{
|
|
|
|
logger = new ProgressLoggerGui(this);
|
|
|
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
2008-04-06 19:50:38 +00:00
|
|
|
logger->show();
|
2010-02-28 11:06:49 +00:00
|
|
|
|
|
|
|
saveSettings();
|
2008-01-11 23:59:12 +00:00
|
|
|
|
|
|
|
//configure voicecreator
|
2009-05-09 16:59:14 +00:00
|
|
|
voicecreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
|
2012-05-19 14:49:48 +00:00
|
|
|
voicecreator->setLang(ui.comboLanguage->itemData(ui.comboLanguage->currentIndex()).toString());
|
2010-02-28 11:06:49 +00:00
|
|
|
voicecreator->setWavtrimThreshold(ui.wavtrimthreshold->value());
|
2008-01-11 23:59:12 +00:00
|
|
|
|
|
|
|
//start creating
|
2009-06-26 20:40:51 +00:00
|
|
|
connect(voicecreator, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(voicecreator, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(voicecreator, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(logger,SIGNAL(aborted()),voicecreator,SLOT(abort()));
|
|
|
|
voicecreator->createVoiceFile();
|
2008-01-11 23:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-01 13:42:14 +00:00
|
|
|
/** @brief update displayed settings
|
|
|
|
*/
|
2008-03-14 18:27:39 +00:00
|
|
|
void CreateVoiceWindow::updateSettings(void)
|
2008-03-01 13:42:14 +00:00
|
|
|
{
|
2008-01-11 23:59:12 +00:00
|
|
|
// fill in language combobox
|
2012-05-19 14:49:48 +00:00
|
|
|
QMap<QString, QStringList> languages = SystemInfo::languages();
|
2011-02-04 23:28:34 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < languages.keys().size(); i++) {
|
|
|
|
QString key = languages.keys().at(i);
|
2012-05-19 14:49:48 +00:00
|
|
|
ui.comboLanguage->addItem(languages.value(key).at(1), languages.value(key).at(0));
|
2011-02-04 23:28:34 +00:00
|
|
|
}
|
2008-01-11 23:59:12 +00:00
|
|
|
// set saved lang
|
2012-05-19 14:49:48 +00:00
|
|
|
int sel = ui.comboLanguage->findData(
|
2011-02-04 23:28:34 +00:00
|
|
|
RbSettings::value(RbSettings::VoiceLanguage).toString());
|
2008-02-03 20:04:34 +00:00
|
|
|
// if no saved language is found try to figure the language from the UI lang
|
|
|
|
if(sel == -1) {
|
2012-05-19 14:49:48 +00:00
|
|
|
QString uilang = RbSettings::value(RbSettings::Language).toString();
|
2008-02-03 20:04:34 +00:00
|
|
|
// if no language is set default to english. Make sure not to check an empty string.
|
2012-05-19 14:49:48 +00:00
|
|
|
QString f = "english";
|
|
|
|
if(!uilang.isEmpty() && languages.contains(uilang)) {
|
|
|
|
f = languages.value(uilang).at(0);
|
|
|
|
}
|
2011-02-04 23:28:34 +00:00
|
|
|
sel = ui.comboLanguage->findData(f);
|
2012-05-19 14:49:48 +00:00
|
|
|
qDebug() << "[CreateVoiceWindow] Selected language index:" << sel;
|
2008-02-03 20:04:34 +00:00
|
|
|
}
|
|
|
|
ui.comboLanguage->setCurrentIndex(sel);
|
2011-02-04 23:28:34 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
QString ttsName = RbSettings::value(RbSettings::Tts).toString();
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
2012-10-06 10:42:20 +00:00
|
|
|
if(!tts)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("TTS error"),
|
|
|
|
tr("The selected TTS failed to initialize. You can't use this TTS."));
|
|
|
|
return;
|
|
|
|
}
|
2008-01-11 23:59:12 +00:00
|
|
|
if(tts->configOk())
|
2012-06-13 20:42:32 +00:00
|
|
|
ui.labelTtsProfile->setText(tr("Engine: <b>%1</b>")
|
2008-07-05 22:14:15 +00:00
|
|
|
.arg(TTSBase::getTTSName(ttsName)));
|
2008-01-11 23:59:12 +00:00
|
|
|
else
|
2012-06-13 20:42:32 +00:00
|
|
|
ui.labelTtsProfile->setText(tr("Engine: <b>%1</b>")
|
2008-07-05 22:14:15 +00:00
|
|
|
.arg("Invalid TTS configuration!"));
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
ui.wavtrimthreshold->setValue(RbSettings::value(RbSettings::WavtrimThreshold).toInt());
|
2008-03-14 18:27:39 +00:00
|
|
|
emit settingsUpdated();
|
2008-01-11 23:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-28 11:06:49 +00:00
|
|
|
/** @brief save options
|
|
|
|
*/
|
|
|
|
void CreateVoiceWindow::saveSettings(void)
|
|
|
|
{
|
|
|
|
// save selected language
|
|
|
|
RbSettings::setValue(RbSettings::VoiceLanguage,
|
2012-05-19 14:49:48 +00:00
|
|
|
ui.comboLanguage->itemData(ui.comboLanguage->currentIndex()).toString());
|
2010-02-28 11:06:49 +00:00
|
|
|
// save wavtrim threshold value
|
|
|
|
RbSettings::setValue(RbSettings::WavtrimThreshold,
|
|
|
|
ui.wavtrimthreshold->value());
|
|
|
|
RbSettings::sync();
|
|
|
|
}
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
void CreateVoiceWindow::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
ui.retranslateUi(this);
|
2011-10-04 18:30:27 +00:00
|
|
|
updateSettings();
|
2011-10-02 14:30:05 +00:00
|
|
|
} else {
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|