Fix case in the constant
[maemo-rb.git] / rbutil / rbutilqt / installtalkwindow.cpp
blob6277313d3a8ae2c1592302febf20e9467121690e
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"
25 #include "rbsettings.h"
27 InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
29 ui.setupUi(this);
30 talkcreator = new TalkFileCreator(this);
32 connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
33 connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
35 ui.recursive->setChecked(true);
36 ui.OverwriteTalk->setChecked(true);
37 ui.StripExtensions->setChecked(true);
39 updateSettings();
42 void InstallTalkWindow::browseFolder()
44 BrowseDirtree browser(this);
45 browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
47 if(QFileInfo(ui.lineTalkFolder->text()).isDir())
49 browser.setDir(ui.lineTalkFolder->text());
51 else
53 browser.setDir("/media"); // FIXME: This looks Linux specific
55 if(browser.exec() == QDialog::Accepted)
57 qDebug() << browser.getSelected();
58 setTalkFolder(browser.getSelected());
62 void InstallTalkWindow::setTalkFolder(QString folder)
64 ui.lineTalkFolder->setText(folder);
67 void InstallTalkWindow::change()
69 Config *cw = new Config(this,4);
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->setFinished();
90 return;
93 RbSettings::setValue(RbSettings::LastTalkedFolder, folderToTalk);
95 RbSettings::sync();
97 talkcreator->setDir(QDir(folderToTalk));
98 talkcreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
100 talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
101 talkcreator->setRecursive(ui.recursive->isChecked());
102 talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
103 talkcreator->setTalkFolders(ui.talkFolders->isChecked());
104 talkcreator->setTalkFiles(ui.talkFiles->isChecked());
106 talkcreator->createTalkFiles(logger);
110 void InstallTalkWindow::updateSettings(void)
112 QString ttsName = RbSettings::value(RbSettings::Tts).toString();
113 TTSBase* tts = TTSBase::getTTS(this,ttsName);
114 if(tts->configOk())
115 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
116 .arg(TTSBase::getTTSName(ttsName)));
117 else
118 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
119 .arg("Invalid TTS configuration!"));
121 QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
122 EncBase* enc = EncBase::getEncoder(this,encoder);
123 if(enc != NULL) {
124 if(enc->configOk())
125 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
126 .arg(EncBase::getEncoderName(encoder)));
127 else
128 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
129 .arg("Invalid encoder configuration!"));
131 else
132 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
133 .arg("Invalid encoder configuration!"));
135 setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString());
136 emit settingsUpdated();