codec.link must be created with -DCODEC
[kugel-rb.git] / rbutil / rbutilqt / createvoicewindow.cpp
blobbb047cb196c1d69a58851e02fff746d912007ac0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
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 ****************************************************************************/
20 #include "createvoicewindow.h"
21 #include "ui_createvoicefrm.h"
23 #include "browsedirtree.h"
24 #include "configure.h"
26 CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
28 ui.setupUi(this);
29 voicecreator = new VoiceFileCreator(this);
31 connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
34 void CreateVoiceWindow::change()
36 Config *cw = new Config(this,4);
37 cw->setSettings(settings);
38 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
39 cw->show();
42 void CreateVoiceWindow::accept()
44 logger = new ProgressLoggerGui(this);
45 connect(logger,SIGNAL(closed()),this,SLOT(close()));
46 logger->show();
48 QString lang = ui.comboLanguage->currentText();
49 int wvThreshold = ui.wavtrimthreshold->value();
51 //safe selected language
52 settings->setVoiceLanguage(lang);
53 settings->setWavtrimTh(wvThreshold);
54 settings->sync();
56 //configure voicecreator
57 voicecreator->setSettings(settings);
58 voicecreator->setMountPoint(settings->mountpoint());
59 voicecreator->setTargetId(settings->curTargetId());
60 voicecreator->setLang(lang);
61 voicecreator->setWavtrimThreshold(wvThreshold);
63 //start creating
64 voicecreator->createVoiceFile(logger);
68 /** @brief set settings object
70 void CreateVoiceWindow::setSettings(RbSettings* sett)
72 settings = sett;
73 updateSettings();
77 /** @brief update displayed settings
79 void CreateVoiceWindow::updateSettings(void)
81 // fill in language combobox
82 QStringList languages = settings->allLanguages();
83 languages.sort();
84 ui.comboLanguage->addItems(languages);
85 // set saved lang
86 int sel = ui.comboLanguage->findText(settings->voiceLanguage());
87 // if no saved language is found try to figure the language from the UI lang
88 if(sel == -1) {
89 QString f = settings->curLang();
90 // if no language is set default to english. Make sure not to check an empty string.
91 if(f.isEmpty()) f = "english";
92 sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith);
93 qDebug() << "sel =" << sel;
94 // still nothing found?
95 if(sel == -1)
96 sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith);
98 ui.comboLanguage->setCurrentIndex(sel);
100 QString ttsName = settings->curTTS();
101 TTSBase* tts = TTSBase::getTTS(ttsName);
102 tts->setCfg(settings);
103 if(tts->configOk())
104 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
105 .arg(TTSBase::getTTSName(ttsName)));
106 else
107 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
108 .arg("Invalid TTS configuration!"));
110 QString encoder = settings->curEncoder();
111 // only proceed if encoder setting is set
112 EncBase* enc = EncBase::getEncoder(encoder);
113 if(enc != NULL) {
114 enc->setCfg(settings);
115 if(enc->configOk())
116 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
117 .arg(EncBase::getEncoderName(encoder)));
118 else
119 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
120 .arg("Invalid encoder configuration!"));
122 else
123 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
124 .arg("Invalid encoder configuration!"));
125 ui.wavtrimthreshold->setValue(settings->wavtrimTh());
126 emit settingsUpdated();