summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/utils.cpp29
-rw-r--r--rbutil/rbutilqt/base/utils.h1
-rw-r--r--rbutil/rbutilqt/configure.cpp30
-rw-r--r--rbutil/rbutilqt/createvoicewindow.cpp4
-rw-r--r--rbutil/rbutilqt/createvoicewindow.h2
-rw-r--r--rbutil/rbutilqt/encoders.cpp104
-rw-r--r--rbutil/rbutilqt/encoders.h84
-rw-r--r--rbutil/rbutilqt/encodersgui.cpp171
-rw-r--r--rbutil/rbutilqt/encodersgui.h79
-rw-r--r--rbutil/rbutilqt/encttscfggui.cpp361
-rw-r--r--rbutil/rbutilqt/encttscfggui.h78
-rw-r--r--rbutil/rbutilqt/encttssettings.cpp70
-rw-r--r--rbutil/rbutilqt/encttssettings.h129
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp4
-rw-r--r--rbutil/rbutilqt/rbspeexcfgfrm.ui171
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro13
-rw-r--r--rbutil/rbutilqt/sapicfgfrm.ui175
-rw-r--r--rbutil/rbutilqt/talkfile.cpp4
-rw-r--r--rbutil/rbutilqt/talkfile.h2
-rw-r--r--rbutil/rbutilqt/tts.cpp707
-rw-r--r--rbutil/rbutilqt/tts.h171
-rw-r--r--rbutil/rbutilqt/ttsexescfgfrm.ui158
-rw-r--r--rbutil/rbutilqt/ttsfestivalcfgform.ui322
-rw-r--r--rbutil/rbutilqt/ttsgui.cpp341
-rw-r--r--rbutil/rbutilqt/ttsgui.h105
-rw-r--r--rbutil/rbutilqt/voicefile.cpp4
-rw-r--r--rbutil/rbutilqt/voicefile.h2
27 files changed, 1283 insertions, 2038 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index 4b76c6497a..966ce335ea 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -130,6 +130,35 @@ qulonglong filesystemFree(QString path)
return size;
}
+//! \brief searches for a Executable in the Environement Path
+QString findExecutable(QString name)
+{
+ QString exepath;
+ //try autodetect tts
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
+ QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
+#elif defined(Q_OS_WIN)
+ QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
+#endif
+ qDebug() << path;
+ for(int i = 0; i < path.size(); i++)
+ {
+ QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + name;
+#if defined(Q_OS_WIN)
+ executable += ".exe";
+ QStringList ex = executable.split("\"", QString::SkipEmptyParts);
+ executable = ex.join("");
+#endif
+ qDebug() << executable;
+ if(QFileInfo(executable).isExecutable())
+ {
+ return QDir::toNativeSeparators(executable);
+ }
+ }
+ return "";
+}
+
+
RockboxInfo::RockboxInfo(QString mountpoint)
{
m_path = mountpoint +"/.rockbox/rockbox-info.txt";
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h
index caaf13eb41..49fca85df6 100644
--- a/rbutil/rbutilqt/base/utils.h
+++ b/rbutil/rbutilqt/base/utils.h
@@ -29,6 +29,7 @@
bool recRmdir( const QString &dirName );
QString resolvePathCase(QString path);
qulonglong filesystemFree(QString path);
+QString findExecutable(QString name);
class RockboxInfo
{
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 5731dbe78a..00a899abb4 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -27,6 +27,7 @@
#include "encoders.h"
#include "tts.h"
#include "detect.h"
+#include "encttscfggui.h"
#include <stdio.h>
#if defined(Q_OS_WIN32)
@@ -356,7 +357,7 @@ void Config::setDevices()
void Config::updateTtsState(int index)
{
QString ttsName = ui.comboTts->itemData(index).toString();
- TTSBase* tts = TTSBase::getTTS(ttsName);
+ TTSBase* tts = TTSBase::getTTS(this,ttsName);
tts->setCfg(settings);
if(tts->configOk())
@@ -386,7 +387,7 @@ void Config::updateEncState()
ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
settings->setValue(RbSettings::Platform, olddevice);
- EncBase* enc = EncBase::getEncoder(encoder);
+ EncBase* enc = EncBase::getEncoder(this,encoder);
enc->setCfg(settings);
if(enc->configOk())
@@ -666,19 +667,36 @@ void Config::cacheClear()
void Config::configTts()
{
int index = ui.comboTts->currentIndex();
- TTSBase* tts = TTSBase::getTTS(ui.comboTts->itemData(index).toString());
+ TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
tts->setCfg(settings);
- tts->showCfg();
+ EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(settings->value(RbSettings::Tts).toString()));
+ gui.exec();
updateTtsState(ui.comboTts->currentIndex());
}
void Config::configEnc()
{
- EncBase* enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
+ // FIXME: this is a workaround to make the encoder follow the device selection
+ // even with the settings (and thus the device) being saved. Needs to be redone
+ // properly later by extending the settings object
+ if(ui.treeDevices->selectedItems().size() == 0)
+ return;
+
+ QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
+ QString olddevice = settings->value(RbSettings::CurrentPlatform).toString();
+ settings->setValue(RbSettings::CurrentPlatform,devname);
+ QString encoder = settings->value(RbSettings::CurEncoder).toString();
+ ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
+ settings->setValue(RbSettings::CurrentPlatform,olddevice);
+
+
+ EncBase* enc = EncBase::getEncoder(this,encoder);
enc->setCfg(settings);
- enc->showCfg();
+ EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder));
+ gui.exec();
+
updateEncState();
}
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp
index 2b45386589..efd9f6a93f 100644
--- a/rbutil/rbutilqt/createvoicewindow.cpp
+++ b/rbutil/rbutilqt/createvoicewindow.cpp
@@ -98,7 +98,7 @@ void CreateVoiceWindow::updateSettings(void)
ui.comboLanguage->setCurrentIndex(sel);
QString ttsName = settings->value(RbSettings::Tts).toString();
- TTSBase* tts = TTSBase::getTTS(ttsName);
+ TTSBase* tts = TTSBase::getTTS(this,ttsName);
tts->setCfg(settings);
if(tts->configOk())
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
@@ -109,7 +109,7 @@ void CreateVoiceWindow::updateSettings(void)
QString encoder = settings->value(RbSettings::CurEncoder).toString();
// only proceed if encoder setting is set
- EncBase* enc = EncBase::getEncoder(encoder);
+ EncBase* enc = EncBase::getEncoder(this,encoder);
if(enc != NULL) {
enc->setCfg(settings);
if(enc->configOk())
diff --git a/rbutil/rbutilqt/createvoicewindow.h b/rbutil/rbutilqt/createvoicewindow.h
index 9384c85abc..ab98bf985b 100644
--- a/rbutil/rbutilqt/createvoicewindow.h
+++ b/rbutil/rbutilqt/createvoicewindow.h
@@ -33,7 +33,7 @@ class CreateVoiceWindow : public QDialog
{
Q_OBJECT
public:
- CreateVoiceWindow(QWidget *parent = 0);
+ CreateVoiceWindow(QWidget *parent);
void setSettings(RbSettings* sett);
void setProxy(QUrl proxy){m_proxy = proxy;}
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp
index a822b932f7..6ff1185c82 100644
--- a/rbutil/rbutilqt/encoders.cpp
+++ b/rbutil/rbutilqt/encoders.cpp
@@ -18,18 +18,17 @@
****************************************************************************/
#include "encoders.h"
+#include "utils.h"
-#ifndef CONSOLE
-#include "encodersgui.h"
-#include "browsedirtree.h"
-#else
-#include "encodersguicli.h"
-#endif
-
-
+/*********************************************************************
+* Encoder Base
+**********************************************************************/
QMap<QString,QString> EncBase::encoderList;
-QMap<QString,EncBase*> EncBase::encoderCache;
+EncBase::EncBase(QObject *parent): EncTtsSettingInterface(parent)
+{
+
+}
// initialize list of encoders
void EncBase::initEncodernamesList()
@@ -49,23 +48,17 @@ QString EncBase::getEncoderName(QString encoder)
// get a specific encoder object
-EncBase* EncBase::getEncoder(QString encoder)
+EncBase* EncBase::getEncoder(QObject* parent,QString encoder)
{
- // check cache
- if(encoderCache.contains(encoder))
- return encoderCache.value(encoder);
-
EncBase* enc;
if(encoder == "lame")
{
- enc = new EncExes(encoder);
- encoderCache[encoder] = enc;
+ enc = new EncExes(encoder,parent);
return enc;
}
else // rbspeex is default
{
- enc = new EncRbSpeex();
- encoderCache[encoder] = enc;
+ enc = new EncRbSpeex(parent);
return enc;
}
}
@@ -80,14 +73,6 @@ QStringList EncBase::getEncoderList()
/*********************************************************************
-* Encoder Base
-**********************************************************************/
-EncBase::EncBase(QObject *parent): QObject(parent)
-{
-
-}
-
-/*********************************************************************
* GEneral Exe Encoder
**********************************************************************/
EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
@@ -95,6 +80,25 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
m_name = name;
m_TemplateMap["lame"] = "\"%exe\" %options \"%input\" \"%output\"";
+
+}
+
+
+
+void EncExes::generateSettings()
+{
+ QString exepath =settings->subValue(m_name,RbSettings::EncoderPath).toString();
+ if(exepath == "") exepath = findExecutable(m_name);
+
+ insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Encoder:",exepath,EncTtsSetting::eBROWSEBTN));
+ insertSetting(eEXEOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Encoder options:",settings->subValue(m_name,RbSettings::EncoderOptions)));
+}
+
+void EncExes::saveSettings()
+{
+ settings->setSubValue(m_name,RbSettings::EncoderPath,getSetting(eEXEPATH)->current().toString());
+ settings->setSubValue(m_name,RbSettings::EncoderOptions,getSetting(eEXEOPTIONS)->current().toString());
+ settings->sync();
}
bool EncExes::start()
@@ -130,18 +134,6 @@ bool EncExes::encode(QString input,QString output)
}
-
-void EncExes::showCfg()
-{
-#ifndef CONSOLE
- EncExesGui gui;
-#else
- EncExesGuiCli gui;
-#endif
- gui.setCfg(settings);
- gui.showCfg(m_name);
-}
-
bool EncExes::configOk()
{
QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
@@ -152,20 +144,32 @@ bool EncExes::configOk()
return false;
}
-
-
/*********************************************************************
* RB SPEEX ENCODER
**********************************************************************/
EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent)
{
- defaultQuality = 8.f;
- defaultVolume = 1.f;
- defaultComplexity = 10;
- defaultBand = false;
}
+void EncRbSpeex::generateSettings()
+{
+ insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Volume:",settings->subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
+ insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Quality:",settings->subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
+ insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,"Complexity:",settings->subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
+ insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,"Use Narrowband:",settings->subValue("rbspeex",RbSettings::EncoderNarrowBand)));
+}
+
+void EncRbSpeex::saveSettings()
+{
+ //save settings in user config
+ settings->setSubValue("rbspeex",RbSettings::EncoderVolume,getSetting(eVOLUME)->current().toDouble());
+ settings->setSubValue("rbspeex",RbSettings::EncoderQuality,getSetting(eQUALITY)->current().toDouble());
+ settings->setSubValue("rbspeex",RbSettings::EncoderComplexity,getSetting(eCOMPLEXITY)->current().toInt());
+ settings->setSubValue("rbspeex",RbSettings::EncoderNarrowBand,getSetting(eNARROWBAND)->current().toBool());
+
+ settings->sync();
+}
bool EncRbSpeex::start()
{
@@ -210,18 +214,6 @@ bool EncRbSpeex::encode(QString input,QString output)
return true;
}
-
-void EncRbSpeex::showCfg()
-{
-#ifndef CONSOLE
- EncRbSpeexGui gui;
-#else
- EncRbSpeexGuiCli gui;
-#endif
- gui.setCfg(settings);
- gui.showCfg(defaultQuality,defaultVolume,defaultComplexity,defaultBand);
-}
-
bool EncRbSpeex::configOk()
{
bool result=true;
diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h
index 8a1805545f..d5d1723a46 100644
--- a/rbutil/rbutilqt/encoders.h
+++ b/rbutil/rbutilqt/encoders.h
@@ -25,32 +25,38 @@
#include <QtCore>
#include "rbsettings.h"
-
+#include "encttssettings.h"
#include "rbspeex.h"
-class EncBase : public QObject
+class EncBase : public EncTtsSettingInterface
{
Q_OBJECT
public:
EncBase(QObject *parent );
- virtual bool encode(QString input,QString output)
- {(void)input; (void)output; return false;}
- virtual bool start(){return false;}
- virtual bool stop(){return false;}
- virtual void showCfg(){}
- virtual bool configOk(){return false;}
-
- void setCfg(RbSettings *sett){settings = sett;}
- static QString getEncoderName(QString);
- static EncBase* getEncoder(QString);
+ //! Child class should encode a wav file
+ virtual bool encode(QString input,QString output) =0;
+ //! Child class should do startup
+ virtual bool start()=0;
+ //! Child class should stop
+ virtual bool stop()=0;
+
+ // settings
+ //! Child class should return true when configuration is ok
+ virtual bool configOk()=0;
+ //! Child class should fill in the setttingsList
+ virtual void generateSettings() = 0;
+ //! Chlid class should commit the from SettingsList to permanent storage
+ virtual void saveSettings() = 0;
+
+ // static functions
+ static QString getEncoderName(QString name);
+ static EncBase* getEncoder(QObject* parent,QString name);
static QStringList getEncoderList(void);
-
- public slots:
- virtual void accept(void){}
- virtual void reject(void){}
- virtual void reset(void){}
+
+ //set the config. users of Encoder classes, always have to call this first
+ void setCfg(RbSettings *sett){settings = sett;}
private:
static void initEncodernamesList(void);
@@ -58,22 +64,29 @@ class EncBase : public QObject
RbSettings* settings;
static QMap<QString,QString> encoderList;
- static QMap<QString,EncBase*> encoderCache;
};
-
class EncExes : public EncBase
{
+ enum ESettings
+ {
+ eEXEPATH,
+ eEXEOPTIONS
+ };
+
Q_OBJECT
public:
EncExes(QString name,QObject *parent = NULL);
- virtual bool encode(QString input,QString output);
- virtual bool start();
- virtual bool stop() {return true;}
- virtual void showCfg();
- virtual bool configOk();
+ bool encode(QString input,QString output);
+ bool start();
+ bool stop() {return true;}
+ // setting
+ bool configOk();
+ void generateSettings();
+ void saveSettings();
+
private:
QString m_name;
QString m_EncExec;
@@ -84,15 +97,26 @@ private:
class EncRbSpeex : public EncBase
{
+ enum ESettings
+ {
+ eVOLUME,
+ eQUALITY,
+ eCOMPLEXITY,
+ eNARROWBAND
+ };
+
Q_OBJECT
public:
EncRbSpeex(QObject *parent = NULL);
- virtual bool encode(QString input,QString output);
- virtual bool start();
- virtual bool stop() {return true;}
- virtual void showCfg();
- virtual bool configOk();
-
+ bool encode(QString input,QString output);
+ bool start();
+ bool stop() {return true;}
+
+ // for settings view
+ bool configOk();
+ void generateSettings();
+ void saveSettings();
+
private:
float quality;
float volume;
diff --git a/rbutil/rbutilqt/encodersgui.cpp b/rbutil/rbutilqt/encodersgui.cpp
deleted file mode 100644
index 3d1619f807..0000000000
--- a/rbutil/rbutilqt/encodersgui.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2007 by Dominik Wenger
- * $Id$
- *
- * 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 "encodersgui.h"
-
-#include "rbsettings.h"
-#include "browsedirtree.h"
-
-EncExesGui::EncExesGui(QDialog* parent) : QDialog(parent)
-{
- ui.setupUi(this);
- this->hide();
- connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
- connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
-}
-
-void EncExesGui::showCfg(QString name)
-{
- m_name = name;
- // try to get config from settings
- QString exepath =settings->subValue(m_name, RbSettings::EncoderPath).toString();
- ui.encoderoptions->setText(settings->subValue(m_name, RbSettings::EncoderOptions).toString());
-
- if(exepath == "")
- {
-
- // try to autodetect encoder
-#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
- QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
-#elif defined(Q_OS_WIN)
- QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
-#endif
- qDebug() << path;
-
- for(int i = 0; i < path.size(); i++)
- {
- QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
-#if defined(Q_OS_WIN)
- executable += ".exe";
- QStringList ex = executable.split("\"", QString::SkipEmptyParts);
- executable = ex.join("");
-#endif
- if(QFileInfo(executable).isExecutable())
- {
- qDebug() << "found:" << executable;
- exepath = QDir::toNativeSeparators(executable);
- break;
- }
- }
- }
-
- ui.encoderpath->setText(exepath);
-
- //show dialog
- this->exec();
-
-}
-
-void EncExesGui::accept(void)
-{
- //save settings in user config
- settings->setSubValue(m_name, RbSettings::EncoderPath, ui.encoderpath->text());
- settings->setSubValue(m_name, RbSettings::EncoderOptions, ui.encoderoptions->text());
-
- // sync settings
- settings->sync();
- this->done(0);
-}
-
-void EncExesGui::reject(void)
-{
- this->done(0);
-}
-
-void EncExesGui::reset()
-{
- ui.encoderpath->setText("");
- ui.encoderoptions->setText("");
-}
-
-void EncExesGui::browse()
-{
- BrowseDirtree browser(this);
- browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
-
- if(QFileInfo(ui.encoderpath->text()).isDir())
- {
- browser.setDir(ui.encoderpath->text());
- }
- if(browser.exec() == QDialog::Accepted)
- {
- qDebug() << browser.getSelected();
- QString exe = browser.getSelected();
- if(!QFileInfo(exe).isExecutable())
- return;
- ui.encoderpath->setText(exe);
- }
-}
-
-
-EncRbSpeexGui::EncRbSpeexGui(QDialog* parent) : QDialog(parent)
-{
- ui.setupUi(this);
- this->hide();
- connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
-
-}
-
-void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
-{
- defaultQuality =defQ;
- defaultVolume = defV;
- defaultComplexity = defC;
- defaultBand =defB;
-
- //fill in the usersettings
- ui.volume->setValue(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble());
- ui.quality->setValue(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble());
- ui.complexity->setValue(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt());
-
- if(settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool())
- ui.narrowband->setCheckState(Qt::Checked);
- else
- ui.narrowband->setCheckState(Qt::Unchecked);
-
- //show dialog
- this->exec();
-}
-
-void EncRbSpeexGui::accept(void)
-{
- //save settings in user config
- settings->setSubValue("rbspeex", RbSettings::EncoderVolume, ui.volume->value());
- settings->setSubValue("rbspeex", RbSettings::EncoderQuality, ui.quality->value());
- settings->setSubValue("rbspeex", RbSettings::EncoderComplexity, ui.complexity->value());
- settings->setSubValue("rbspeex", RbSettings::EncoderNarrowBand, ui.narrowband->isChecked() ? true : false);
-
- // sync settings
- settings->sync();
- this->done(0);
-}
-
-void EncRbSpeexGui::reject(void)
-{
- this->done(0);
-}
-
-void EncRbSpeexGui::reset()
-{
- ui.volume->setValue(defaultVolume);
- ui.quality->setValue(defaultQuality);
- ui.complexity->setValue(defaultComplexity);
- ui.narrowband->setChecked(Qt::Unchecked);
-}
-
diff --git a/rbutil/rbutilqt/encodersgui.h b/rbutil/rbutilqt/encodersgui.h
deleted file mode 100644
index 0c53549f80..0000000000
--- a/rbutil/rbutilqt/encodersgui.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2007 by Dominik Wenger
- * $Id$
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef ENCODERSGUI_H
-#define ENCODERSGUI_H
-
-#include <QtGui>
-
-class RbSettings;
-
-#include "ui_rbspeexcfgfrm.h"
-#include "ui_encexescfgfrm.h"
-
-
-class EncExesGui : public QDialog
-{
- Q_OBJECT
-public:
- EncExesGui(QDialog* parent = NULL);
-
- void showCfg(QString m_name);
- void setCfg(RbSettings* sett){settings = sett;}
-
-public slots:
- virtual void accept(void);
- virtual void reject(void);
- virtual void reset(void);
- void browse(void);
-
-private:
- Ui::EncExesCfgFrm ui;
- RbSettings* settings;
- QString m_name;
-};
-
-class EncRbSpeexGui : public QDialog
-{
- Q_OBJECT
-public:
- EncRbSpeexGui(QDialog* parent = NULL);
-
- void showCfg(float defQ,float defV,int defC, bool defB);
- void setCfg(RbSettings* sett){settings = sett;}
-
-public slots:
- virtual void accept(void);
- virtual void reject(void);
- virtual void reset(void);
-
-private:
- Ui::RbSpeexCfgFrm ui;
- RbSettings* settings;
- float defaultQuality;
- float defaultVolume;
- int defaultComplexity;
- bool defaultBand;
-};
-
-
-
-#endif
diff --git a/rbutil/rbutilqt/encttscfggui.cpp b/rbutil/rbutilqt/encttscfggui.cpp
new file mode 100644
index 0000000000..25089873fc
--- /dev/null
+++ b/rbutil/rbutilqt/encttscfggui.cpp
@@ -0,0 +1,361 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "encttscfggui.h"
+#include "browsedirtree.h"
+
+EncTtsCfgGui::EncTtsCfgGui(QDialog* parent,EncTtsSettingInterface* interface,QString name) : QDialog(parent)
+{
+ m_settingInterface = interface;
+
+ m_busyCnt=0;
+ // create a busy Dialog
+ m_busyDlg= new QProgressDialog(tr(""), tr(""), 0, 0,this);
+ m_busyDlg->setWindowTitle(tr("Waiting for engine..."));
+ m_busyDlg->setModal(true);
+ m_busyDlg->setLabel(0);
+ m_busyDlg->setCancelButton(0);
+ m_busyDlg->hide();
+ connect(interface,SIGNAL(busy()),this,SLOT(showBusy()));
+ connect(interface,SIGNAL(busyEnd()),this,SLOT(hideBusy()));
+
+ //setup the window
+ setWindowTitle(name);
+ setUpWindow();
+}
+
+void EncTtsCfgGui::setUpWindow()
+{
+ m_settingsList = m_settingInterface->getSettings();
+
+ //layout
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+
+ // groupbox
+ QGroupBox *groupBox = new QGroupBox(this);
+ QFormLayout *formlayout = new QFormLayout;
+ // setting widgets
+ for(int i = 0; i < m_settingsList.size(); i++)
+ {
+ formlayout->addRow(m_settingsList.at(i)->name(),createWidgets(m_settingsList.at(i)));
+ }
+ groupBox->setLayout(formlayout);
+ mainLayout->addWidget(groupBox);
+
+ // connect browse btn
+ connect(&m_browseBtnMap,SIGNAL(mapped(QObject*)),this,SLOT(browse(QObject*)));
+
+ // ok - cancel buttons
+ QPushButton* okBtn = new QPushButton(tr("Ok"),this);
+ okBtn->setDefault(true);
+ okBtn->setIcon(QIcon(":icons/go-next.png"));
+ QPushButton* cancelBtn = new QPushButton(tr("Cancel"),this);
+ cancelBtn->setIcon(QIcon(":icons/process-stop.png"));
+ connect(okBtn,SIGNAL(clicked()),this,SLOT(accept()));
+ connect(cancelBtn,SIGNAL(clicked()),this,SLOT(reject()));
+
+ QHBoxLayout *btnbox = new QHBoxLayout;
+ btnbox->addWidget(okBtn);
+ btnbox->addWidget(cancelBtn);
+ btnbox->insertStretch(0,1);
+
+ mainLayout->addLayout(btnbox);
+
+ this->setLayout(mainLayout);
+}
+
+QLayout* EncTtsCfgGui::createWidgets(EncTtsSetting* setting)
+{
+ // value display
+ QWidget* value = NULL;
+ switch(setting->type())
+ {
+ case EncTtsSetting::eDOUBLE:
+ {
+ QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
+ spinBox->setMinimum(setting->min().toDouble());
+ spinBox->setMaximum(setting->max().toDouble());
+ spinBox->setSingleStep(0.01);
+ spinBox->setValue(setting->current().toDouble());
+ connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting()));
+ value = spinBox;
+ break;
+ }
+ case EncTtsSetting::eINT:
+ {
+ QSpinBox *spinBox = new QSpinBox(this);
+ spinBox->setMinimum(setting->min().toInt());
+ spinBox->setMaximum(setting->max().toInt());
+ spinBox->setValue(setting->current().toInt());
+ connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting()));
+ value = spinBox;
+ break;
+ }
+ case EncTtsSetting::eSTRING:
+ {
+ QLineEdit *lineEdit = new QLineEdit(this);
+ lineEdit->setText(setting->current().toString());
+ connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting()));
+ value = lineEdit;
+ break;
+ }
+ case EncTtsSetting::eREADONLYSTRING:
+ {
+ value = new QLabel(setting->current().toString(),this);
+ break;
+ }
+ case EncTtsSetting::eSTRINGLIST:
+ {
+ QComboBox *comboBox = new QComboBox(this);
+ comboBox->addItems(setting->list());
+ int index = comboBox->findText(setting->current().toString());
+ comboBox->setCurrentIndex(index);
+ connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting()));
+ value = comboBox;
+ break;
+ }
+ case EncTtsSetting::eBOOL:
+ {
+ QCheckBox *checkbox = new QCheckBox(this);
+ checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
+ connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting()));
+ value = checkbox;
+ break;
+ }
+ default:
+ {
+ qDebug() << "Warning: unknown EncTTsSetting type" << setting->type();
+ break;
+ }
+ }
+
+ // remeber widget
+ if(value != NULL)
+ {
+ m_settingsWidgetsMap.insert(setting,value);
+ connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget()));
+ }
+
+ // buttons ?
+ QWidget* btn = createButton(setting);
+
+ // add to layout
+ QHBoxLayout *hbox = new QHBoxLayout;
+ if(value != NULL)hbox->addWidget(value);
+ if(btn != NULL) hbox->addWidget(btn);
+
+ return hbox;
+
+}
+
+QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting)
+{
+ if(setting->button() == EncTtsSetting::eBROWSEBTN)
+ {
+ QPushButton* browsebtn = new QPushButton(tr("Browse"),this);
+ browsebtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
+ m_browseBtnMap.setMapping(browsebtn,setting);
+ connect(browsebtn,SIGNAL(clicked()),&m_browseBtnMap,SLOT(map()));
+ return browsebtn;
+ }
+ else if(setting->button() == EncTtsSetting::eREFRESHBTN)
+ {
+ QPushButton* refreshbtn = new QPushButton(tr("Refresh"),this);
+ refreshbtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
+ connect(refreshbtn,SIGNAL(clicked()),setting,SIGNAL(refresh()));
+ return refreshbtn;
+ }
+ else
+ return NULL;
+}
+
+void EncTtsCfgGui::updateSetting()
+{
+ //cast and get the sender widget
+ QWidget* widget = qobject_cast<QWidget*>(QObject::sender());
+ if(widget == NULL) return;
+ // get the corresponding setting
+ EncTtsSetting* setting = m_settingsWidgetsMap.key(widget);
+
+ // update widget based on setting type
+ switch(setting->type())
+ {
+ case EncTtsSetting::eDOUBLE:
+ {
+ setting->setCurrent(((QDoubleSpinBox*)widget)->value(),false);
+ break;
+ }
+ case EncTtsSetting::eINT:
+ {
+ setting->setCurrent(((QSpinBox*)widget)->value(),false);
+ break;
+ }
+ case EncTtsSetting::eSTRING:
+ {
+ setting->setCurrent(((QLineEdit*)widget)->text(),false);
+ break;
+ }
+ case EncTtsSetting::eREADONLYSTRING:
+ {
+ setting->setCurrent(((QLabel*)widget)->text(),false);
+ break;
+ }
+ case EncTtsSetting::eSTRINGLIST:
+ {
+ setting->setCurrent(((QComboBox*)widget)->currentText(),false);
+ break;
+ }
+ case EncTtsSetting::eBOOL:
+ {
+ setting->setCurrent(((QCheckBox*)widget)->isChecked(),false);
+ }
+ default:
+ {
+ qDebug() << "unknown Settingtype !!";
+ break;
+ }
+ }
+}
+
+void EncTtsCfgGui::updateWidget()
+{
+ // get sender setting
+ EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender());
+ if(setting == NULL) return;
+ // get corresponding widget
+ QWidget* widget = m_settingsWidgetsMap.value(setting);
+
+ // update Widget based on setting type
+ switch(setting->type())
+ {
+ case EncTtsSetting::eDOUBLE:
+ {
+ QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget;
+ spinbox->setMinimum(setting->min().toDouble());
+ spinbox->setMaximum(setting->max().toDouble());
+ spinbox->blockSignals(true);
+ spinbox->setValue(setting->current().toDouble());
+ spinbox->blockSignals(false);
+ break;
+ }
+ case EncTtsSetting::eINT:
+ {
+ QSpinBox* spinbox = (QSpinBox*) widget;
+ spinbox->setMinimum(setting->min().toInt());
+ spinbox->setMaximum(setting->max().toInt());
+ spinbox->blockSignals(true);
+ spinbox->setValue(setting->current().toInt());
+ spinbox->blockSignals(false);
+ break;
+ }
+ case EncTtsSetting::eSTRING:
+ {
+ QLineEdit* lineedit = (QLineEdit*) widget;
+
+ lineedit->blockSignals(true);
+ lineedit->setText(setting->current().toString());
+ lineedit->blockSignals(false);
+ break;
+ }
+ case EncTtsSetting::eREADONLYSTRING:
+ {
+ QLabel* label = (QLabel*) widget;
+
+ label->blockSignals(true);
+ label->setText(setting->current().toString());
+ label->blockSignals(false);
+ break;
+ }
+ case EncTtsSetting::eSTRINGLIST:
+ {
+ QComboBox* combobox = (QComboBox*) widget;
+
+ combobox->blockSignals(true);
+ combobox->clear();
+ combobox->addItems(setting->list());
+ int index = combobox->findText(setting->current().toString());
+ combobox->setCurrentIndex(index);
+ combobox->blockSignals(false);
+
+ break;
+ }
+ case EncTtsSetting::eBOOL:
+ {
+ QCheckBox* checkbox = (QCheckBox*) widget;
+
+ checkbox->blockSignals(true);
+ checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
+ checkbox->blockSignals(false);
+ break;
+ }
+ default:
+ {
+ qDebug() << "unknown EncTTsSetting";
+ break;
+ }
+ }
+}
+
+void EncTtsCfgGui::showBusy()
+{
+ if(m_busyCnt == 0) m_busyDlg->show();
+
+ m_busyCnt++;
+}
+
+void EncTtsCfgGui::hideBusy()
+{
+ m_busyCnt--;
+
+ if(m_busyCnt == 0) m_busyDlg->hide();
+}
+
+
+void EncTtsCfgGui::accept(void)
+{
+ m_settingInterface->saveSettings();
+ this->done(0);
+}
+
+void EncTtsCfgGui::reject(void)
+{
+ this->done(0);
+}
+
+//! takes a QObject because of QsignalMapper
+void EncTtsCfgGui::browse(QObject* settingObj)
+{
+ // cast top setting
+ EncTtsSetting* setting= qobject_cast<EncTtsSetting*>(settingObj);
+ if(setting == NULL) return;
+
+ //current path
+ QString curPath = setting->current().toString();
+ // show file dialog
+ QString exe = QFileDialog::getOpenFileName(this, tr("Select excutable"), curPath, "*");
+ if(!QFileInfo(exe).isExecutable())
+ return;
+ // set new value, gui will update automatically
+ setting->setCurrent(exe);
+}
+
+
+
diff --git a/rbutil/rbutilqt/encttscfggui.h b/rbutil/rbutilqt/encttscfggui.h
new file mode 100644
index 0000000000..45b151ce23
--- /dev/null
+++ b/rbutil/rbutilqt/encttscfggui.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef ENCTTSCFGGUI_H
+#define ENCTTSCFGGUI_H
+
+#include <QtGui>
+#include "encttssettings.h"
+
+//! \brief Shows and manages a configuration gui for encoders and tts enignes
+//!
+class EncTtsCfgGui: public QDialog
+{
+ Q_OBJECT
+public:
+ //! Creates the UI. give it a endoer or tts engine with already set config. uses show() or exec() to show it.
+ EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* interface,QString name);
+
+private slots:
+ //! accept current configuration values and close window
+ void accept(void);
+ //! close window and dont save configuration
+ void reject(void);
+ //! updates the corresponding setting from the sending Widget
+ void updateSetting();
+ //! updates corresponding Widget from the sending Setting.
+ void updateWidget();
+ //! shows a busy dialog. counts calls.
+ void showBusy();
+ //! hides the busy dialog, counts calls
+ void hideBusy();
+ //! used via the SignalMapper for all Browse buttons
+ void browse(QObject*);
+
+private:
+ //! creates all dynamic window content
+ void setUpWindow();
+ //! creates the Widgets needed for one setting. returns a Layout with the widgets
+ QLayout* createWidgets(EncTtsSetting* setting);
+ //! creates a button when needed by the setting.
+ QWidget* createButton(EncTtsSetting* setting);
+ //! name of the Encoder or TTS for which this UI is
+ QString m_name;
+ //! the interface pointer to the TTS or encoder
+ EncTtsSettingInterface* m_settingInterface;
+ //! Dialog, shown when enc or tts is busy
+ QProgressDialog* m_busyDlg;
+ //! List of settings from the TTS or Encoder
+ QList<EncTtsSetting*> m_settingsList;
+ //! Maps settings and the correspondig Widget
+ QMap<EncTtsSetting*,QWidget*> m_settingsWidgetsMap;
+ //! Maps all browse buttons to the corresponding Setting
+ QSignalMapper m_browseBtnMap;
+ //! counter how often busyShow() is called,
+ int m_busyCnt;
+};
+
+
+#endif
+
diff --git a/rbutil/rbutilqt/encttssettings.cpp b/rbutil/rbutilqt/encttssettings.cpp
new file mode 100644
index 0000000000..fa7cfb39c2
--- /dev/null
+++ b/rbutil/rbutilqt/encttssettings.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "encttssettings.h"
+
+
+EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current, EButton btn)
+{
+ m_btn = btn;
+ m_name =name;
+ m_type =type;
+ m_currentValue = current;
+}
+
+EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn)
+{
+ m_btn = btn;
+ m_name =name;
+ m_type =type;
+ m_currentValue = current;
+ m_list = list;
+}
+
+EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max, EButton btn)
+{
+ m_btn = btn;
+ m_name =name;
+ m_type =type;
+ m_currentValue = current;
+ m_minValue = min;
+ m_maxValue = max;
+}
+
+void EncTtsSetting::setCurrent(QVariant current,bool noticeGui)
+{
+ m_currentValue = current;
+ emit dataChanged();
+
+ if(noticeGui) emit updateGui();
+}
+
+//! insert a setting
+void EncTtsSettingInterface::insertSetting(int id,EncTtsSetting* setting)
+{
+ settingsList.insert(id,setting);
+}
+
+//! retrieve a specific setting
+EncTtsSetting* EncTtsSettingInterface::getSetting(int id)
+{
+ return settingsList.at(id);
+}
diff --git a/rbutil/rbutilqt/encttssettings.h b/rbutil/rbutilqt/encttssettings.h
new file mode 100644
index 0000000000..843829a815
--- /dev/null
+++ b/rbutil/rbutilqt/encttssettings.h
@@ -0,0 +1,129 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef ENCTTSSETTINGS_H
+#define ENCTTSSETTINGS_H
+
+#include <QtCore>
+
+//! \brief This class stores everything needed to display a Setting.
+//!
+class EncTtsSetting : public QObject
+{
+ Q_OBJECT
+public:
+ enum ESettingType
+ {
+ eBASE,
+ eBOOL,
+ eDOUBLE,
+ eINT,
+ eSTRING,
+ eREADONLYSTRING,
+ eSTRINGLIST,
+ };
+ enum EButton
+ {
+ eNOBTN,
+ eBROWSEBTN,
+ eREFRESHBTN
+ };
+
+ //! constructor for a String or Bool setting
+ EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN);
+ //! contructor for a Stringlist setting, ie a enumeration
+ EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN);
+ //! constructor for a setting with a min-max range
+ EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN);
+
+ //! get currentValue
+ QVariant current() {return m_currentValue;}
+ //! set currentValue
+ void setCurrent(QVariant current,bool noticeGui=true);
+
+ //! get name of the Setting
+ QString name() {return m_name;}
+ //! get the type of the setting
+ ESettingType type() {return m_type;}
+ //! get what type of button this setting needs
+ EButton button() {return m_btn;}
+ //! get the minValue (only valid for a range setting, ie eDOUBLE or eINT)
+ QVariant min() {return m_minValue; }
+ //! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT)
+ QVariant max() {return m_maxValue; }
+ //! get the enumerationlist (only valid for eSTRINGLIST settings)
+ QStringList list() {return m_list;}
+ //! set the enumeration list
+ void setList(QStringList list){m_list = list;}
+
+signals:
+ //! connect to this signal if you want to get noticed when the data changes
+ void dataChanged();
+ //! connect to this if you want to react on refresh button
+ void refresh();
+ //! will be emited when the gui should update this setting
+ void updateGui();
+
+private:
+ ESettingType m_type;
+ EButton m_btn;
+ QString m_name;
+ QVariant m_currentValue;
+ QVariant m_minValue;
+ QVariant m_maxValue;
+ QStringList m_list;
+};
+
+
+//! \brief this class is the Interface for Encoder and TTS engines, to display settings
+//! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented
+//!
+class EncTtsSettingInterface : public QObject
+{
+ Q_OBJECT
+public:
+ EncTtsSettingInterface(QObject* parent) : QObject(parent) {}
+
+ //! get the Settings list
+ QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;}
+
+ //! Chlid class should commit the from SettingsList to permanent storage
+ virtual void saveSettings() = 0;
+
+signals:
+ void busy(); // emit this if a operation takes time
+ void busyEnd(); // emit this at the end of a busy section
+
+protected:
+ //! Child class should fill in the setttingsList
+ virtual void generateSettings() = 0;
+
+ //! insert a setting
+ void insertSetting(int id,EncTtsSetting* setting);
+ //! retrieve a specific setting
+ EncTtsSetting* getSetting(int id);
+
+private:
+ //! The setting storage.
+ QList<EncTtsSetting*> settingsList;
+
+};
+#endif
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index 4caaa4fbc7..041b8f2885 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -116,7 +116,7 @@ void InstallTalkWindow::setSettings(RbSettings* sett)
void InstallTalkWindow::updateSettings(void)
{
QString ttsName = settings->value(RbSettings::Tts).toString();
- TTSBase* tts = TTSBase::getTTS(ttsName);
+ TTSBase* tts = TTSBase::getTTS(this,ttsName);
tts->setCfg(settings);
if(tts->configOk())
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
@@ -126,7 +126,7 @@ void InstallTalkWindow::updateSettings(void)
.arg("Invalid TTS configuration!"));
QString encoder = settings->value(RbSettings::CurEncoder).toString();
- EncBase* enc = EncBase::getEncoder(encoder);
+ EncBase* enc = EncBase::getEncoder(this,encoder);
if(enc != NULL) {
enc->setCfg(settings);
if(enc->configOk())
diff --git a/rbutil/rbutilqt/rbspeexcfgfrm.ui b/rbutil/rbutilqt/rbspeexcfgfrm.ui
deleted file mode 100644
index 0134817fec..0000000000
--- a/rbutil/rbutilqt/rbspeexcfgfrm.ui
+++ /dev/null
@@ -1,171 +0,0 @@
-<ui version="4.0" >
- <class>RbSpeexCfgFrm</class>
- <widget class="QDialog" name="RbSpeexCfgFrm" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>408</width>
- <height>173</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Configuration</string>
- </property>
- <layout class="QGridLayout" >
- <item row="0" column="0" colspan="4" >
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
- <string>Configure RbSpeex Encoder</string>
- </property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QDoubleSpinBox" name="volume" >
- <property name="maximum" >
- <double>10.000000000000000</double>
- </property>
- <property name="singleStep" >
- <double>0.010000000000000</double>
- </property>
- <property name="value" >
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Volume</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2" >
- <widget class="QCheckBox" name="narrowband" >
- <property name="text" >
- <string>Narrowband</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QDoubleSpinBox" name="quality" >
- <property name="decimals" >
- <number>1</number>
- </property>
- <property name="maximum" >
- <double>10.000000000000000</double>
- </property>
- <property name="singleStep" >
- <double>1.000000000000000</double>
- </property>
- <property name="value" >
- <double>8.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="1" column="1" colspan="2" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Quality</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QSpinBox" name="complexity" >
- <property name="maximum" >
- <number>10</number>
- </property>
- <property name="value" >
- <number>10</number>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="2" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>Complexity</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="reset" >
- <property name="text" >
- <string>Reset</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="buttonOk" >
- <property name="text" >
- <string>&amp;Ok</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="3" >
- <widget class="QPushButton" name="buttonCancel" >
- <property name="text" >
- <string>&amp;Cancel</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="rbutilqt.qrc" />
- </resources>
- <connections>
- <connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
- <receiver>RbSpeexCfgFrm</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>253</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
- <receiver>RbSpeexCfgFrm</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>352</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 2838213b33..27ab920e0f 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -64,9 +64,9 @@ SOURCES += rbutilqt.cpp \
base/utils.cpp \
preview.cpp \
encoders.cpp \
- encodersgui.cpp \
+ encttscfggui.cpp \
+ encttssettings.cpp \
tts.cpp \
- ttsgui.cpp \
../../tools/wavtrim.c \
../../tools/voicefont.c \
voicefile.cpp \
@@ -116,9 +116,9 @@ HEADERS += rbutilqt.h \
base/utils.h \
preview.h \
encoders.h \
- encodersgui.h \
+ encttscfggui.h \
+ encttssettings.h \
tts.h \
- ttsgui.h \
../../tools/wavtrim.h \
../../tools/voicefont.h \
voicefile.h \
@@ -167,11 +167,6 @@ FORMS += rbutilqtfrm.ui \
themesinstallfrm.ui \
uninstallfrm.ui \
previewfrm.ui \
- rbspeexcfgfrm.ui \
- encexescfgfrm.ui \
- ttsexescfgfrm.ui \
- sapicfgfrm.ui \
- ttsfestivalcfgform.ui \
createvoicefrm.ui \
sysinfofrm.ui
diff --git a/rbutil/rbutilqt/sapicfgfrm.ui b/rbutil/rbutilqt/sapicfgfrm.ui
deleted file mode 100644
index 4d77c51ea7..0000000000
--- a/rbutil/rbutilqt/sapicfgfrm.ui
+++ /dev/null
@@ -1,175 +0,0 @@
-<ui version="4.0" >
- <class>SapiCfgFrm</class>
- <widget class="QDialog" name="SapiCfgFrm" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>511</width>
- <height>242</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Configuration</string>
- </property>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
- <string>Configure TTS Engine</string>
- </property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>Language</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QComboBox" name="languagecombo" />
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Voice</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QComboBox" name="voicecombo" />
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="label_4" >
- <property name="text" >
- <string>Speed</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QSpinBox" name="speed" >
- <property name="minimum" >
- <number>-10</number>
- </property>
- <property name="maximum" >
- <number>10</number>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>TTS options</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QLineEdit" name="ttsoptions" />
- </item>
- <item row="5" column="0" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>473</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="6" column="0" colspan="2" >
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QPushButton" name="reset" >
- <property name="text" >
- <string>Reset</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonOk" >
- <property name="text" >
- <string>&amp;Ok</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel" >
- <property name="text" >
- <string>&amp;Cancel</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="4" column="0" colspan="2" >
- <widget class="QCheckBox" name="usesapi4" >
- <property name="text" >
- <string>Use Sapi 4</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="rbutilqt.qrc" />
- </resources>
- <connections>
- <connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
- <receiver>SapiCfgFrm</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>253</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
- <receiver>SapiCfgFrm</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>352</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp
index 6e872ad281..fd6f4a2109 100644
--- a/rbutil/rbutilqt/talkfile.cpp
+++ b/rbutil/rbutilqt/talkfile.cpp
@@ -40,7 +40,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
//tts
- m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
+ m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings);
if(!m_tts->start(&errStr))
@@ -52,7 +52,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
}
// Encoder
- m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
+ m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings);
if(!m_enc->start())
diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h
index 08c076132d..ae69acfd78 100644
--- a/rbutil/rbutilqt/talkfile.h
+++ b/rbutil/rbutilqt/talkfile.h
@@ -34,7 +34,7 @@ class TalkFileCreator :public QObject
Q_OBJECT
public:
- TalkFileCreator(QObject* parent=0);
+ TalkFileCreator(QObject* parent);
bool createTalkFiles(ProgressloggerInterface* logger);
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp
index 277022b9a1..d55ba9e739 100644
--- a/rbutil/rbutilqt/tts.cpp
+++ b/rbutil/rbutilqt/tts.cpp
@@ -18,11 +18,16 @@
****************************************************************************/
#include "tts.h"
+#include "utils.h"
+/*********************************************************************
+* TTS Base
+**********************************************************************/
+QMap<QString,QString> TTSBase::ttsList;
+TTSBase::TTSBase(QObject* parent): EncTtsSettingInterface(parent)
+{
-// static variables
-QMap<QString,QString> TTSBase::ttsList;
-QMap<QString,TTSBase*> TTSBase::ttsCache;
+}
// static functions
void TTSBase::initTTSList()
@@ -39,35 +44,29 @@ void TTSBase::initTTSList()
}
// function to get a specific encoder
-TTSBase* TTSBase::getTTS(QString ttsName)
+TTSBase* TTSBase::getTTS(QObject* parent,QString ttsName)
{
- // check cache
- if(ttsCache.contains(ttsName))
- return ttsCache.value(ttsName);
-
+
TTSBase* tts;
#if defined(Q_OS_WIN)
if(ttsName == "sapi")
{
- tts = new TTSSapi();
- ttsCache[ttsName] = tts;
+ tts = new TTSSapi(parent);
return tts;
}
- else
+ else
#endif
#if defined(Q_OS_LINUX)
if (ttsName == "festival")
{
- tts = new TTSFestival();
- ttsCache[ttsName] = tts;
- return tts;
+ tts = new TTSFestival(parent);
+ return tts;
}
else
#endif
if (true) // fix for OS other than WIN or LINUX
{
- tts = new TTSExes(ttsName);
- ttsCache[ttsName] = tts;
+ tts = new TTSExes(ttsName,parent);
return tts;
}
}
@@ -90,69 +89,41 @@ QString TTSBase::getTTSName(QString tts)
return ttsList.value(tts);
}
-/*********************************************************************
-* TTS Base
-**********************************************************************/
-TTSBase::TTSBase(): QObject()
-{
-
-}
/*********************************************************************
* General TTS Exes
**********************************************************************/
-TTSExes::TTSExes(QString name) : TTSBase()
+TTSExes::TTSExes(QString name,QObject* parent) : TTSBase(parent)
{
m_name = name;
-
+
m_TemplateMap["espeak"] = "\"%exe\" %options -w \"%wavfile\" \"%text\"";
m_TemplateMap["flite"] = "\"%exe\" %options -o \"%wavfile\" -t \"%text\"";
m_TemplateMap["swift"] = "\"%exe\" %options -o \"%wavfile\" \"%text\"";
-
+
}
-void TTSExes::setCfg(RbSettings* sett)
+void TTSExes::generateSettings()
{
- // call function of base class
- TTSBase::setCfg(sett);
-
- // if the config isnt OK, try to autodetect
- if(!configOk())
- {
- QString exepath;
- //try autodetect tts
-#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
- QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
-#elif defined(Q_OS_WIN)
- QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
-#endif
- qDebug() << path;
- for(int i = 0; i < path.size(); i++)
- {
- QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
-#if defined(Q_OS_WIN)
- executable += ".exe";
- QStringList ex = executable.split("\"", QString::SkipEmptyParts);
- executable = ex.join("");
-#endif
- qDebug() << executable;
- if(QFileInfo(executable).isExecutable())
- {
- exepath= QDir::toNativeSeparators(executable);
- break;
- }
- }
- settings->setSubValue(m_name, RbSettings::TtsPath, exepath);
- settings->sync();
- }
+ QString exepath =settings->subValue(m_name,RbSettings::TtsPath).toString();
+ if(exepath == "") exepath = findExecutable(m_name);
+
+ insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to TTS engine:",exepath,EncTtsSetting::eBROWSEBTN));
+ insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"TTS enginge options:",settings->subValue(m_name,RbSettings::TtsOptions)));
+}
+void TTSExes::saveSettings()
+{
+ settings->setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString());
+ settings->setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
+ settings->sync();
}
bool TTSExes::start(QString *errStr)
{
- m_TTSexec = settings->subValue(m_name, RbSettings::TtsPath).toString();
- m_TTSOpts = settings->subValue(m_name, RbSettings::TtsOptions).toString();
-
+ m_TTSexec = settings->subValue(m_name,RbSettings::TtsPath).toString();
+ m_TTSOpts = settings->subValue(m_name,RbSettings::TtsOptions).toString();
+
m_TTSTemplate = m_TemplateMap.value(m_name);
QFileInfo tts(m_TTSexec);
@@ -169,7 +140,7 @@ bool TTSExes::start(QString *errStr)
TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
{
- (void) errStr;
+ (void) errStr;
QString execstring = m_TTSTemplate;
execstring.replace("%exe",m_TTSexec);
@@ -182,57 +153,84 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
}
-void TTSExes::showCfg()
-{
-#ifndef CONSOLE
- TTSExesGui gui;
-#else
- TTSExesGuiCli gui;
-#endif
- gui.setCfg(settings);
- gui.showCfg(m_name);
-}
-
bool TTSExes::configOk()
{
- QString path = settings->subValue(m_name, RbSettings::TtsPath).toString();
-
+ QString path = settings->subValue(m_name,RbSettings::TtsPath).toString();
+
if (QFileInfo(path).exists())
return true;
-
+
return false;
}
/*********************************************************************
* TTS Sapi
**********************************************************************/
-TTSSapi::TTSSapi() : TTSBase()
+TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
{
m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\" /speed:%speed \"%options\"";
defaultLanguage ="english";
m_sapi4 =false;
}
+void TTSSapi::generateSettings()
+{
+ // language
+ QStringList languages = settings->languages();
+ languages.sort();
+ EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Language:",settings->subValue("sapi",RbSettings::TtsLanguage),languages);
+ connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
+ insertSetting(eLANGUAGE,setting);
+ // voice
+ setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("sapi",RbSettings::TtsVoice),getVoiceList(settings->subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN);
+ connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
+ insertSetting(eVOICE,setting);
+ //speed
+ insertSetting(eSPEED,new EncTtsSetting(this,EncTtsSetting::eINT,"Speed:",settings->subValue("sapi",RbSettings::TtsSpeed),-10,10));
+ // options
+ insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Options:",settings->subValue("sapi",RbSettings::TtsOptions)));
-bool TTSSapi::start(QString *errStr)
+}
+
+void TTSSapi::saveSettings()
+{
+ //save settings in user config
+ settings->setSubValue("sapi",RbSettings::TtsLanguage,getSetting(eLANGUAGE)->current().toString());
+ settings->setSubValue("sapi",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
+ settings->setSubValue("sapi",RbSettings::TtsSpeed,getSetting(eSPEED)->current().toInt());
+ settings->setSubValue("sapi",RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
+
+ settings->sync();
+}
+
+void TTSSapi::updateVoiceList()
{
+ qDebug() << "update voiceList";
+ QStringList voiceList = getVoiceList(getSetting(eLANGUAGE)->current().toString());
+ getSetting(eVOICE)->setList(voiceList);
+ if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0));
+ else getSetting(eVOICE)->setCurrent("");
+}
+
+bool TTSSapi::start(QString *errStr)
+{
- m_TTSOpts = settings->subValue("sapi", RbSettings::TtsOptions).toString();
- m_TTSLanguage =settings->subValue("sapi", RbSettings::TtsLanguage).toString();
- m_TTSVoice=settings->subValue("sapi", RbSettings::TtsVoice).toString();
- m_TTSSpeed=QString("%1").arg(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
- m_sapi4 = settings->value(RbSettings::TtsUseSapi4).toBool();
+ m_TTSOpts = settings->subValue("sapi",RbSettings::TtsOptions).toString();
+ m_TTSLanguage =settings->subValue("sapi",RbSettings::TtsLanguage).toString();
+ m_TTSVoice=settings->subValue("sapi",RbSettings::TtsVoice).toString();
+ m_TTSSpeed=settings->subValue("sapi",RbSettings::TtsSpeed).toString();
+ m_sapi4 = settings->subValue("sapi",RbSettings::TtsUseSapi4).toBool();
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs";
-
+
QFileInfo tts(m_TTSexec);
if(!tts.exists())
{
*errStr = tr("Could not copy the Sapi-script");
return false;
- }
+ }
// create the voice process
QString execstring = m_TTSTemplate;
execstring.replace("%exe",m_TTSexec);
@@ -240,31 +238,31 @@ bool TTSSapi::start(QString *errStr)
execstring.replace("%lang",m_TTSLanguage);
execstring.replace("%voice",m_TTSVoice);
execstring.replace("%speed",m_TTSSpeed);
-
+
if(m_sapi4)
execstring.append(" /sapi4 ");
-
- qDebug() << "init" << execstring;
+
+ qDebug() << "init" << execstring;
voicescript = new QProcess(NULL);
//connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error()));
-
+
voicescript->start(execstring);
if(!voicescript->waitForStarted())
{
*errStr = tr("Could not start the Sapi-script");
return false;
}
-
- if(!voicescript->waitForReadyRead(300))
+
+ if(!voicescript->waitForReadyRead(300))
{
*errStr = voicescript->readAllStandardError();
if(*errStr != "")
- return false;
+ return false;
}
-
+
voicestream = new QTextStream(voicescript);
voicestream->setCodec("UTF16-LE");
-
+
return true;
}
@@ -272,14 +270,14 @@ bool TTSSapi::start(QString *errStr)
QStringList TTSSapi::getVoiceList(QString language)
{
QStringList result;
-
+
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs";
-
+
QFileInfo tts(m_TTSexec);
if(!tts.exists())
return result;
-
+
// create the voice process
QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices";
execstring.replace("%exe",m_TTSexec);
@@ -287,34 +285,34 @@ QStringList TTSSapi::getVoiceList(QString language)
if(settings->value(RbSettings::TtsUseSapi4).toBool())
execstring.append(" /sapi4 ");
-
- qDebug() << "init" << execstring;
+
+ qDebug() << "init" << execstring;
voicescript = new QProcess(NULL);
voicescript->start(execstring);
- qDebug() << "wait for started";
+ qDebug() << "wait for started";
if(!voicescript->waitForStarted())
return result;
voicescript->closeWriteChannel();
voicescript->waitForReadyRead();
-
+
QString dataRaw = voicescript->readAllStandardError().data();
result = dataRaw.split(",",QString::SkipEmptyParts);
- result.sort();
- result.removeFirst();
- for(int i = 0; i< result.size();i++)
+ if(result.size() > 0)
{
- result[i] = result.at(i).simplified();
- }
-
-
+ result.sort();
+ result.removeFirst();
+ for(int i = 0; i< result.size();i++)
+ {
+ result[i] = result.at(i).simplified();
+ }
+ }
+
delete voicescript;
- QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",
- QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner
- |QFile::ReadUser |QFile::WriteUser |QFile::ExeUser
- |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
- |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther);
+ QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
+ |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
+ |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
+ |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther );
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
-
return result;
}
@@ -322,7 +320,7 @@ QStringList TTSSapi::getVoiceList(QString language)
TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr)
{
- (void) errStr;
+ (void) errStr;
QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
qDebug() << "voicing" << query;
*voicestream << query;
@@ -333,37 +331,24 @@ TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr)
}
bool TTSSapi::stop()
-{
-
+{
+
*voicestream << "QUIT\r\n";
voicestream->flush();
voicescript->waitForFinished();
delete voicestream;
delete voicescript;
- QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",
- QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner
- |QFile::ReadUser |QFile::WriteUser |QFile::ExeUser
- |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
- |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther);
+ QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
+ |QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
+ |QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
+ |QFile::ReadOther |QFile::WriteOther |QFile::ExeOther );
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
return true;
}
-
-void TTSSapi::showCfg()
-{
-#ifndef CONSOLE
- TTSSapiGui gui(this);
-#else
- TTSSapiGuiCli gui(this);
-#endif
- gui.setCfg(settings);
- gui.showCfg();
-}
-
bool TTSSapi::configOk()
{
- if(settings->subValue("sapi", RbSettings::TtsVoice).toString().isEmpty())
+ if(settings->subValue("sapi",RbSettings::TtsVoice).toString().isEmpty())
return false;
return true;
}
@@ -372,252 +357,300 @@ bool TTSSapi::configOk()
**********************************************************************/
TTSFestival::~TTSFestival()
{
- stop();
+ stop();
}
-void TTSFestival::startServer()
+void TTSFestival::generateSettings()
{
- if(!configOk())
- return;
+ // server path
+ QString exepath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
+ if(exepath == "" ) exepath = findExecutable("festival");
+ insertSetting(eSERVERPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival server:",exepath,EncTtsSetting::eBROWSEBTN));
+
+ // client path
+ QString clientpath = settings->subValue("festival-client",RbSettings::TtsPath).toString();
+ if(clientpath == "" ) clientpath = findExecutable("festival_client");
+ insertSetting(eCLIENTPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival client:",clientpath,EncTtsSetting::eBROWSEBTN));
+
+ // voice
+ EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN);
+ connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
+ connect(setting,SIGNAL(dataChanged()),this,SLOT(clearVoiceDescription()));
+ insertSetting(eVOICE,setting);
+
+ //voice description
+ setting = new EncTtsSetting(this,EncTtsSetting::eREADONLYSTRING,"Voice description:","",EncTtsSetting::eREFRESHBTN);
+ connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceDescription()));
+ insertSetting(eVOICEDESC,setting);
+}
- QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
+void TTSFestival::saveSettings()
+{
+ //save settings in user config
+ settings->setSubValue("festival-server",RbSettings::TtsPath,getSetting(eSERVERPATH)->current().toString());
+ settings->setSubValue("festival-client",RbSettings::TtsPath,getSetting(eCLIENTPATH)->current().toString());
+ settings->setSubValue("festival",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
+
+ settings->sync();
+}
- serverProcess.start(QString("%1 --server").arg(paths[0]));
- serverProcess.waitForStarted();
+void TTSFestival::updateVoiceDescription()
+{
+ // get voice Info with current voice and path
+ QString info = getVoiceInfo(getSetting(eVOICE)->current().toString(),getSetting(eSERVERPATH)->current().toString());
+ getSetting(eVOICEDESC)->setCurrent(info);
+}
- queryServer("(getpid)");
- if(serverProcess.state() == QProcess::Running)
- qDebug() << "Festival is up and running";
- else
- qDebug() << "Festival failed to start";
+void TTSFestival::clearVoiceDescription()
+{
+ getSetting(eVOICEDESC)->setCurrent("");
}
-void TTSFestival::ensureServerRunning()
+void TTSFestival::updateVoiceList()
{
- if(serverProcess.state() != QProcess::Running)
- {
- // least common denominator for all the server startup code paths
- QProgressDialog progressDialog(tr(""), tr(""), 0, 0);
- progressDialog.setWindowTitle(tr("Starting festival"));
- progressDialog.setModal(true);
- progressDialog.setLabel(0);
- progressDialog.setCancelButton(0);
- progressDialog.show();
+ QStringList voiceList = getVoiceList(getSetting(eSERVERPATH)->current().toString());
+ getSetting(eVOICE)->setList(voiceList);
+ if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0));
+ else getSetting(eVOICE)->setCurrent("");
+}
+
+void TTSFestival::startServer(QString path)
+{
+ if(!configOk())
+ return;
+
+ if(path == "")
+ path = settings->subValue("festival-server",RbSettings::TtsPath).toString();
+
+ serverProcess.start(QString("%1 --server").arg(path));
+ serverProcess.waitForStarted();
- QApplication::processEvents(); // actually show the dialog
+ queryServer("(getpid)",300,path);
+ if(serverProcess.state() == QProcess::Running)
+ qDebug() << "Festival is up and running";
+ else
+ qDebug() << "Festival failed to start";
+}
- startServer();
+void TTSFestival::ensureServerRunning(QString path)
+{
+ if(serverProcess.state() != QProcess::Running)
+ {
+ startServer(path);
}
}
bool TTSFestival::start(QString* errStr)
{
- (void) errStr;
- ensureServerRunning();
- if (!settings->subValue("festival", RbSettings::TtsVoice).toString().isEmpty())
+ (void) errStr;
+ ensureServerRunning();
+ if (!settings->subValue("festival",RbSettings::TtsVoice).toString().isEmpty())
queryServer(QString("(voice.select '%1)")
.arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
- return true;
+ return true;
}
bool TTSFestival::stop()
{
- serverProcess.terminate();
- serverProcess.kill();
+ serverProcess.terminate();
+ serverProcess.kill();
- return true;
+ return true;
}
TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
{
- qDebug() << text << "->" << wavfile;
-
- QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
- QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(paths[1]).arg(wavfile);
- qDebug() << cmd;
-
- QProcess clientProcess;
- clientProcess.start(cmd);
- clientProcess.write(QString("%1.\n").arg(text).toAscii());
- clientProcess.waitForBytesWritten();
- clientProcess.closeWriteChannel();
- clientProcess.waitForReadyRead();
- QString response = clientProcess.readAll();
- response = response.trimmed();
- if(!response.contains("Utterance"))
- {
- qDebug() << "Could not voice string: " << response;
- *errStr = tr("engine could not voice string");
- return Warning;
- /* do not stop the voicing process because of a single string
- TODO: needs proper settings */
- }
- clientProcess.closeReadChannel(QProcess::StandardError);
- clientProcess.closeReadChannel(QProcess::StandardOutput);
- clientProcess.terminate();
- clientProcess.kill();
-
- return NoError;
+ qDebug() << text << "->" << wavfile;
+
+ QString path = settings->subValue("festival-client",RbSettings::TtsPath).toString();
+ QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(path).arg(wavfile);
+ qDebug() << cmd;
+
+ QProcess clientProcess;
+ clientProcess.start(cmd);
+ clientProcess.write(QString("%1.\n").arg(text).toAscii());
+ clientProcess.waitForBytesWritten();
+ clientProcess.closeWriteChannel();
+ clientProcess.waitForReadyRead();
+ QString response = clientProcess.readAll();
+ response = response.trimmed();
+ if(!response.contains("Utterance"))
+ {
+ qDebug() << "Could not voice string: " << response;
+ *errStr = tr("engine could not voice string");
+ return Warning;
+ /* do not stop the voicing process because of a single string
+ TODO: needs proper settings */
+ }
+ clientProcess.closeReadChannel(QProcess::StandardError);
+ clientProcess.closeReadChannel(QProcess::StandardOutput);
+ clientProcess.terminate();
+ clientProcess.kill();
+
+ return NoError;
}
bool TTSFestival::configOk()
{
- QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
- if(paths.size() != 2)
- return false;
- bool ret = QFileInfo(paths[0]).isExecutable() &&
- QFileInfo(paths[1]).isExecutable();
- if(settings->subValue("festival", RbSettings::TtsVoice).toString().size() > 0
- && voices.size() > 0)
- ret = ret && (voices.indexOf(settings->subValue("festival",
- RbSettings::TtsVoice).toString()) != -1);
- return ret;
-}
-
-void TTSFestival::showCfg()
-{
-#ifndef CONSOLE
- TTSFestivalGui gui(this);
-#endif
- gui.setCfg(settings);
- gui.showCfg();
+ QString serverPath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
+ QString clientPath = settings->subValue("festival-client",RbSettings::TtsVoice).toString();
+
+ bool ret = QFileInfo(serverPath).isExecutable() &&
+ QFileInfo(clientPath).isExecutable();
+ if(settings->subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0)
+ ret = ret && (voices.indexOf(settings->subValue("festival",RbSettings::TtsVoice).toString()) != -1);
+ return ret;
}
-QStringList TTSFestival::getVoiceList()
+QStringList TTSFestival::getVoiceList(QString path)
{
- if(!configOk())
- return QStringList();
-
- if(voices.size() > 0)
- {
- qDebug() << "Using voice cache";
- return voices;
- }
- QString response = queryServer("(voice.list)");
-
- // get the 2nd line. It should be (<voice_name>, <voice_name>)
- response = response.mid(response.indexOf('\n') + 1, -1);
- response = response.left(response.indexOf('\n')).trimmed();
-
- voices = response.mid(1, response.size()-2).split(' ');
-
- voices.sort();
- if (voices.size() == 1 && voices[0].size() == 0)
- voices.removeAt(0);
- if (voices.size() > 0)
- qDebug() << "Voices: " << voices;
- else
- qDebug() << "No voices.";
- return voices;
+ if(!configOk())
+ return QStringList();
+
+ if(voices.size() > 0)
+ {
+ qDebug() << "Using voice cache";
+ return voices;
+ }
+
+ QString response = queryServer("(voice.list)",3000,path);
+
+ // get the 2nd line. It should be (<voice_name>, <voice_name>)
+ response = response.mid(response.indexOf('\n') + 1, -1);
+ response = response.left(response.indexOf('\n')).trimmed();
+
+ voices = response.mid(1, response.size()-2).split(' ');
+
+ voices.sort();
+ if (voices.size() == 1 && voices[0].size() == 0)
+ voices.removeAt(0);
+ if (voices.size() > 0)
+ qDebug() << "Voices: " << voices;
+ else
+ qDebug() << "No voices.";
+
+ return voices;
}
-QString TTSFestival::getVoiceInfo(QString voice)
+QString TTSFestival::getVoiceInfo(QString voice,QString path)
{
- if(!configOk())
- return "";
-
- if(!getVoiceList().contains(voice))
- return "";
-
- if(voiceDescriptions.contains(voice))
- return voiceDescriptions[voice];
-
- QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000);
-
- if (response == "")
- {
- voiceDescriptions[voice]=tr("No description available");
- }
- else
- {
- response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard));
- qDebug() << "voiceInfo w/o descr: " << response;
- response = response.remove(')');
- QStringList responseLines = response.split('(', QString::SkipEmptyParts);
- responseLines.removeAt(0); // the voice name itself
-
- QString description;
- foreach(QString line, responseLines)
- {
- line = line.remove('(');
- line = line.simplified();
-
- line[0] = line[0].toUpper(); // capitalize the key
-
- int firstSpace = line.indexOf(' ');
- if (firstSpace > 0)
- {
- line = line.insert(firstSpace, ':'); // add a colon between the key and the value
- line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value
- }
-
- description += line + "\n";
- }
- voiceDescriptions[voice] = description.trimmed();
- }
- return voiceDescriptions[voice];
+ if(!configOk())
+ return "";
+
+ if(!getVoiceList().contains(voice))
+ return "";
+
+ if(voiceDescriptions.contains(voice))
+ return voiceDescriptions[voice];
+
+ QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000,path);
+
+ if (response == "")
+ {
+ voiceDescriptions[voice]=tr("No description available");
+ }
+ else
+ {
+ response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard));
+ qDebug() << "voiceInfo w/o descr: " << response;
+ response = response.remove(')');
+ QStringList responseLines = response.split('(', QString::SkipEmptyParts);
+ responseLines.removeAt(0); // the voice name itself
+
+ QString description;
+ foreach(QString line, responseLines)
+ {
+ line = line.remove('(');
+ line = line.simplified();
+
+ line[0] = line[0].toUpper(); // capitalize the key
+
+ int firstSpace = line.indexOf(' ');
+ if (firstSpace > 0)
+ {
+ line = line.insert(firstSpace, ':'); // add a colon between the key and the value
+ line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value
+ }
+
+ description += line + "\n";
+ }
+ voiceDescriptions[voice] = description.trimmed();
+ }
+
+ return voiceDescriptions[voice];
}
-QString TTSFestival::queryServer(QString query, int timeout)
+QString TTSFestival::queryServer(QString query, int timeout,QString path)
{
- if(!configOk())
- return "";
-
- ensureServerRunning();
-
- qDebug() << "queryServer with " << query;
- QString response;
-
- QDateTime endTime;
- if(timeout > 0)
- endTime = QDateTime::currentDateTime().addMSecs(timeout);
-
- /* Festival is *extremely* unreliable. Although at this
- * point we are sure that SIOD is accepting commands,
- * we might end up with an empty response. Hence, the loop.
- */
- while(true)
- {
- QApplication::processEvents(QEventLoop::AllEvents, 50);
- QTcpSocket socket;
-
- socket.connectToHost("localhost", 1314);
- socket.waitForConnected();
-
- if(socket.state() == QAbstractSocket::ConnectedState)
+ if(!configOk())
+ return "";
+
+ // this operation could take some time
+ emit busy();
+
+ ensureServerRunning(path);
+
+ qDebug() << "queryServer with " << query;
+ QString response;
+
+ QDateTime endTime;
+ if(timeout > 0)
+ endTime = QDateTime::currentDateTime().addMSecs(timeout);
+
+ /* Festival is *extremely* unreliable. Although at this
+ * point we are sure that SIOD is accepting commands,
+ * we might end up with an empty response. Hence, the loop.
+ */
+ while(true)
+ {
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+ QTcpSocket socket;
+
+ socket.connectToHost("localhost", 1314);
+ socket.waitForConnected();
+
+ if(socket.state() == QAbstractSocket::ConnectedState)
+ {
+ socket.write(QString("%1\n").arg(query).toAscii());
+ socket.waitForBytesWritten();
+ socket.waitForReadyRead();
+
+ response = socket.readAll().trimmed();
+
+ if (response != "LP" && response != "")
+ break;
+ }
+ socket.abort();
+ socket.disconnectFromHost();
+
+ if(timeout > 0 && QDateTime::currentDateTime() >= endTime)
{
- socket.write(QString("%1\n").arg(query).toAscii());
- socket.waitForBytesWritten();
- socket.waitForReadyRead();
-
- response = socket.readAll().trimmed();
-
- if (response != "LP" && response != "")
- break;
+ emit busyEnd();
+ return "";
}
- socket.abort();
- socket.disconnectFromHost();
-
- if(timeout > 0 && QDateTime::currentDateTime() >= endTime)
- return "";
-
- /* make sure we wait a little as we don't want to flood the server with requests */
- QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500);
- while(QDateTime::currentDateTime() < tmpEndTime)
- QApplication::processEvents(QEventLoop::AllEvents);
- }
- if(response == "nil")
- return "";
-
- QStringList lines = response.split('\n');
- if(lines.size() > 2)
+ /* make sure we wait a little as we don't want to flood the server with requests */
+ QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500);
+ while(QDateTime::currentDateTime() < tmpEndTime)
+ QCoreApplication::processEvents(QEventLoop::AllEvents);
+ }
+ if(response == "nil")
{
- lines.removeFirst();
- lines.removeLast();
+ emit busyEnd();
+ return "";
}
- else
- qDebug() << "Response too short: " << response;
+
+ QStringList lines = response.split('\n');
+ if(lines.size() > 2)
+ {
+ lines.removeFirst();
+ lines.removeLast();
+ }
+ else
+ qDebug() << "Response too short: " << response;
+
+ emit busyEnd();
return lines.join("\n");
+
}
diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h
index c9262b74c6..093ccd6138 100644
--- a/rbutil/rbutilqt/tts.h
+++ b/rbutil/rbutilqt/tts.h
@@ -19,52 +19,49 @@
*
****************************************************************************/
-
+
#ifndef TTS_H
#define TTS_H
#include "rbsettings.h"
#include <QtCore>
#include <QProcess>
-#include <QProgressDialog>
#include <QDateTime>
#include <QRegExp>
#include <QTcpSocket>
-#ifndef CONSOLE
-#include "ttsgui.h"
-#else
-#include "ttsguicli.h"
-#endif
+#include "encttssettings.h"
enum TTSStatus{ FatalError, NoError, Warning };
-class TTSSapi;
-#if defined(Q_OS_LINUX)
-class TTSFestival;
-#endif
-class TTSBase : public QObject
+
+class TTSBase : public EncTtsSettingInterface
{
Q_OBJECT
public:
- TTSBase();
- virtual TTSStatus voice(QString text,QString wavfile, QString* errStr)
- { (void) text; (void) wavfile; (void) errStr; return FatalError;}
- virtual bool start(QString *errStr) { (void)errStr; return false; }
- virtual bool stop() { return false; }
- virtual void showCfg(){}
- virtual bool configOk() { return false; }
-
- virtual void setCfg(RbSettings* sett) { settings = sett; }
-
- static TTSBase* getTTS(QString ttsname);
+ TTSBase(QObject *parent);
+ //! Child class should generate a clip
+ virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) =0;
+ //! Child class should do startup
+ virtual bool start(QString *errStr) =0;
+ //! child class should stop
+ virtual bool stop() =0;
+
+ // configuration
+ //! Child class should return true, when configuration is good
+ virtual bool configOk()=0;
+ //! Child class should generate and insertSetting(..) its settings
+ virtual void generateSettings() = 0;
+ //! Chlid class should commit the Settings to permanent storage
+ virtual void saveSettings() = 0;
+
+ // static functions
+ static TTSBase* getTTS(QObject* parent,QString ttsname);
static QStringList getTTSList();
- static QString getTTSName(QString tts);
-
- public slots:
- virtual void accept(void){}
- virtual void reject(void){}
- virtual void reset(void){}
-
+ static QString getTTSName(QString tts);
+
+ // sets the config. Users of TTS classes, always have to call this first
+ void setCfg(RbSettings* sett) { settings = sett; }
+
private:
//inits the tts List
static void initTTSList();
@@ -72,26 +69,42 @@ class TTSBase : public QObject
protected:
RbSettings* settings;
static QMap<QString,QString> ttsList;
- static QMap<QString,TTSBase*> ttsCache;
};
class TTSSapi : public TTSBase
{
- Q_OBJECT
+ //! Enum to identify the settings
+ enum ESettings
+ {
+ eLANGUAGE,
+ eVOICE,
+ eSPEED,
+ eOPTIONS
+ };
+
+ Q_OBJECT
public:
- TTSSapi();
- virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
- virtual bool start(QString *errStr);
- virtual bool stop();
- virtual void showCfg();
- virtual bool configOk();
-
+ TTSSapi(QObject* parent=NULL);
+
+ TTSStatus voice(QString text,QString wavfile, QString *errStr);
+ bool start(QString *errStr);
+ bool stop();
+
+ // for settings
+ bool configOk();
+ void generateSettings();
+ void saveSettings();
+
+ private slots:
+ void updateVoiceList();
+
+ private:
QStringList getVoiceList(QString language);
- private:
+
QProcess* voicescript;
QTextStream* voicestream;
QString defaultLanguage;
-
+
QString m_TTSexec;
QString m_TTSOpts;
QString m_TTSTemplate;
@@ -104,16 +117,23 @@ class TTSSapi : public TTSBase
class TTSExes : public TTSBase
{
+ enum ESettings
+ {
+ eEXEPATH,
+ eOPTIONS
+ };
+
Q_OBJECT
public:
- TTSExes(QString name);
- virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
- virtual bool start(QString *errStr);
- virtual bool stop() {return true;}
- virtual void showCfg();
- virtual bool configOk();
-
- virtual void setCfg(RbSettings* sett);
+ TTSExes(QString name,QObject* parent=NULL);
+ TTSStatus voice(QString text,QString wavfile, QString *errStr);
+ bool start(QString *errStr);
+ bool stop() {return true;}
+
+ // for settings
+ void generateSettings();
+ void saveSettings();
+ bool configOk();
private:
QString m_name;
@@ -125,24 +145,41 @@ class TTSExes : public TTSBase
class TTSFestival : public TTSBase
{
- Q_OBJECT
- public:
- ~TTSFestival();
- virtual bool configOk();
- virtual bool start(QString *errStr);
- virtual bool stop();
- virtual void showCfg();
- virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
-
- QStringList getVoiceList();
- QString getVoiceInfo(QString voice);
- private:
- inline void startServer();
- inline void ensureServerRunning();
- QString queryServer(QString query, int timeout = -1);
- QProcess serverProcess;
- QStringList voices;
- QMap<QString, QString> voiceDescriptions;
+ enum ESettings
+ {
+ eSERVERPATH,
+ eCLIENTPATH,
+ eVOICE,
+ eVOICEDESC
+ };
+
+ Q_OBJECT
+public:
+ TTSFestival(QObject* parent=NULL) :TTSBase(parent) {}
+ ~TTSFestival();
+ bool start(QString *errStr);
+ bool stop();
+ TTSStatus voice(QString text,QString wavfile, QString *errStr);
+
+ // for settings
+ bool configOk();
+ void generateSettings();
+ void saveSettings();
+
+private slots:
+ void updateVoiceList();
+ void updateVoiceDescription();
+ void clearVoiceDescription();
+private:
+ QStringList getVoiceList(QString path ="");
+ QString getVoiceInfo(QString voice,QString path ="");
+
+ inline void startServer(QString path="");
+ inline void ensureServerRunning(QString path="");
+ QString queryServer(QString query, int timeout = -1,QString path="");
+ QProcess serverProcess;
+ QStringList voices;
+ QMap<QString, QString> voiceDescriptions;
};
#endif
diff --git a/rbutil/rbutilqt/ttsexescfgfrm.ui b/rbutil/rbutilqt/ttsexescfgfrm.ui
deleted file mode 100644
index a8df51c847..0000000000
--- a/rbutil/rbutilqt/ttsexescfgfrm.ui
+++ /dev/null
@@ -1,158 +0,0 @@
-<ui version="4.0" >
- <class>TTSExesCfgFrm</class>
- <widget class="QDialog" name="TTSExesCfgFrm" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>463</width>
- <height>214</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Configuration</string>
- </property>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
- <string>Configure TTS Engine</string>
- </property>
- <layout class="QVBoxLayout" >
- <item>
- <widget class="QLabel" name="label" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>255</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Path to TTS Engine</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QLineEdit" name="ttspath" />
- </item>
- <item>
- <widget class="QPushButton" name="browse" >
- <property name="text" >
- <string>&amp;Browse</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>TTS options</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="ttsoptions" />
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QPushButton" name="reset" >
- <property name="text" >
- <string>Reset</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonOk" >
- <property name="text" >
- <string>&amp;Ok</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel" >
- <property name="text" >
- <string>&amp;Cancel</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="rbutilqt.qrc" />
- </resources>
- <connections>
- <connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
- <receiver>TTSExesCfgFrm</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>253</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
- <receiver>TTSExesCfgFrm</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>352</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel" >
- <x>203</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/rbutil/rbutilqt/ttsfestivalcfgform.ui b/rbutil/rbutilqt/ttsfestivalcfgform.ui
deleted file mode 100644
index bdebf3fe93..0000000000
--- a/rbutil/rbutilqt/ttsfestivalcfgform.ui
+++ /dev/null
@@ -1,322 +0,0 @@
-<ui version="4.0" >
- <class>TTSFestivalCfgFrm</class>
- <widget class="QDialog" name="TTSFestivalCfgFrm" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>340</width>
- <height>316</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Configuration</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_4" >
- <item row="3" column="1" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- <property name="centerButtons" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2" >
- <widget class="QGroupBox" name="execsBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title" >
- <string>Executables</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2" >
- <property name="topMargin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>0</number>
- </property>
- <item row="0" column="0" >
- <layout class="QGridLayout" name="gridLayout" >
- <property name="sizeConstraint" >
- <enum>QLayout::SetMinimumSize</enum>
- </property>
- <property name="horizontalSpacing" >
- <number>6</number>
- </property>
- <property name="verticalSpacing" >
- <number>0</number>
- </property>
- <item row="0" column="0" colspan="2" >
- <widget class="QLabel" name="label" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Path to Festival server</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLineEdit" name="serverPath" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>215</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="serverButton" >
- <property name="text" >
- <string>Browse</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2" >
- <widget class="QLabel" name="label_2" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Path to Festival client</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLineEdit" name="clientPath" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>215</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QPushButton" name="clientButton" >
- <property name="text" >
- <string>Browse</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="0" >
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>70</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" >
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>153</width>
- <height>43</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0" colspan="2" >
- <widget class="QGroupBox" name="groupBox2" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="title" >
- <string>Server voice</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_3" >
- <property name="leftMargin" >
- <number>6</number>
- </property>
- <property name="topMargin" >
- <number>6</number>
- </property>
- <property name="bottomMargin" >
- <number>6</number>
- </property>
- <property name="horizontalSpacing" >
- <number>6</number>
- </property>
- <property name="verticalSpacing" >
- <number>0</number>
- </property>
- <item row="0" column="0" colspan="2" >
- <widget class="QLabel" name="voiceLabel" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Select a voice</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="refreshButton" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>&amp;Refresh</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >
- <normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QComboBox" name="voicesBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="4" column="1" >
- <widget class="QLabel" name="descriptionLabel" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QCheckBox" name="showDescriptionCheckbox" >
- <property name="text" >
- <string>Show voice description</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- <zorder>buttonBox</zorder>
- <zorder>execsBox</zorder>
- <zorder>horizontalSpacer</zorder>
- <zorder>verticalSpacer</zorder>
- <zorder>groupBox2</zorder>
- </widget>
- <tabstops>
- <tabstop>serverPath</tabstop>
- <tabstop>serverButton</tabstop>
- <tabstop>clientPath</tabstop>
- <tabstop>clientButton</tabstop>
- <tabstop>refreshButton</tabstop>
- <tabstop>voicesBox</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources>
- <include location="rbutilqt.qrc" />
- </resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>TTSFestivalCfgFrm</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel" >
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>TTSFestivalCfgFrm</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel" >
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/rbutil/rbutilqt/ttsgui.cpp b/rbutil/rbutilqt/ttsgui.cpp
deleted file mode 100644
index ead32f17c3..0000000000
--- a/rbutil/rbutilqt/ttsgui.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2007 by Dominik Wenger
- * $Id$
- *
- * 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 "ttsgui.h"
-
-#include "rbsettings.h"
-#include "tts.h"
-#include "browsedirtree.h"
-
-TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent)
-{
- m_sapi= sapi;
- ui.setupUi(this);
- this->hide();
- connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
- connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString)));
- connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int)));
-}
-
-void TTSSapiGui::showCfg()
-{
- // try to get config from settings
- ui.ttsoptions->setText(settings->subValue("sapi", RbSettings::TtsOptions).toString());
- QString selLang = settings->subValue("sapi", RbSettings::TtsLanguage).toString();
- QString selVoice = settings->subValue("sapi", RbSettings::TtsVoice).toString();
- ui.speed->setValue(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
- if(settings->value(RbSettings::TtsUseSapi4).toBool())
- ui.usesapi4->setCheckState(Qt::Checked);
- else
- ui.usesapi4->setCheckState(Qt::Unchecked);
-
- // fill in language combobox
- QStringList languages = settings->languages();
-
- languages.sort();
- ui.languagecombo->clear();
- ui.languagecombo->addItems(languages);
-
- // set saved lang
- ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang));
-
- // fill in voice combobox
- updateVoices(selLang);
-
- // set saved lang
- ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice));
-
- //show dialog
- this->exec();
-
-}
-
-
-void TTSSapiGui::reset()
-{
- ui.ttsoptions->setText("");
- ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english"));
-}
-
-
-
-void TTSSapiGui::accept(void)
-{
- //save settings in user config
- settings->setSubValue("sapi", RbSettings::TtsOptions, ui.ttsoptions->text());
- settings->setSubValue("sapi", RbSettings::TtsLanguage, ui.languagecombo->currentText());
- settings->setSubValue("sapi", RbSettings::TtsVoice, ui.voicecombo->currentText());
- settings->setSubValue("sapi", RbSettings::TtsSpeed, ui.speed->value());
- if(ui.usesapi4->checkState() == Qt::Checked)
- settings->setValue(RbSettings::TtsUseSapi4, true);
- else
- settings->setValue(RbSettings::TtsUseSapi4, false);
- // sync settings
- settings->sync();
-
- this->done(0);
-}
-
-void TTSSapiGui::reject(void)
-{
- this->done(0);
-}
-
-void TTSSapiGui::updateVoices(QString language)
-{
- QStringList Voices = m_sapi->getVoiceList(language);
- ui.voicecombo->clear();
- ui.voicecombo->addItems(Voices);
-
-}
-
-void TTSSapiGui::useSapi4Changed(int)
-{
- if(ui.usesapi4->checkState() == Qt::Checked)
- settings->setValue(RbSettings::TtsUseSapi4, true);
- else
- settings->setValue(RbSettings::TtsUseSapi4, false);
- // sync settings
- settings->sync();
- updateVoices(ui.languagecombo->currentText());
-
-}
-
-TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent)
-{
- ui.setupUi(this);
- this->hide();
- connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
- connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
-}
-
-
-void TTSExesGui::reset()
-{
- ui.ttspath->setText("");
- ui.ttsoptions->setText("");
-}
-
-void TTSExesGui::showCfg(QString name)
-{
- m_name = name;
- // try to get config from settings
- QString exepath =settings->subValue(m_name, RbSettings::TtsPath).toString();
- ui.ttsoptions->setText(settings->subValue(m_name, RbSettings::TtsOptions).toString());
- ui.ttspath->setText(exepath);
-
- //show dialog
- this->exec();
-
-}
-
-void TTSExesGui::accept(void)
-{
- //save settings in user config
- settings->setSubValue(m_name, RbSettings::TtsPath, ui.ttspath->text());
- settings->setSubValue(m_name, RbSettings::TtsOptions, ui.ttsoptions->text());
- // sync settings
- settings->sync();
-
- this->done(0);
-}
-
-void TTSExesGui::reject(void)
-{
- this->done(0);
-}
-
-
-void TTSExesGui::browse()
-{
- BrowseDirtree browser(this);
- browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
-
- if(QFileInfo(ui.ttspath->text()).isDir())
- {
- browser.setDir(ui.ttspath->text());
- }
- if(browser.exec() == QDialog::Accepted)
- {
- qDebug() << browser.getSelected();
- QString exe = browser.getSelected();
- if(!QFileInfo(exe).isExecutable())
- return;
- ui.ttspath->setText(exe);
- }
-}
-
-TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) :
- QDialog(parent), festival(api)
-{
- ui.setupUi(this);
- this->setModal(true);
- this->setDisabled(true);
- this->show();
-
- connect(ui.clientButton, SIGNAL(clicked()), this, SLOT(onBrowseClient()));
- connect(ui.serverButton, SIGNAL(clicked()), this, SLOT(onBrowseServer()));
-
- connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(onRefreshButton()));
- connect(ui.voicesBox, SIGNAL(activated(QString)), this, SLOT(updateDescription(QString)));
- connect(ui.showDescriptionCheckbox, SIGNAL(stateChanged(int)), this, SLOT(onShowDescription(int)));
-}
-
-void TTSFestivalGui::showCfg()
-{
- qDebug() << "show\tpaths: " << settings->subValue("festival", RbSettings::TtsPath) << "\n"
- << "\tvoice: " << settings->subValue("festival", RbSettings::TtsVoice);
-
- // will populate the voices if the paths are correct,
- // otherwise, it will require the user to press Refresh
- updateVoices();
-
- // try to get config from settings
- QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
- if(paths.size() == 2)
- {
- ui.serverPath->setText(paths[0]);
- ui.clientPath->setText(paths[1]);
- }
-
- this->setEnabled(true);
- this->exec();
-}
-
-void TTSFestivalGui::accept(void)
-{
- //save settings in user config
- QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
- qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText();
- settings->setSubValue("festival", RbSettings::TtsPath, newPath);
- settings->setSubValue("festival", RbSettings::TtsVoice, ui.voicesBox->currentText());
-
- settings->sync();
-
- this->done(0);
-}
-
-void TTSFestivalGui::reject(void)
-{
- this->done(0);
-}
-
-void TTSFestivalGui::onBrowseClient()
-{
- BrowseDirtree browser(this);
- browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
-
- QFileInfo currentPath(ui.clientPath->text().trimmed());
- if(currentPath.isDir())
- {
- browser.setDir(ui.clientPath->text());
- }
- else if (currentPath.isFile())
- {
- browser.setDir(currentPath.dir().absolutePath());
- }
- if(browser.exec() == QDialog::Accepted)
- {
- qDebug() << browser.getSelected();
- QString exe = browser.getSelected();
- if(!QFileInfo(exe).isExecutable())
- return;
- ui.clientPath->setText(exe);
- }
-}
-
-void TTSFestivalGui::onBrowseServer()
-{
- BrowseDirtree browser(this);
- browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
-
- QFileInfo currentPath(ui.serverPath->text().trimmed());
- if(currentPath.isDir())
- {
- browser.setDir(ui.serverPath->text());
- }
- else if (currentPath.isFile())
- {
- browser.setDir(currentPath.dir().absolutePath());
- }
- if(browser.exec() == QDialog::Accepted)
- {
- qDebug() << browser.getSelected();
- QString exe = browser.getSelected();
- if(!QFileInfo(exe).isExecutable())
- return;
- ui.serverPath->setText(exe);
- }
-}
-
-void TTSFestivalGui::onRefreshButton()
-{
- /* Temporarily commit the settings so that we get the new path when we check for voices */
- QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
- QString oldPath = settings->subValue("festival", RbSettings::TtsPath).toString();
- qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath);
-
- if(newPath != oldPath)
- {
- qDebug() << "Using new paths for getVoiceList";
- settings->setSubValue("festival", RbSettings::TtsPath, newPath);
- settings->sync();
- }
-
- updateVoices();
-
- if(newPath != oldPath)
- {
- settings->setSubValue("festival", RbSettings::TtsPath, oldPath);
- settings->sync();
- }
-}
-
-void TTSFestivalGui::onShowDescription(int state)
-{
- if(state == Qt::Unchecked)
- ui.descriptionLabel->setText("");
- else
- updateDescription(ui.voicesBox->currentText());
-}
-
-void TTSFestivalGui::updateVoices()
-{
- ui.voicesBox->clear();
- ui.voicesBox->addItem(tr("Loading.."));
-
- QStringList voiceList = festival->getVoiceList();
- ui.voicesBox->clear();
- ui.voicesBox->addItems(voiceList);
-
- ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(
- settings->subValue("festival", RbSettings::TtsVoice).toString()));
-
- updateDescription(settings->subValue("festival", RbSettings::TtsVoice).toString());
-}
-
-void TTSFestivalGui::updateDescription(QString value)
-{
- if(ui.showDescriptionCheckbox->checkState() == Qt::Checked)
- {
- ui.descriptionLabel->setText(tr("Querying festival"));
- ui.descriptionLabel->setText(festival->getVoiceInfo(value));
- }
-}
-
diff --git a/rbutil/rbutilqt/ttsgui.h b/rbutil/rbutilqt/ttsgui.h
deleted file mode 100644
index 693555cb6c..0000000000
--- a/rbutil/rbutilqt/ttsgui.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2007 by Dominik Wenger
- * $Id$
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef TTSGUI_H
-#define TTSGUI_H
-
-#include <QtGui>
-
-#include "ui_ttsexescfgfrm.h"
-#include "ui_sapicfgfrm.h"
-#include "ui_ttsfestivalcfgform.h"
-
-class RbSettings;
-class TTSSapi;
-class TTSFestival;
-
-class TTSSapiGui : public QDialog
-{
- Q_OBJECT
- public:
- TTSSapiGui(TTSSapi* sapi,QDialog* parent = NULL);
-
- void showCfg();
- void setCfg(RbSettings* sett){settings = sett;}
- public slots:
-
- virtual void accept(void);
- virtual void reject(void);
- virtual void reset(void);
- void updateVoices(QString language);
- void useSapi4Changed(int);
- private:
- Ui::SapiCfgFrm ui;
- RbSettings* settings;
- TTSSapi* m_sapi;
-};
-
-class TTSExesGui : public QDialog
-{
- Q_OBJECT
- public:
- TTSExesGui(QDialog* parent = NULL);
-
- void showCfg(QString m_name);
- void setCfg(RbSettings* sett){settings = sett;}
-
- public slots:
- virtual void accept(void);
- virtual void reject(void);
- virtual void reset(void);
- void browse(void);
- private:
- Ui::TTSExesCfgFrm ui;
- RbSettings* settings;
- QString m_name;
-};
-
-class TTSFestivalGui : public QDialog
-{
- Q_OBJECT
- public:
- TTSFestivalGui(TTSFestival* festival, QDialog* parent = NULL);
-
- void showCfg();
- void setCfg(RbSettings* sett){settings = sett;}
-
- public slots:
- virtual void accept(void);
- virtual void reject(void);
- //virtual void reset(void);
-
- void onRefreshButton();
- void onShowDescription(int state);
- void onBrowseServer();
- void onBrowseClient();
- private:
- Ui::TTSFestivalCfgFrm ui;
- RbSettings* settings;
- TTSFestival* festival;
-
- void updateVoices();
- private slots:
- void updateDescription(QString value);
-};
-
-#endif
-
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp
index 14af9adb24..c38977af96 100644
--- a/rbutil/rbutilqt/voicefile.cpp
+++ b/rbutil/rbutilqt/voicefile.cpp
@@ -128,7 +128,7 @@ void VoiceFileCreator::downloadDone(bool error)
}
//tts
- m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
+ m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString());
m_tts->setCfg(settings);
QString errStr;
@@ -142,7 +142,7 @@ void VoiceFileCreator::downloadDone(bool error)
}
// Encoder
- m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
+ m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString());
m_enc->setCfg(settings);
if(!m_enc->start())
diff --git a/rbutil/rbutilqt/voicefile.h b/rbutil/rbutilqt/voicefile.h
index 39205db756..1a5d267b1f 100644
--- a/rbutil/rbutilqt/voicefile.h
+++ b/rbutil/rbutilqt/voicefile.h
@@ -38,7 +38,7 @@ class VoiceFileCreator :public QObject
{
Q_OBJECT
public:
- VoiceFileCreator(QObject* parent=0);
+ VoiceFileCreator(QObject* parent);
//start creation
bool createVoiceFile(ProgressloggerInterface* logger);