Correct manual keymaps for plugins recently converted to PLA, and use manual PLA...
[maemo-rb.git] / rbutil / rbutilqt / createvoicewindow.cpp
blob7c2ff732c48ae7c937aec882d4c840a407a0c676
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"
26 #include "systeminfo.h"
28 CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
30 ui.setupUi(this);
31 voicecreator = new VoiceFileCreator(this);
32 updateSettings();
33 connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
36 void CreateVoiceWindow::change()
38 // save window settings
39 saveSettings();
41 // call configuration dialog
42 Config *cw = new Config(this,4);
43 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
44 cw->show();
47 void CreateVoiceWindow::accept()
49 logger = new ProgressLoggerGui(this);
50 connect(logger,SIGNAL(closed()),this,SLOT(close()));
51 logger->show();
53 saveSettings();
55 //configure voicecreator
56 voicecreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
57 voicecreator->setLang(ui.comboLanguage->currentText());
58 voicecreator->setWavtrimThreshold(ui.wavtrimthreshold->value());
60 //start creating
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();
75 languages.sort();
76 ui.comboLanguage->addItems(languages);
77 // set saved lang
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
80 if(sel == -1) {
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?
87 if(sel == -1)
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);
94 if(tts->configOk())
95 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
96 .arg(TTSBase::getTTSName(ttsName)));
97 else
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);
104 if(enc != NULL) {
105 if(enc->configOk())
106 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
107 .arg(EncBase::getEncoderName(encoder)));
108 else
109 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
110 .arg("Invalid encoder configuration!"));
112 else
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());
130 RbSettings::sync();