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"
26 #include "systeminfo.h"
28 CreateVoiceWindow::CreateVoiceWindow(QWidget
*parent
) : QDialog(parent
)
31 voicecreator
= new VoiceFileCreator(this);
33 connect(ui
.change
,SIGNAL(clicked()),this,SLOT(change()));
36 void CreateVoiceWindow::change()
38 // save window settings
41 // call configuration dialog
42 Config
*cw
= new Config(this,4);
43 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
47 void CreateVoiceWindow::accept()
49 logger
= new ProgressLoggerGui(this);
50 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
55 //configure voicecreator
56 voicecreator
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
57 voicecreator
->setLang(ui
.comboLanguage
->currentText());
58 voicecreator
->setWavtrimThreshold(ui
.wavtrimthreshold
->value());
61 connect(voicecreator
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
62 connect(voicecreator
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
63 connect(voicecreator
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
64 connect(logger
,SIGNAL(aborted()),voicecreator
,SLOT(abort()));
65 voicecreator
->createVoiceFile();
69 /** @brief update displayed settings
71 void CreateVoiceWindow::updateSettings(void)
73 // fill in language combobox
74 QStringList languages
= SystemInfo::languages();
76 ui
.comboLanguage
->addItems(languages
);
78 int sel
= ui
.comboLanguage
->findText(RbSettings::value(RbSettings::VoiceLanguage
).toString());
79 // if no saved language is found try to figure the language from the UI lang
81 QString f
= RbSettings::value(RbSettings::Language
).toString();
82 // if no language is set default to english. Make sure not to check an empty string.
83 if(f
.isEmpty()) f
= "english";
84 sel
= ui
.comboLanguage
->findText(f
, Qt::MatchStartsWith
);
85 qDebug() << "sel =" << sel
;
86 // still nothing found?
88 sel
= ui
.comboLanguage
->findText("english", Qt::MatchStartsWith
);
90 ui
.comboLanguage
->setCurrentIndex(sel
);
92 QString ttsName
= RbSettings::value(RbSettings::Tts
).toString();
93 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
95 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
96 .arg(TTSBase::getTTSName(ttsName
)));
98 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
99 .arg("Invalid TTS configuration!"));
101 QString encoder
= SystemInfo::value(SystemInfo::CurEncoder
).toString();
102 // only proceed if encoder setting is set
103 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
106 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
107 .arg(EncBase::getEncoderName(encoder
)));
109 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
110 .arg("Invalid encoder configuration!"));
113 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
114 .arg("Invalid encoder configuration!"));
115 ui
.wavtrimthreshold
->setValue(RbSettings::value(RbSettings::WavtrimThreshold
).toInt());
116 emit
settingsUpdated();
120 /** @brief save options
122 void CreateVoiceWindow::saveSettings(void)
124 // save selected language
125 RbSettings::setValue(RbSettings::VoiceLanguage
,
126 ui
.comboLanguage
->currentText());
127 // save wavtrim threshold value
128 RbSettings::setValue(RbSettings::WavtrimThreshold
,
129 ui
.wavtrimthreshold
->value());