Make addItem() a slot to be able adding items using a signal.
[Rockbox.git] / rbutil / rbutilqt / installtalkwindow.cpp
blob1246d53876abcc43c7cecceb01699212f5834695
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.OverwriteWav->setChecked(true);
35 ui.RemoveWav->setChecked(true);
36 ui.recursive->setChecked(true);
37 ui.OverwriteTalk->setChecked(true);
38 ui.StripExtensions->setChecked(true);
41 void InstallTalkWindow::browseFolder()
43 BrowseDirtree browser(this);
44 browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
46 if(QFileInfo(ui.lineTalkFolder->text()).isDir())
48 browser.setDir(ui.lineTalkFolder->text());
50 else
52 browser.setDir("/media"); // FIXME: This looks Linux specific
54 if(browser.exec() == QDialog::Accepted)
56 qDebug() << browser.getSelected();
57 setTalkFolder(browser.getSelected());
61 void InstallTalkWindow::setTalkFolder(QString folder)
63 ui.lineTalkFolder->setText(folder);
66 void InstallTalkWindow::change()
68 Config *cw = new Config(this,4);
69 cw->setSettings(settings);
71 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
73 cw->show();
76 void InstallTalkWindow::accept()
78 logger = new ProgressLoggerGui(this);
80 connect(logger,SIGNAL(closed()),this,SLOT(close()));
81 logger->show();
84 QString folderToTalk = ui.lineTalkFolder->text();
86 if(!QFileInfo(folderToTalk).isDir())
88 logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
89 logger->abort();
90 return;
93 settings->setLastTalkedDir(folderToTalk);
95 settings->sync();
97 talkcreator->setSettings(settings);
98 talkcreator->setDir(QDir(folderToTalk));
99 talkcreator->setMountPoint(settings->mountpoint());
101 talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
102 talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
103 talkcreator->setRemoveWav(ui.RemoveWav->isChecked());
104 talkcreator->setRecursive(ui.recursive->isChecked());
105 talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
106 talkcreator->setTalkFolders(ui.talkFolders->isChecked());
107 talkcreator->setTalkFiles(ui.talkFiles->isChecked());
109 talkcreator->createTalkFiles(logger);
113 void InstallTalkWindow::setSettings(RbSettings* sett)
115 settings = sett;
116 updateSettings();
120 void InstallTalkWindow::updateSettings(void)
122 QString ttsName = settings->curTTS();
123 TTSBase* tts = TTSBase::getTTS(ttsName);
124 tts->setCfg(settings);
125 if(tts->configOk())
126 ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(TTSBase::getTTSName(ttsName)));
127 else
128 ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
130 QString encoder = settings->curEncoder();
131 EncBase* enc = EncBase::getEncoder(encoder);
132 if(enc != NULL) {
133 enc->setCfg(settings);
134 if(enc->configOk())
135 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder)));
136 else
137 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
139 else
140 ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
142 setTalkFolder(settings->lastTalkedFolder());
143 emit settingsUpdated();