Let qmake generate an install Makefile target to install the binary. Doesn't handle...
[Rockbox.git] / rbutil / rbutilqt / createvoicewindow.cpp
blob66819aedd6c72604f733be5f0c0c7284d3a70a77
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id: createvoicewindow.cpp 15932 2007-12-15 13:13:57Z 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 ****************************************************************************/
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>").arg(TTSBase::getTTSName(ttsName)));
105 else
106 ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
108 QString encoder = settings->curEncoder();
109 // only proceed if encoder setting is set
110 EncBase* enc = EncBase::getEncoder(encoder);
111 if(enc != NULL) {
112 enc->setCfg(settings);
113 if(enc->configOk())
114 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder)));
115 else
116 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
118 else
119 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
120 ui.wavtrimthreshold->setValue(settings->wavtrimTh());
121 emit settingsUpdated();