diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2007-08-05 16:17:35 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2007-08-05 16:17:35 +0000 |
commit | e70f7f4ca857e9e88a6e076360b6c9c235d7739b (patch) | |
tree | c5528e6abc91f74ac14192f9f2844f856588fdc0 /rbutil/rbutilqt/installtalkwindow.cpp | |
parent | 1d9f693658fda6e76d6c473fce8aa42b07f1b898 (diff) |
rbutilQt: added Talkfile creation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14197 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/installtalkwindow.cpp')
-rw-r--r-- | rbutil/rbutilqt/installtalkwindow.cpp | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp new file mode 100644 index 0000000000..4d1cdb1491 --- /dev/null +++ b/rbutil/rbutilqt/installtalkwindow.cpp @@ -0,0 +1,264 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id: installtalkwindow.cpp 14151 2007-08-02 22:27:51Z bluebrother $ + * + * 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" + +InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent) +{ + ui.setupUi(this); + talkcreator = new TalkFileCreator(this); + + connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder())); + connect(ui.buttonBrowseTTS, SIGNAL(clicked()), this, SLOT(browseTTS())); + connect(ui.buttonBrowseEncoder, SIGNAL(clicked()), this, SLOT(browseEncoder())); + + connect(ui.Encodercbx,SIGNAL(currentIndexChanged(int)),this,SLOT(setEncoderOptions(int))); + connect(ui.TTScbx,SIGNAL(currentIndexChanged(int)),this,SLOT(setTTSOptions(int))); + + ui.OverwriteWav->setChecked(true); + ui.RemoveWav->setChecked(true); + ui.recursive->setChecked(true); + ui.OverwriteTalk->setChecked(true); + ui.StripExtensions->setChecked(true); + + +} + +void InstallTalkWindow::browseFolder() +{ + QFileDialog browser(this); + if(QFileInfo(ui.lineTalkFolder->text()).isDir()) + browser.setDirectory(ui.lineTalkFolder->text()); + else + browser.setDirectory("/media"); + browser.setReadOnly(true); + browser.setFileMode(QFileDialog::DirectoryOnly); + browser.setAcceptMode(QFileDialog::AcceptOpen); + if(browser.exec()) { + qDebug() << browser.directory(); + QStringList files = browser.selectedFiles(); + setTalkFolder(files.at(0)); + } +} + +void InstallTalkWindow::setTalkFolder(QString folder) +{ + ui.lineTalkFolder->clear(); + ui.lineTalkFolder->insert(folder); +} + +void InstallTalkWindow::browseTTS() +{ + QFileDialog browser(this); + if(QFileInfo(ui.TTSpath->text()).isDir()) + browser.setDirectory(ui.TTSpath->text()); + else + browser.setDirectory("/media"); + browser.setReadOnly(true); + browser.setFileMode(QFileDialog::ExistingFile); + browser.setAcceptMode(QFileDialog::AcceptOpen); + if(browser.exec()) { + qDebug() << browser.directory(); + QStringList files = browser.selectedFiles(); + setTTSExec(files.at(0)); + } +} + +void InstallTalkWindow::setTTSExec(QString path) +{ + ui.TTSpath->clear(); + ui.TTSpath->insert(path); +} + +void InstallTalkWindow::browseEncoder() +{ + QFileDialog browser(this); + if(QFileInfo(ui.Encoderpath->text()).isDir()) + browser.setDirectory(ui.Encoderpath->text()); + else + browser.setDirectory("/media"); + browser.setReadOnly(true); + browser.setFileMode(QFileDialog::ExistingFile); + browser.setAcceptMode(QFileDialog::AcceptOpen); + if(browser.exec()) { + qDebug() << browser.directory(); + QStringList files = browser.selectedFiles(); + setEncoderExec(files.at(0)); + } +} + +void InstallTalkWindow::setEncoderExec(QString path) +{ + ui.Encoderpath->clear(); + ui.Encoderpath->insert(path); +} + +void InstallTalkWindow::setEncoderOptions(int index) +{ + QString options = talkcreator->getEncOpts(ui.Encodercbx->itemText(index)); + setEncoderOptions(options); +} +void InstallTalkWindow::setEncoderOptions(QString options) +{ + ui.EncoderOptions->clear(); + ui.EncoderOptions->insert(options); +} +void InstallTalkWindow::setTTSOptions(QString options) +{ + ui.TTSOptions->clear(); + ui.TTSOptions->insert(options); +} +void InstallTalkWindow::setTTSOptions(int index) +{ + QString options = talkcreator->getTTsOpts(ui.TTScbx->itemText(index)); + setEncoderOptions(options); +} + +void InstallTalkWindow::accept() +{ + logger = new ProgressLoggerGui(this); + logger->show(); + + QString folderToTalk = ui.lineTalkFolder->text(); + QString pathEncoder = ui.Encoderpath->text(); + QString pathTTS = ui.TTSpath->text(); + + if(!QFileInfo(folderToTalk).isDir()) + { + logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR); + logger->abort(); + return; + } + + if(!QFileInfo(pathEncoder).exists()) + { + logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR); + logger->abort(); + return; + } + + if(!QFileInfo(pathTTS).exists()) + { + logger->addItem(tr("Path to TTS is wrong!"),LOGERROR); + logger->abort(); + return; + } + + userSettings->setValue("defaults/folderToTalk",folderToTalk); + userSettings->setValue("defaults/pathEncoder",pathEncoder); + userSettings->setValue("defaults/pathTTS",pathTTS); + + userSettings->sync(); + + talkcreator->setDir(folderToTalk); + talkcreator->setTTSexe(pathTTS); + talkcreator->setEncexe(pathEncoder); + talkcreator->setEncOpts(ui.EncoderOptions->text()); + talkcreator->setTTsOpts(ui.TTSOptions->text()); + talkcreator->setTTsType(ui.TTScbx->currentText()); + talkcreator->setEncType(ui.Encodercbx->currentText()); + + 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; + + QStringList encoders; + QStringList encodersOpts; + QStringList encodersTemplates; + + QStringList tts; + QStringList ttsOpts; + QStringList ttsTemplates; + + devices->beginGroup("encoders"); + QStringList keys = devices->allKeys(); + qDebug() << keys; + for(int i=0; i < keys.size();i++) + { + encoders << devices->value(keys.at(i),"null").toString(); + } + qDebug() << encoders; + devices->endGroup(); + for(int i=0; i < encoders.size();i++) + { + devices->beginGroup(encoders.at(i)); + encodersOpts << devices->value("options","null").toString(); + encodersTemplates << devices->value("template","null").toString(); + devices->endGroup(); + } + qDebug() << encodersOpts; + qDebug() << encodersTemplates; + + devices->beginGroup("tts"); + keys = devices->allKeys(); + qDebug() << keys; + for(int i=0; i < keys.size();i++) + { + tts << devices->value(keys.at(i),"null").toString(); + } + qDebug() << tts; + devices->endGroup(); + for(int i= 0; i < tts.size();i++) + { + devices->beginGroup(tts.at(i)); + ttsOpts << devices->value("options","null").toString(); + ttsTemplates << devices->value("template","null").toString(); + devices->endGroup(); + } + qDebug() << ttsOpts; + qDebug() << ttsTemplates; + + talkcreator->setSupportedEnc(encoders); + talkcreator->setSupportedEncOptions(encodersOpts); + talkcreator->setSupportedEncTemplates(encodersTemplates); + + talkcreator->setSupportedTTS(tts); + talkcreator->setSupportedTTSOptions(ttsOpts); + talkcreator->setSupportedTTSTemplates(ttsTemplates); + + ui.Encodercbx->insertItems(0,talkcreator->getSupportedEnc()); + ui.TTScbx->insertItems(0,talkcreator->getSupportedTTS()); + +} + + + + +void InstallTalkWindow::setUserSettings(QSettings *user) +{ + userSettings = user; + + + + setTalkFolder(userSettings->value("defaults/folderToTalk").toString()); + setEncoderExec(userSettings->value("defaults/pathEncoder").toString()); + setTTSExec(userSettings->value("defaults/pathTTS").toString()); +} |