rbutil: improve talkfile generation. remove the options to keep and overwrite the...
[kugel-rb.git] / rbutil / rbutilqt / installtalkwindow.cpp
blob16b3b83f21a04c34ede63f6c3b7320f48744d2d5
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 "installtalkwindow.h"
21 #include "ui_installtalkfrm.h"
23 #include "browsedirtree.h"
24 #include "configure.h"
26 InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
28 ui.setupUi(this);
29 talkcreator = new TalkFileCreator(this);
31 connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
32 connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
34 ui.recursive->setChecked(true);
35 ui.OverwriteTalk->setChecked(true);
36 ui.StripExtensions->setChecked(true);
39 void InstallTalkWindow::browseFolder()
41 BrowseDirtree browser(this);
42 browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
44 if(QFileInfo(ui.lineTalkFolder->text()).isDir())
46 browser.setDir(ui.lineTalkFolder->text());
48 else
50 browser.setDir("/media"); // FIXME: This looks Linux specific
52 if(browser.exec() == QDialog::Accepted)
54 qDebug() << browser.getSelected();
55 setTalkFolder(browser.getSelected());
59 void InstallTalkWindow::setTalkFolder(QString folder)
61 ui.lineTalkFolder->setText(folder);
64 void InstallTalkWindow::change()
66 Config *cw = new Config(this,4);
67 cw->setSettings(settings);
69 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
71 cw->show();
74 void InstallTalkWindow::accept()
76 logger = new ProgressLoggerGui(this);
78 connect(logger,SIGNAL(closed()),this,SLOT(close()));
79 logger->show();
82 QString folderToTalk = ui.lineTalkFolder->text();
84 if(!QFileInfo(folderToTalk).isDir())
86 logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
87 logger->abort();
88 return;
91 settings->setLastTalkedDir(folderToTalk);
93 settings->sync();
95 talkcreator->setSettings(settings);
96 talkcreator->setDir(QDir(folderToTalk));
97 talkcreator->setMountPoint(settings->mountpoint());
99 talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
100 talkcreator->setOverwriteWav(true);
101 talkcreator->setRemoveWav(true);
102 talkcreator->setRecursive(ui.recursive->isChecked());
103 talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
104 talkcreator->setTalkFolders(ui.talkFolders->isChecked());
105 talkcreator->setTalkFiles(ui.talkFiles->isChecked());
107 talkcreator->createTalkFiles(logger);
111 void InstallTalkWindow::setSettings(RbSettings* sett)
113 settings = sett;
114 updateSettings();
118 void InstallTalkWindow::updateSettings(void)
120 QString ttsName = settings->curTTS();
121 TTSBase* tts = TTSBase::getTTS(ttsName);
122 tts->setCfg(settings);
123 if(tts->configOk())
124 ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(TTSBase::getTTSName(ttsName)));
125 else
126 ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
128 QString encoder = settings->curEncoder();
129 EncBase* enc = EncBase::getEncoder(encoder);
130 if(enc != NULL) {
131 enc->setCfg(settings);
132 if(enc->configOk())
133 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder)));
134 else
135 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
137 else
138 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
140 setTalkFolder(settings->lastTalkedFolder());
141 emit settingsUpdated();