1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
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
)
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()));
42 void CreateVoiceWindow::accept()
44 logger
= new ProgressLoggerGui(this);
45 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
48 QString lang
= ui
.comboLanguage
->currentText();
49 int wvThreshold
= ui
.wavtrimthreshold
->value();
51 //safe selected language
52 settings
->setVoiceLanguage(lang
);
53 settings
->setWavtrimTh(wvThreshold
);
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
);
64 voicecreator
->createVoiceFile(logger
);
68 /** @brief set settings object
70 void CreateVoiceWindow::setSettings(RbSettings
* sett
)
77 /** @brief update displayed settings
79 void CreateVoiceWindow::updateSettings(void)
81 // fill in language combobox
82 QStringList languages
= settings
->allLanguages();
84 ui
.comboLanguage
->addItems(languages
);
86 int sel
= ui
.comboLanguage
->findText(settings
->voiceLanguage());
87 // if no saved language is found try to figure the language from the UI lang
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?
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
);
104 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
105 .arg(TTSBase::getTTSName(ttsName
)));
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
);
114 enc
->setCfg(settings
);
116 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
117 .arg(EncBase::getEncoderName(encoder
)));
119 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
120 .arg("Invalid encoder configuration!"));
123 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
124 .arg("Invalid encoder configuration!"));
125 ui
.wavtrimthreshold
->setValue(settings
->wavtrimTh());
126 emit
settingsUpdated();