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);
|
|
|
|
|
|
|
|
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-08-05 16:17:35 +00:00
|
|
|
if(QFileInfo(ui.lineTalkFolder->text()).isDir())
|
2007-08-07 17:49:35 +00:00
|
|
|
{
|
|
|
|
QDir d(ui.lineTalkFolder->text());
|
|
|
|
browser.setDir(d);
|
|
|
|
}
|
2007-08-05 16:17:35 +00:00
|
|
|
else
|
2007-08-07 17:49:35 +00:00
|
|
|
{
|
|
|
|
QDir d("/media");
|
|
|
|
browser.setDir(d);
|
|
|
|
}
|
|
|
|
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-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
QString folderToTalk = ui.lineTalkFolder->text();
|
2007-08-28 23:10:42 +00:00
|
|
|
QString pathEncoder = userSettings->value("encbin").toString();
|
|
|
|
QString pathTTS = userSettings->value("ttsbin").toString();
|
2007-08-29 21:46:12 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
if(!QFileInfo(folderToTalk).isDir())
|
|
|
|
{
|
|
|
|
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
if(!QFileInfo(pathEncoder).isExecutable())
|
2007-08-05 16:17:35 +00:00
|
|
|
{
|
|
|
|
logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
if(!QFileInfo(pathTTS).isExecutable())
|
2007-08-05 16:17:35 +00:00
|
|
|
{
|
|
|
|
logger->addItem(tr("Path to TTS is wrong!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
userSettings->setValue("last_talked_folder", folderToTalk);
|
2007-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
userSettings->sync();
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setDir(folderToTalk);
|
|
|
|
talkcreator->setTTSexe(pathTTS);
|
|
|
|
talkcreator->setEncexe(pathEncoder);
|
2007-08-28 23:10:42 +00:00
|
|
|
talkcreator->setEncOpts(userSettings->value("encopts").toString());
|
|
|
|
talkcreator->setTTsOpts(userSettings->value("ttsopts").toString());
|
|
|
|
|
|
|
|
devices->beginGroup(userSettings->value("ttspreset").toString());
|
|
|
|
talkcreator->setTTsType(devices->value("tts").toString());
|
|
|
|
talkcreator->setTTsOpts(devices->value("options").toString());
|
|
|
|
talkcreator->setTTsTemplate(devices->value("template").toString());
|
|
|
|
devices->endGroup();
|
|
|
|
devices->beginGroup(userSettings->value("encpreset").toString());
|
|
|
|
talkcreator->setEncType(devices->value("encoder").toString());
|
|
|
|
talkcreator->setEncOpts(devices->value("options").toString());
|
|
|
|
talkcreator->setEncTemplate(devices->value("template").toString());
|
|
|
|
devices->endGroup();
|
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());
|
|
|
|
|
|
|
|
talkcreator->createTalkFiles(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallTalkWindow::setDeviceSettings(QSettings *dev)
|
|
|
|
{
|
|
|
|
devices = dev;
|
|
|
|
qDebug() << "Install::setDeviceSettings:" << devices;
|
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
QString profile;
|
2007-08-05 16:17:35 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
profile = userSettings->value("ttspreset").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();
|
|
|
|
profile = userSettings->value("encpreset").toString();
|
|
|
|
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-08-10 22:17:43 +00:00
|
|
|
talkcreator->setMountPoint(userSettings->value("defaults/mountpoint").toString());
|
2007-08-05 16:17:35 +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
|
|
|
}
|