2007-08-05 16:17:35 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
2007-08-23 22:11:50 +00:00
|
|
|
* $Id$
|
2007-08-05 16:17:35 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "installtalkwindow.h"
|
|
|
|
#include "ui_installtalkfrm.h"
|
|
|
|
|
2007-08-07 17:49:35 +00:00
|
|
|
#include "browsedirtree.h"
|
2007-12-14 19:49:11 +00:00
|
|
|
#include "configure.h"
|
2007-08-07 17:49:35 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
talkcreator = new TalkFileCreator(this);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
|
2007-12-14 19:49:11 +00:00
|
|
|
connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
ui.recursive->setChecked(true);
|
|
|
|
ui.OverwriteTalk->setChecked(true);
|
|
|
|
ui.StripExtensions->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstallTalkWindow::browseFolder()
|
|
|
|
{
|
2007-08-07 17:49:35 +00:00
|
|
|
BrowseDirtree browser(this);
|
|
|
|
browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
if(QFileInfo(ui.lineTalkFolder->text()).isDir())
|
2007-08-07 17:49:35 +00:00
|
|
|
{
|
2007-09-14 20:10:54 +00:00
|
|
|
browser.setDir(ui.lineTalkFolder->text());
|
2007-08-07 17:49:35 +00:00
|
|
|
}
|
2007-08-05 16:17:35 +00:00
|
|
|
else
|
2007-08-07 17:49:35 +00:00
|
|
|
{
|
2007-09-14 20:10:54 +00:00
|
|
|
browser.setDir("/media"); // FIXME: This looks Linux specific
|
2007-08-07 17:49:35 +00:00
|
|
|
}
|
|
|
|
if(browser.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
qDebug() << browser.getSelected();
|
|
|
|
setTalkFolder(browser.getSelected());
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstallTalkWindow::setTalkFolder(QString folder)
|
|
|
|
{
|
2007-08-28 23:10:42 +00:00
|
|
|
ui.lineTalkFolder->setText(folder);
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
|
2007-12-14 19:49:11 +00:00
|
|
|
void InstallTalkWindow::change()
|
|
|
|
{
|
|
|
|
Config *cw = new Config(this,4);
|
2008-01-25 00:12:25 +00:00
|
|
|
cw->setSettings(settings);
|
2008-04-06 19:50:38 +00:00
|
|
|
|
2008-03-14 18:27:39 +00:00
|
|
|
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2008-04-06 19:50:38 +00:00
|
|
|
|
|
|
|
cw->show();
|
2007-12-14 19:49:11 +00:00
|
|
|
}
|
2007-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
void InstallTalkWindow::accept()
|
|
|
|
{
|
|
|
|
logger = new ProgressLoggerGui(this);
|
2008-04-06 19:50:38 +00:00
|
|
|
|
2007-08-29 21:46:12 +00:00
|
|
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
2008-04-06 19:50:38 +00:00
|
|
|
logger->show();
|
|
|
|
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
QString folderToTalk = ui.lineTalkFolder->text();
|
2007-12-15 13:13:57 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
if(!QFileInfo(folderToTalk).isDir())
|
|
|
|
{
|
2007-09-23 13:35:45 +00:00
|
|
|
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
settings->setLastTalkedDir(folderToTalk);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
settings->sync();
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
talkcreator->setSettings(settings);
|
2007-10-19 21:49:07 +00:00
|
|
|
talkcreator->setDir(QDir(folderToTalk));
|
2008-01-25 00:12:25 +00:00
|
|
|
talkcreator->setMountPoint(settings->mountpoint());
|
2007-09-23 13:35:45 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
|
|
|
|
talkcreator->setRecursive(ui.recursive->isChecked());
|
|
|
|
talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
|
2007-10-12 15:52:04 +00:00
|
|
|
talkcreator->setTalkFolders(ui.talkFolders->isChecked());
|
|
|
|
talkcreator->setTalkFiles(ui.talkFiles->isChecked());
|
2008-05-27 20:02:25 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->createTalkFiles(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
void InstallTalkWindow::setSettings(RbSettings* sett)
|
2007-08-05 16:17:35 +00:00
|
|
|
{
|
2008-01-25 00:12:25 +00:00
|
|
|
settings = sett;
|
2008-03-14 18:27:39 +00:00
|
|
|
updateSettings();
|
2008-03-01 13:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-14 18:27:39 +00:00
|
|
|
void InstallTalkWindow::updateSettings(void)
|
2008-03-01 13:42:14 +00:00
|
|
|
{
|
2008-01-25 00:12:25 +00:00
|
|
|
QString ttsName = settings->curTTS();
|
2008-02-12 21:45:50 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(ttsName);
|
2008-01-25 00:12:25 +00:00
|
|
|
tts->setCfg(settings);
|
2007-12-15 13:13:57 +00:00
|
|
|
if(tts->configOk())
|
2008-07-05 22:14:15 +00:00
|
|
|
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
|
|
|
.arg(TTSBase::getTTSName(ttsName)));
|
2007-12-15 13:13:57 +00:00
|
|
|
else
|
2008-07-05 22:14:15 +00:00
|
|
|
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
|
|
|
.arg("Invalid TTS configuration!"));
|
2007-12-14 19:26:54 +00:00
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
QString encoder = settings->curEncoder();
|
2008-02-13 18:11:09 +00:00
|
|
|
EncBase* enc = EncBase::getEncoder(encoder);
|
2008-02-03 11:49:29 +00:00
|
|
|
if(enc != NULL) {
|
2008-02-02 21:34:39 +00:00
|
|
|
enc->setCfg(settings);
|
|
|
|
if(enc->configOk())
|
2008-07-05 22:14:15 +00:00
|
|
|
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
|
|
|
|
.arg(EncBase::getEncoderName(encoder)));
|
2008-02-02 21:34:39 +00:00
|
|
|
else
|
2008-07-05 22:14:15 +00:00
|
|
|
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
|
|
|
|
.arg("Invalid encoder configuration!"));
|
2008-02-02 21:34:39 +00:00
|
|
|
}
|
2007-12-14 19:26:54 +00:00
|
|
|
else
|
2008-07-05 22:14:15 +00:00
|
|
|
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
|
|
|
|
.arg("Invalid encoder configuration!"));
|
2008-02-02 21:34:39 +00:00
|
|
|
|
2008-01-25 00:12:25 +00:00
|
|
|
setTalkFolder(settings->lastTalkedFolder());
|
2008-03-14 18:27:39 +00:00
|
|
|
emit settingsUpdated();
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
2008-01-19 18:33:33 +00:00
|
|
|
|