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"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.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);
|
2009-05-09 16:59:14 +00:00
|
|
|
|
|
|
|
updateSettings();
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2009-07-04 18:00:13 +00:00
|
|
|
|
|
|
|
// make sure the current selected folder doesn't get lost on settings
|
|
|
|
// changes. If the current selection is invalid don't accept it so
|
|
|
|
// it gets reset to the old value after closing the settings dialog.
|
|
|
|
QString folderToTalk = ui.lineTalkFolder->text();
|
|
|
|
if(QFileInfo(folderToTalk).isDir())
|
|
|
|
RbSettings::setValue(RbSettings::LastTalkedFolder, folderToTalk);
|
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);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-09-23 13:35:45 +00:00
|
|
|
return;
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::LastTalkedFolder, folderToTalk);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::sync();
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2007-10-19 21:49:07 +00:00
|
|
|
talkcreator->setDir(QDir(folderToTalk));
|
2009-05-09 16:59:14 +00:00
|
|
|
talkcreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
|
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
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
connect(talkcreator, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(talkcreator, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(talkcreator, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(logger,SIGNAL(aborted()),talkcreator,SLOT(abort()));
|
|
|
|
|
|
|
|
talkcreator->createTalkFiles();
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-14 18:27:39 +00:00
|
|
|
void InstallTalkWindow::updateSettings(void)
|
2008-03-01 13:42:14 +00:00
|
|
|
{
|
2009-05-09 16:59:14 +00:00
|
|
|
QString ttsName = RbSettings::value(RbSettings::Tts).toString();
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
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
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
|
2009-04-29 21:27:01 +00:00
|
|
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
2008-02-03 11:49:29 +00:00
|
|
|
if(enc != NULL) {
|
2008-02-02 21:34:39 +00:00
|
|
|
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
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString());
|
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
|
|
|
|