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"
25 #include "rbsettings.h"
27 CreateVoiceWindow::CreateVoiceWindow(QWidget
*parent
) : QDialog(parent
)
30 voicecreator
= new VoiceFileCreator(this);
32 connect(ui
.change
,SIGNAL(clicked()),this,SLOT(change()));
35 void CreateVoiceWindow::change()
37 Config
*cw
= new Config(this,4);
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 RbSettings::setValue(RbSettings::Language
, lang
);
53 RbSettings::setValue(RbSettings::WavtrimThreshold
, wvThreshold
);
56 //configure voicecreator
57 voicecreator
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
58 voicecreator
->setLang(lang
);
59 voicecreator
->setWavtrimThreshold(wvThreshold
);
62 connect(voicecreator
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
63 connect(voicecreator
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
64 connect(voicecreator
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
65 connect(logger
,SIGNAL(aborted()),voicecreator
,SLOT(abort()));
66 voicecreator
->createVoiceFile();
70 /** @brief update displayed settings
72 void CreateVoiceWindow::updateSettings(void)
74 // fill in language combobox
75 QStringList languages
= RbSettings::languages();
77 ui
.comboLanguage
->addItems(languages
);
79 int sel
= ui
.comboLanguage
->findText(RbSettings::value(RbSettings::VoiceLanguage
).toString());
80 // if no saved language is found try to figure the language from the UI lang
82 QString f
= RbSettings::value(RbSettings::Language
).toString();
83 // if no language is set default to english. Make sure not to check an empty string.
84 if(f
.isEmpty()) f
= "english";
85 sel
= ui
.comboLanguage
->findText(f
, Qt::MatchStartsWith
);
86 qDebug() << "sel =" << sel
;
87 // still nothing found?
89 sel
= ui
.comboLanguage
->findText("english", Qt::MatchStartsWith
);
91 ui
.comboLanguage
->setCurrentIndex(sel
);
93 QString ttsName
= RbSettings::value(RbSettings::Tts
).toString();
94 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
96 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
97 .arg(TTSBase::getTTSName(ttsName
)));
99 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
100 .arg("Invalid TTS configuration!"));
102 QString encoder
= RbSettings::value(RbSettings::CurEncoder
).toString();
103 // only proceed if encoder setting is set
104 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
107 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
108 .arg(EncBase::getEncoderName(encoder
)));
110 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
111 .arg("Invalid encoder configuration!"));
114 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
115 .arg("Invalid encoder configuration!"));
116 ui
.wavtrimthreshold
->setValue(RbSettings::value(RbSettings::WavtrimThreshold
).toInt());
117 emit
settingsUpdated();