(Maybe the first) correction of the order the album art images are searched. Also...
[kugel-rb.git] / rbutil / rbutilqt / createvoicewindow.cpp
blob01c9a256b72a2b8cd275c021e54d5a8399c3034d
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"
25 #include "rbsettings.h"
27 CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
29 ui.setupUi(this);
30 voicecreator = new VoiceFileCreator(this);
31 updateSettings();
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()));
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 RbSettings::setValue(RbSettings::Language, lang);
53 RbSettings::setValue(RbSettings::WavtrimThreshold, wvThreshold);
54 RbSettings::sync();
56 //configure voicecreator
57 voicecreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
58 voicecreator->setTargetId(RbSettings::value(RbSettings::CurTargetId).toInt());
59 voicecreator->setLang(lang);
60 voicecreator->setWavtrimThreshold(wvThreshold);
62 //start creating
63 voicecreator->createVoiceFile(logger);
67 /** @brief update displayed settings
69 void CreateVoiceWindow::updateSettings(void)
71 // fill in language combobox
72 QStringList languages = RbSettings::languages();
73 languages.sort();
74 ui.comboLanguage->addItems(languages);
75 // set saved lang
76 int sel = ui.comboLanguage->findText(RbSettings::value(RbSettings::VoiceLanguage).toString());
77 // if no saved language is found try to figure the language from the UI lang
78 if(sel == -1) {
79 QString f = RbSettings::value(RbSettings::Language).toString();
80 // if no language is set default to english. Make sure not to check an empty string.
81 if(f.isEmpty()) f = "english";
82 sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith);
83 qDebug() << "sel =" << sel;
84 // still nothing found?
85 if(sel == -1)
86 sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith);
88 ui.comboLanguage->setCurrentIndex(sel);
90 QString ttsName = RbSettings::value(RbSettings::Tts).toString();
91 TTSBase* tts = TTSBase::getTTS(this,ttsName);
92 if(tts->configOk())
93 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
94 .arg(TTSBase::getTTSName(ttsName)));
95 else
96 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
97 .arg("Invalid TTS configuration!"));
99 QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
100 // only proceed if encoder setting is set
101 EncBase* enc = EncBase::getEncoder(this,encoder);
102 if(enc != NULL) {
103 if(enc->configOk())
104 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
105 .arg(EncBase::getEncoderName(encoder)));
106 else
107 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
108 .arg("Invalid encoder configuration!"));
110 else
111 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
112 .arg("Invalid encoder configuration!"));
113 ui.wavtrimthreshold->setValue(RbSettings::value(RbSettings::WavtrimThreshold).toInt());
114 emit settingsUpdated();