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-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-08-28 23:10:42 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
ui.OverwriteWav->setChecked(true);
|
|
|
|
ui.RemoveWav->setChecked(true);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallTalkWindow::accept()
|
|
|
|
{
|
|
|
|
logger = new ProgressLoggerGui(this);
|
|
|
|
logger->show();
|
2007-08-29 21:46:12 +00:00
|
|
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
QString folderToTalk = ui.lineTalkFolder->text();
|
2007-09-23 13:35:45 +00:00
|
|
|
|
|
|
|
// tts
|
|
|
|
QString preset = userSettings->value("ttspreset").toString();
|
|
|
|
userSettings->beginGroup(preset);
|
|
|
|
QString pathTTS = userSettings->value("binary").toString();
|
|
|
|
QString ttsOpts = userSettings->value("options").toString();
|
|
|
|
QString ttsLanguage = userSettings->value("language").toString();
|
|
|
|
QString ttsTemplate = userSettings->value("template").toString();
|
|
|
|
QString ttsType =userSettings->value("type").toString();
|
|
|
|
userSettings->endGroup();
|
|
|
|
|
|
|
|
//encoder
|
|
|
|
QString encoderPreset = userSettings->value("encpreset").toString();
|
|
|
|
userSettings->beginGroup(encoderPreset);
|
|
|
|
QString pathEncoder = userSettings->value("binary").toString();
|
|
|
|
QString encOpts = userSettings->value("options").toString();
|
|
|
|
QString encTemplate = userSettings->value("template").toString();
|
|
|
|
QString encType =userSettings->value("type").toString();
|
|
|
|
userSettings->endGroup();
|
|
|
|
|
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
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
if(!QFileInfo(pathEncoder).isExecutable())
|
2007-08-05 16:17:35 +00:00
|
|
|
{
|
2007-09-23 13:35:45 +00:00
|
|
|
logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-09-23 13:35:45 +00:00
|
|
|
if(!QFileInfo(pathTTS).exists())
|
2007-08-05 16:17:35 +00:00
|
|
|
{
|
|
|
|
logger->addItem(tr("Path to TTS is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
userSettings->setValue("last_talked_folder", folderToTalk);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
userSettings->sync();
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2007-10-19 21:49:07 +00:00
|
|
|
talkcreator->setDir(QDir(folderToTalk));
|
|
|
|
talkcreator->setMountPoint(userSettings->value("mountpoint").toString());
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setTTSexe(pathTTS);
|
2007-09-23 13:35:45 +00:00
|
|
|
talkcreator->setTTsOpts(ttsOpts);
|
|
|
|
talkcreator->setTTsLanguage(ttsLanguage);
|
|
|
|
talkcreator->setTTsType(ttsType);
|
|
|
|
talkcreator->setTTsTemplate(ttsTemplate);
|
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setEncexe(pathEncoder);
|
2007-09-23 13:35:45 +00:00
|
|
|
talkcreator->setEncOpts(encOpts);
|
|
|
|
talkcreator->setEncTemplate(encTemplate);
|
|
|
|
talkcreator->setEncType(encType);
|
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
|
|
|
|
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
|
|
|
|
talkcreator->setRemoveWav(ui.RemoveWav->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());
|
2007-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
talkcreator->createTalkFiles(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallTalkWindow::setDeviceSettings(QSettings *dev)
|
|
|
|
{
|
|
|
|
devices = dev;
|
|
|
|
qDebug() << "Install::setDeviceSettings:" << devices;
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
QString profile;
|
2007-08-31 13:00:50 +00:00
|
|
|
|
|
|
|
profile = userSettings->value("ttspreset", "none").toString();
|
2007-08-05 16:17:35 +00:00
|
|
|
devices->beginGroup("tts");
|
2007-08-28 23:10:42 +00:00
|
|
|
ui.labelTtsProfile->setText(tr("TTS Profile: <b>%1</b>")
|
|
|
|
.arg(devices->value(profile, tr("Invalid TTS profile!")).toString()));
|
|
|
|
qDebug() << profile;
|
|
|
|
devices->endGroup();
|
2007-08-31 13:00:50 +00:00
|
|
|
profile = userSettings->value("encpreset", "none").toString();
|
2007-08-28 23:10:42 +00:00
|
|
|
devices->beginGroup("encoders");
|
|
|
|
ui.labelEncProfile->setText(tr("Encoder Profile: <b>%1</b>")
|
|
|
|
.arg(devices->value(profile, tr("Invalid encoder profile!")).toString()));
|
|
|
|
qDebug() << profile;
|
2007-08-05 16:17:35 +00:00
|
|
|
devices->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InstallTalkWindow::setUserSettings(QSettings *user)
|
|
|
|
{
|
|
|
|
userSettings = user;
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
setTalkFolder(userSettings->value("last_talked_folder").toString());
|
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|