summaryrefslogtreecommitdiffstats
path: root/kttsd/filters/talkerchooser
diff options
context:
space:
mode:
Diffstat (limited to 'kttsd/filters/talkerchooser')
-rw-r--r--kttsd/filters/talkerchooser/Makefile.am25
-rw-r--r--kttsd/filters/talkerchooser/female_notifications_rc10
-rw-r--r--kttsd/filters/talkerchooser/kttsd_talkerchooserplugin.desktop89
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserconf.cpp269
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserconf.h134
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserconfwidget.ui319
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserplugin.cpp32
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserproc.cpp148
-rw-r--r--kttsd/filters/talkerchooser/talkerchooserproc.h87
9 files changed, 1113 insertions, 0 deletions
diff --git a/kttsd/filters/talkerchooser/Makefile.am b/kttsd/filters/talkerchooser/Makefile.am
new file mode 100644
index 0000000..66f857d
--- /dev/null
+++ b/kttsd/filters/talkerchooser/Makefile.am
@@ -0,0 +1,25 @@
+INCLUDES = \
+ -I$(top_srcdir)/kttsd/libkttsd -I$(top_builddir)/kttsd/libkttsd \
+ $(all_includes)
+
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = libkttsd_talkerchooserplugin.la
+
+libkttsd_talkerchooserplugin_la_SOURCES = \
+ talkerchooserconfwidget.ui \
+ talkerchooserconf.cpp \
+ talkerchooserproc.cpp \
+ talkerchooserplugin.cpp
+libkttsd_talkerchooserplugin_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries)
+libkttsd_talkerchooserplugin_la_LIBADD = $(top_builddir)/kttsd/libkttsd/libkttsd.la
+
+services_DATA = kttsd_talkerchooserplugin.desktop
+servicesdir = $(kde_servicesdir)
+
+# Install data files.
+talkerchooserdatadir = $(kde_datadir)/kttsd/talkerchooser/
+talkerchooserdata_DATA = \
+ female_notifications_rc
+
+noinst_HEADERS = talkerchooserconfwidget.h
diff --git a/kttsd/filters/talkerchooser/female_notifications_rc b/kttsd/filters/talkerchooser/female_notifications_rc
new file mode 100644
index 0000000..1cbd94c
--- /dev/null
+++ b/kttsd/filters/talkerchooser/female_notifications_rc
@@ -0,0 +1,10 @@
+[Filter]
+AppIDs=knotify
+Gender=*female
+LanguageCode=
+MatchRegExp=
+Rate=
+SynthName=
+TalkerCode=<voice gender="*female" />
+UserFilterName=Obsolete. Use Notifications tab instead.
+Volume=
diff --git a/kttsd/filters/talkerchooser/kttsd_talkerchooserplugin.desktop b/kttsd/filters/talkerchooser/kttsd_talkerchooserplugin.desktop
new file mode 100644
index 0000000..cdf1e45
--- /dev/null
+++ b/kttsd/filters/talkerchooser/kttsd_talkerchooserplugin.desktop
@@ -0,0 +1,89 @@
+[Desktop Entry]
+Name=Talker Chooser
+Name[bg]=Избор на глас
+Name[ca]=Selector de parla
+Name[cs]=Výběr hlasu
+Name[da]=Vælger af oplæser
+Name[de]=Sprecherauswahl
+Name[el]=Επιλογή εκφωνητή
+Name[es]=Selector de lectores
+Name[et]=Kõneleja valimine
+Name[fa]=انتخاب‌کنندۀ گوینده
+Name[fi]=Puhujan valitsin
+Name[fr]=Sélecteur de voix
+Name[ga]=Roghnóir Cainteora
+Name[gl]=Escolla de Locutor
+Name[hu]=Hangválasztó
+Name[is]=Talveljari
+Name[it]=Selezione dell'oratore
+Name[ja]=話者選択
+Name[ka]=მოლაპარაკის ამომრჩეველი
+Name[km]=ឧបករណ៍​ជ្រើស​អ្នក​និយាយ
+Name[mk]=Избирач на говорникот
+Name[ms]=Pemilih Penutur
+Name[nb]=Snakkervelger
+Name[nds]=Snacker-Utwahl
+Name[ne]=वक्ता चयनकर्ता
+Name[nl]=Spreker kiezen
+Name[pa]=ਬੋਲਚਾਲ ਚੋਣਕਾਰ
+Name[pl]=Wybieranie Mówców
+Name[pt]=Escolha de Orador
+Name[pt_BR]=Escolha do Talker
+Name[ru]=Диктор
+Name[sk]=Voľba hovorcu
+Name[sl]=Izbirnik govornika
+Name[sr]=Бирач говорника
+Name[sr@Latn]=Birač govornika
+Name[sv]=Urval av talare
+Name[ta]=டாக்கர் தேர்ந்தெடுப்பான்
+Name[tg]=Диктор
+Name[tr]=Konuşmacı Seçici
+Name[uk]=Вибір диктора
+Name[vi]=Trình chọn Máy nói
+Name[zh_TW]=語音選擇器
+Comment=Generic Talker Chooser Filter Plugin for KTTS
+Comment[bg]=Приставка за избор на глас за KTTS
+Comment[ca]=Connector del filtre selector genèric de parla pel KTTS
+Comment[cs]=Modul filtru výběru hlasu KTTS
+Comment[da]=Generisk vælger af oplæser for KTTS
+Comment[de]=Generischer Sprecherauswahlfilter für KTTS
+Comment[el]=Γενικό φίλτρο πρόσθετο επιλογής εκφωνητή για το KTTS
+Comment[es]=Complemento de audio para KTTSD
+Comment[et]=KTTS-i üldine kõneleja valimise filtri plugin
+Comment[eu]=KTTS-ren hizlariak hautatzeko iragazk-plugin generikoa
+Comment[fa]=وصلۀ پالایۀ انتخاب‌کنندۀ گویندۀ عمومی برای KTTS
+Comment[fi]=Yleinen puhujan valitsin suodatin liitännäinen KTTS-ohjelmalle
+Comment[fr]=Module de filtrage de sélection de voix pour KTTS
+Comment[gl]=Plugin para Escoller o Locutor para KTTS
+Comment[hu]=Általános hangkiválasztó modul a KTTS-hez
+Comment[is]=Almennt talvalsíforrit fyrir KTTS
+Comment[it]=Plugin generico per il filtro di scelta dell'oratore per KTTS
+Comment[ja]=KTTS 用汎用話者選択フィルタプラグイン
+Comment[ka]=მოლაპარაკის ამომრჩეველის ზოგადი ფილტრის მოდული KTTS-სთვის
+Comment[km]=កម្មវិធី​ជំនួយ​ឧបករណ៍​ជ្រើស​រើស​អ្នក​និយាយ​ទូទៅ​សម្រាប់ KTTS
+Comment[mk]=Филтер за KTTS за избирач на општ говорник
+Comment[ms]=Plugin Penapis Pemilih Penutur Generik bagi KTTS
+Comment[nb]=Filter-programtillegg til KTTS for snakkervalg
+Comment[nds]=KTTS-Filtermoduul för dat Utsöken vun den Snacker
+Comment[ne]=KTTS का लागि जेनेरीक वक्ता चयनकर्ता फिल्टर प्लगइन
+Comment[nl]=Generieke plugin om de spreker te kiezen voor KTTS
+Comment[pa]=KTTS ਲਈ ਸਧਾਰਨ ਬੋਲੀ ਚੋਣਕਾਰ ਫਿਲਟਰ ਪਲੱਗਿੰਨ
+Comment[pl]=Wtyczka wyboru Mówców dla KTTS
+Comment[pt]='Plugin' Genérico de Escolha de Orador para o KTTS
+Comment[pt_BR]=Plug-in de Filtro Genérico Para Escolha do Talker do KTTS
+Comment[ru]=Фильтр выбора диктора для KTTS
+Comment[sk]=Všeobecný modul filra na voľbu hovorcu v KTTS
+Comment[sl]=Filtrni vstavek KTTS za generični izbirnik govorca
+Comment[sr]=Генерички филтерски прикључак KTTS-а за бирач говорника
+Comment[sr@Latn]=Generički filterski priključak KTTS-a za birač govornika
+Comment[sv]=Insticksprogram för KTTS med generellt urvalsfilter för talare
+Comment[ta]=KTTS க்கான ஜெனரிக் பேச்சாளர் தேர்ந்தெடுப்பான அலங்கார சொருகுப்பொருள்
+Comment[tg]=Филтри интихоби диктор барои KTTS
+Comment[tr]=KTTS için Genel Konuşma Seçici Süzgeci Eklentisi
+Comment[uk]=Загальний втулок Фільтра вибору диктора для KTTS
+Comment[vi]=Trình bổ sung Lọc Chọn Máy nói Chung cho KTTS
+Comment[zh_TW]=KTTS 使用的語音選擇外掛程式
+Type=Service
+ServiceTypes=KTTSD/FilterPlugin
+X-KDE-Library=libkttsd_talkerchooserplugin
+X-KDE-Languages=en,en_US,en_GB,en_CA,es,es_mx,cy,de,fi,cs,pl
diff --git a/kttsd/filters/talkerchooser/talkerchooserconf.cpp b/kttsd/filters/talkerchooser/talkerchooserconf.cpp
new file mode 100644
index 0000000..0dbf53f
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserconf.cpp
@@ -0,0 +1,269 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generic Talker Chooser Filter Configuration class.
+ -------------------
+ Copyright:
+ (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ******************************************************************************/
+
+// Qt includes.
+#include <qstring.h>
+#include <qhbox.h>
+#include <qlayout.h>
+
+// KDE includes.
+#include <klocale.h>
+#include <klineedit.h>
+#include <kdialog.h>
+#include <kdialogbase.h>
+#include <kcombobox.h>
+#include <kpushbutton.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kregexpeditorinterface.h>
+#include <ktrader.h>
+#include <kparts/componentfactory.h>
+#include <kfiledialog.h>
+
+// KTTS includes.
+
+// TalkerChooser includes.
+#include "talkerchooserconf.h"
+#include "talkerchooserconf.moc"
+
+/**
+* Constructor
+*/
+TalkerChooserConf::TalkerChooserConf( QWidget *parent, const char *name, const QStringList& /*args*/) :
+ KttsFilterConf(parent, name)
+{
+ // kdDebug() << "TalkerChooserConf::TalkerChooserConf: Running" << endl;
+
+ // Create configuration widget.
+ QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint(), "TalkerChooserConfigWidgetLayout");
+ layout->setAlignment (Qt::AlignTop);
+ m_widget = new TalkerChooserConfWidget(this, "TalkerChooserConfigWidget");
+ layout->addWidget(m_widget);
+
+ // Determine if kdeutils Regular Expression Editor is installed.
+ m_reEditorInstalled = !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty();
+ m_widget->reEditorButton->setEnabled(m_reEditorInstalled);
+
+ connect(m_widget->nameLineEdit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(configChanged()));
+ connect(m_widget->reLineEdit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(configChanged()));
+ connect(m_widget->reEditorButton, SIGNAL(clicked()),
+ this, SLOT(slotReEditorButton_clicked()));
+ connect(m_widget->appIdLineEdit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(configChanged()));
+ connect(m_widget->talkerButton, SIGNAL(clicked()),
+ this, SLOT(slotTalkerButton_clicked()));
+
+ connect(m_widget->loadButton, SIGNAL(clicked()),
+ this, SLOT(slotLoadButton_clicked()));
+ connect(m_widget->saveButton, SIGNAL(clicked()),
+ this, SLOT(slotSaveButton_clicked()));
+ connect(m_widget->clearButton, SIGNAL(clicked()),
+ this, SLOT(slotClearButton_clicked()));
+
+ // Set up defaults.
+ defaults();
+}
+
+/**
+* Destructor.
+*/
+TalkerChooserConf::~TalkerChooserConf(){
+ // kdDebug() << "TalkerChooserConf::~TalkerChooserConf: Running" << endl;
+}
+
+/**
+* This method is invoked whenever the module should read its
+* configuration (most of the times from a config file) and update the
+* user interface. This happens when the user clicks the "Reset" button in
+* the control center, to undo all of his changes and restore the currently
+* valid settings. Note that kttsmgr calls this when the plugin is
+* loaded, so it not necessary to call it in your constructor.
+* The plugin should read its configuration from the specified group
+* in the specified config file.
+* @param config Pointer to a KConfig object.
+* @param configGroup Call config->setGroup with this argument before
+* loading your configuration.
+*/
+void TalkerChooserConf::load(KConfig* config, const QString& configGroup){
+ // kdDebug() << "TalkerChooserConf::load: Running" << endl;
+ config->setGroup( configGroup );
+ m_widget->nameLineEdit->setText( config->readEntry( "UserFilterName", m_widget->nameLineEdit->text() ) );
+ m_widget->reLineEdit->setText(
+ config->readEntry("MatchRegExp", m_widget->reLineEdit->text()) );
+ m_widget->appIdLineEdit->setText(
+ config->readEntry("AppIDs", m_widget->appIdLineEdit->text()) );
+
+ m_talkerCode = TalkerCode(config->readEntry("TalkerCode"), false);
+ // Legacy settings.
+ QString s = config->readEntry( "LanguageCode" );
+ if (!s.isEmpty()) m_talkerCode.setFullLanguageCode(s);
+ s = config->readEntry( "SynthInName" );
+ if (!s.isEmpty()) m_talkerCode.setPlugInName(s);
+ s = config->readEntry( "Gender" );
+ if (!s.isEmpty()) m_talkerCode.setGender(s);
+ s = config->readEntry( "Volume" );
+ if (!s.isEmpty()) m_talkerCode.setVolume(s);
+ s = config->readEntry( "Rate" );
+ if (!s.isEmpty()) m_talkerCode.setRate(s);
+
+ m_widget->talkerLineEdit->setText(m_talkerCode.getTranslatedDescription());
+}
+
+/**
+* This function gets called when the user wants to save the settings in
+* the user interface, updating the config files or wherever the
+* configuration is stored. The method is called when the user clicks "Apply"
+* or "Ok". The plugin should save its configuration in the specified
+* group of the specified config file.
+* @param config Pointer to a KConfig object.
+* @param configGroup Call config->setGroup with this argument before
+* saving your configuration.
+*/
+void TalkerChooserConf::save(KConfig* config, const QString& configGroup){
+ // kdDebug() << "TalkerChooserConf::save: Running" << endl;
+ config->setGroup( configGroup );
+ config->writeEntry( "UserFilterName", m_widget->nameLineEdit->text() );
+ config->writeEntry( "MatchRegExp", m_widget->reLineEdit->text() );
+ config->writeEntry( "AppIDs", m_widget->appIdLineEdit->text().replace(" ", "") );
+ config->writeEntry( "TalkerCode", m_talkerCode.getTalkerCode());
+}
+
+/**
+* This function is called to set the settings in the module to sensible
+* default values. It gets called when hitting the "Default" button. The
+* default values should probably be the same as the ones the application
+* uses when started without a config file. Note that defaults should
+* be applied to the on-screen widgets; not to the config file.
+*/
+void TalkerChooserConf::defaults(){
+ // kdDebug() << "TalkerChooserConf::defaults: Running" << endl;
+ // Default name.
+ m_widget->nameLineEdit->setText( i18n("Talker Chooser") );
+ // Default regular expression is blank.
+ m_widget->reLineEdit->setText( "" );
+ // Default App ID is blank.
+ m_widget->appIdLineEdit->setText( "" );
+ // Default to using default Talker.
+ m_talkerCode = TalkerCode( QString::null, false );
+ m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() );
+}
+
+/**
+ * Indicates whether the plugin supports multiple instances. Return
+ * False if only one instance of the plugin can be configured.
+ * @return True if multiple instances are possible.
+ */
+bool TalkerChooserConf::supportsMultiInstance() { return true; }
+
+/**
+ * Returns the name of the plugin. Displayed in Filters tab of KTTSMgr.
+ * If there can be more than one instance of a filter, it should return
+ * a unique name for each instance. The name should be TalkerCode::translated for
+ * the user if possible. If the plugin is not correctly configured,
+ * return an empty string.
+ * @return Filter instance name.
+ */
+QString TalkerChooserConf::userPlugInName()
+{
+ if (m_widget->talkerLineEdit->text().isEmpty()) return QString::null;
+ if (m_widget->appIdLineEdit->text().isEmpty() &&
+ m_widget->reLineEdit->text().isEmpty()) return QString::null;
+ QString instName = m_widget->nameLineEdit->text();
+ if (instName.isEmpty()) return QString::null;
+ return instName;
+}
+
+void TalkerChooserConf::slotReEditorButton_clicked()
+{
+ // Show Regular Expression Editor dialog if it is installed.
+ if ( !m_reEditorInstalled ) return;
+ QDialog *editorDialog =
+ KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor" );
+ if ( editorDialog )
+ {
+ // kdeutils was installed, so the dialog was found. Fetch the editor interface.
+ KRegExpEditorInterface *reEditor =
+ static_cast<KRegExpEditorInterface *>(editorDialog->qt_cast( "KRegExpEditorInterface" ) );
+ Q_ASSERT( reEditor ); // This should not fail!// now use the editor.
+ reEditor->setRegExp( m_widget->reLineEdit->text() );
+ int dlgResult = editorDialog->exec();
+ if ( dlgResult == QDialog::Accepted )
+ {
+ QString re = reEditor->regExp();
+ m_widget->reLineEdit->setText( re );
+ }
+ delete editorDialog;
+ } else return;
+}
+
+void TalkerChooserConf::slotTalkerButton_clicked()
+{
+ QString talkerCode = m_talkerCode.getTalkerCode();
+ SelectTalkerDlg dlg( m_widget, "selecttalkerdialog", i18n("Select Talker"), talkerCode, true );
+ int dlgResult = dlg.exec();
+ if ( dlgResult != KDialogBase::Accepted ) return;
+ m_talkerCode = TalkerCode( dlg.getSelectedTalkerCode(), false );
+ m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() );
+ configChanged();
+}
+
+void TalkerChooserConf::slotLoadButton_clicked()
+{
+ QString dataDir = KGlobal::dirs()->findAllResources("data", "kttsd/talkerchooser/").last();
+ QString filename = KFileDialog::getOpenFileName(
+ dataDir,
+ "*rc|Talker Chooser Config (*rc)",
+ m_widget,
+ "talkerchooser_loadfile");
+ if ( filename.isEmpty() ) return;
+ KConfig* cfg = new KConfig( filename, true, false, 0 );
+ load( cfg, "Filter" );
+ delete cfg;
+ configChanged();
+}
+
+void TalkerChooserConf::slotSaveButton_clicked()
+{
+ QString filename = KFileDialog::getSaveFileName(
+ KGlobal::dirs()->saveLocation( "data" ,"kttsd/talkerchooser/", false ),
+ "*rc|Talker Chooser Config (*rc)",
+ m_widget,
+ "talkerchooser_savefile");
+ if ( filename.isEmpty() ) return;
+ KConfig* cfg = new KConfig( filename, false, false, 0 );
+ save( cfg, "Filter" );
+ delete cfg;
+}
+
+void TalkerChooserConf::slotClearButton_clicked()
+{
+ m_widget->nameLineEdit->setText( QString::null );
+ m_widget->reLineEdit->setText( QString::null );
+ m_widget->appIdLineEdit->setText( QString::null );
+ m_talkerCode = TalkerCode( QString::null, false );
+ m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() );
+ configChanged();
+}
diff --git a/kttsd/filters/talkerchooser/talkerchooserconf.h b/kttsd/filters/talkerchooser/talkerchooserconf.h
new file mode 100644
index 0000000..d6b3959
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserconf.h
@@ -0,0 +1,134 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generic Talker Chooser Filter Configuration class.
+ -------------------
+ Copyright:
+ (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ******************************************************************************/
+
+#ifndef _TALKERCHOOSERCONF_H_
+#define _TALKERCHOOSERCONF_H_
+
+// Qt includes.
+#include <qwidget.h>
+
+// KDE includes.
+#include <kconfig.h>
+#include <kdebug.h>
+
+// KTTS includes.
+#include "filterconf.h"
+#include "talkercode.h"
+#include "selecttalkerdlg.h"
+
+// TalkerChooser includes.
+#include "talkerchooserconfwidget.h"
+
+class KDialogBase;
+class EditReplacementWidget;
+
+class TalkerChooserConf : public KttsFilterConf
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor
+ */
+ TalkerChooserConf( QWidget *parent, const char *name, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor
+ */
+ virtual ~TalkerChooserConf();
+
+ /**
+ * This method is invoked whenever the module should read its
+ * configuration (most of the times from a config file) and update the
+ * user interface. This happens when the user clicks the "Reset" button in
+ * the control center, to undo all of his changes and restore the currently
+ * valid settings. Note that KTTSMGR calls this when the plugin is
+ * loaded, so it not necessary to call it in your constructor.
+ * The plugin should read its configuration from the specified group
+ * in the specified config file.
+ * @param config Pointer to a KConfig object.
+ * @param configGroup Call config->setGroup with this argument before
+ * loading your configuration.
+ *
+ * When a plugin is first added to KTTSMGR, @e load will be called with
+ * a Null @e configGroup. In this case, the plugin will not have
+ * any instance-specific parameters to load, but it may still wish
+ * to load parameters that apply to all instances of the plugin.
+ */
+ virtual void load(KConfig *config, const QString &configGroup);
+
+ /**
+ * This function gets called when the user wants to save the settings in
+ * the user interface, updating the config files or wherever the
+ * configuration is stored. The method is called when the user clicks "Apply"
+ * or "Ok". The plugin should save its configuration in the specified
+ * group of the specified config file.
+ * @param config Pointer to a KConfig object.
+ * @param configGroup Call config->setGroup with this argument before
+ * saving your configuration.
+ */
+ virtual void save(KConfig *config, const QString &configGroup);
+
+ /**
+ * This function is called to set the settings in the module to sensible
+ * default values. It gets called when hitting the "Default" button. The
+ * default values should probably be the same as the ones the application
+ * uses when started without a config file. Note that defaults should
+ * be applied to the on-screen widgets; not to the config file.
+ */
+ virtual void defaults();
+
+ /**
+ * Indicates whether the plugin supports multiple instances. Return
+ * False if only one instance of the plugin can be configured.
+ * @return True if multiple instances are possible.
+ */
+ virtual bool supportsMultiInstance();
+
+ /**
+ * Returns the name of the plugin. Displayed in Filters tab of KTTSMgr.
+ * If there can be more than one instance of a filter, it should return
+ * a unique name for each instance. The name should be translated for
+ * the user if possible. If the plugin is not correctly configured,
+ * return an empty string.
+ * @return Filter instance name.
+ */
+ virtual QString userPlugInName();
+
+ private slots:
+ void slotReEditorButton_clicked();
+ void slotTalkerButton_clicked();
+ void slotLoadButton_clicked();
+ void slotSaveButton_clicked();
+ void slotClearButton_clicked();
+
+ private:
+ // Configuration Widget.
+ TalkerChooserConfWidget* m_widget;
+ // True if kdeutils Regular Expression Editor is installed.
+ bool m_reEditorInstalled;
+ // User's chosen Talker Code.
+ TalkerCode m_talkerCode;
+};
+
+#endif //_TALKERCHOOSERCONF_H_
diff --git a/kttsd/filters/talkerchooser/talkerchooserconfwidget.ui b/kttsd/filters/talkerchooser/talkerchooserconfwidget.ui
new file mode 100644
index 0000000..3cdee2e
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserconfwidget.ui
@@ -0,0 +1,319 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>TalkerChooserConfWidget</class>
+<comment>Widget for configuring Talker Chooser Filter for KTTSD.</comment>
+<author>Gary Cramblitt &lt;garycramblitt@comcast.net&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>TalkerChooserConfWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>547</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Configure Talker Chooser</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>nameLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>nameLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter any name you like for this filter.</string>
+ <comment>What's this text</comment>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>nameLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter any name you like for this filter.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>applyGroupBox</cstring>
+ </property>
+ <property name="title">
+ <string>&amp;Apply This Filter When</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>These settings determines when the filter is applied to text.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>reLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Te&amp;xt contains:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>reLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This filter is applied to text jobs of the specified language. You may select more than one language by clicking the browse button and Ctrl-clicking on more than one in the list. If blank, the filter applies to all text jobs of any language.</string>
+ <comment>What's this text</comment>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>appIdLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Application &amp;ID contains:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>appIdLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Enter a DCOP Application ID. This filter will only apply to text jobs queued by that application. You may enter more than one ID separated by commas. If blank, this filter applies to text jobs queued by all applications. Tip: Use kdcop from the command line to get the Application IDs of running applications. Example: "konversation, kvirc,ksirc,kopete"</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>reLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This filter is applied to text jobs of the specified language. You may select more than one language by clicking the browse button and Ctrl-clicking on more than one in the list. If blank, the filter applies to all text jobs of any language.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>reEditorButton</cstring>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Click to select one or more languages. This filter will be applied to text jobs of those languages.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>appIdLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;Enter a DCOP Application ID. This filter will only apply to text jobs queued by that application. You may enter more than one ID separated by commas. Use &lt;b&gt;knotify&lt;/b&gt; to match all messages sent as KDE notifications. If blank, this filter applies to text jobs queued by all applications. Tip: Use kdcop from the command line to get the Application IDs of running applications. Example: "konversation, kvirc,ksirc,kopete"&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout19_2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>talkerLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Talker:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>talkerLineEdit</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The new Talker that will be used when the conditions above are met. The default Talker is the topmost in the Talkers tab. Click the button to choose a Talker.</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>talkerLineEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="paletteForegroundColor">
+ <color>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The new Talker that will be used when the conditions above are met. The default Talker is the topmost in the Talkers tab. Click the button to choose a Talker.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>talkerButton</cstring>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Click to select a Talker.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>loadButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Load...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Click to load a Talker Chooser configuration from a file.</string>
+ <comment>What's this text</comment>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>saveButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Save...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Click to save this Talker Chooser to a file.</string>
+ <comment>What's this text</comment>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>clearButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Cl&amp;ear</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Click to clear everything.</string>
+ <comment>What's this text</comment>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>reLineEdit</tabstop>
+ <tabstop>reEditorButton</tabstop>
+ <tabstop>appIdLineEdit</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kttsd/filters/talkerchooser/talkerchooserplugin.cpp b/kttsd/filters/talkerchooser/talkerchooserplugin.cpp
new file mode 100644
index 0000000..4181f6a
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserplugin.cpp
@@ -0,0 +1,32 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generating the factories so Talker Chooser Filter can be used as plug in.
+ -------------------
+ Copyright:
+ (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ******************************************************************************/
+
+#include <kgenericfactory.h>
+
+#include "talkerchooserconf.h"
+#include "talkerchooserproc.h"
+
+typedef K_TYPELIST_2( TalkerChooserProc, TalkerChooserConf ) TalkerChooserPlugin;
+K_EXPORT_COMPONENT_FACTORY( libkttsd_talkerchooserplugin,
+ KGenericFactory<TalkerChooserPlugin>("kttsd_talkerchooser") )
+
diff --git a/kttsd/filters/talkerchooser/talkerchooserproc.cpp b/kttsd/filters/talkerchooser/talkerchooserproc.cpp
new file mode 100644
index 0000000..628b68a
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserproc.cpp
@@ -0,0 +1,148 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generic Talker Chooser Filter Configuration class.
+ -------------------
+ Copyright:
+ (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ******************************************************************************/
+
+// Qt includes.
+#include <qregexp.h>
+
+// KDE includes.
+#include <kdebug.h>
+#include <kconfig.h>
+
+// KTTS includes.
+#include "talkercode.h"
+
+// Talker Chooser includes.
+#include "talkerchooserproc.h"
+#include "talkerchooserproc.moc"
+
+/**
+ * Constructor.
+ */
+TalkerChooserProc::TalkerChooserProc( QObject *parent, const char *name, const QStringList& /*args*/ ) :
+ KttsFilterProc(parent, name)
+{
+ // kdDebug() << "TalkerChooserProc::TalkerChooserProc: Running" << endl;
+}
+
+/**
+ * Destructor.
+ */
+TalkerChooserProc::~TalkerChooserProc()
+{
+ // kdDebug() << "TalkerChooserProc::~TalkerChooserProc: Running" << endl;
+}
+
+/**
+ * Initialize the filter.
+ * @param config Settings object.
+ * @param configGroup Settings Group.
+ * @return False if filter is not ready to filter.
+ *
+ * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain
+ * separate configuration files of their own.
+ */
+bool TalkerChooserProc::init(KConfig* config, const QString& configGroup){
+ // kdDebug() << "PlugInProc::init: Running" << endl;
+ config->setGroup( configGroup );
+ m_re = config->readEntry( "MatchRegExp" );
+ m_appIdList = config->readListEntry( "AppIDs" );
+ m_chosenTalkerCode = TalkerCode(config->readEntry("TalkerCode"), false);
+ // Legacy settings.
+ QString s = config->readEntry( "LanguageCode" );
+ if (!s.isEmpty()) m_chosenTalkerCode.setFullLanguageCode(s);
+ s = config->readEntry( "SynthInName" );
+ if (!s.isEmpty()) m_chosenTalkerCode.setPlugInName(s);
+ s = config->readEntry( "Gender" );
+ if (!s.isEmpty()) m_chosenTalkerCode.setGender(s);
+ s = config->readEntry( "Volume" );
+ if (!s.isEmpty()) m_chosenTalkerCode.setVolume(s);
+ s = config->readEntry( "Rate" );
+ if (!s.isEmpty()) m_chosenTalkerCode.setRate(s);
+ return true;
+}
+
+/**
+ * Returns True if the plugin supports asynchronous processing,
+ * i.e., supports asyncConvert method.
+ * @return True if this plugin supports asynchronous processing.
+ *
+ * If the plugin returns True, it must also implement @ref getState .
+ * It must also emit @ref filteringFinished when filtering is completed.
+ * If the plugin returns True, it must also implement @ref stopFiltering .
+ * It must also emit @ref filteringStopped when filtering has been stopped.
+ */
+/*virtual*/ bool TalkerChooserProc::supportsAsync() { return false; }
+
+/**
+ * Convert input, returning output. Runs synchronously.
+ * @param inputText Input text.
+ * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
+ * use for synthing the text. Useful for extracting hints about
+ * how to filter the text. For example, languageCode.
+ * @param appId The DCOP appId of the application that queued the text.
+ * Also useful for hints about how to do the filtering.
+ */
+/*virtual*/ QString TalkerChooserProc::convert(const QString& inputText, TalkerCode* talkerCode,
+ const QCString& appId)
+{
+ if ( !m_re.isEmpty() )
+ {
+ int pos = inputText.find( QRegExp(m_re) );
+ if ( pos < 0 ) return inputText;
+ }
+ // If appId doesn't match, return input unmolested.
+ if ( !m_appIdList.isEmpty() )
+ {
+ // kdDebug() << "TalkerChooserProc::convert: converting " << inputText << " if appId "
+ // << appId << " matches " << m_appIdList << endl;
+ bool found = false;
+ QString appIdStr = appId;
+ for ( uint ndx=0; ndx < m_appIdList.count(); ++ndx )
+ {
+ if ( appIdStr.contains(m_appIdList[ndx]) )
+ {
+ found = true;
+ break;
+ }
+ }
+ if ( !found )
+ {
+ // kdDebug() << "TalkerChooserProc::convert: appId not found" << endl;
+ return inputText;
+ }
+ }
+
+ // Set the talker.
+ // kdDebug() << "TalkerChooserProc::convert: setting lang " << m_languageCode <<
+ // " gender " << m_gender << " synth " << m_synth <<
+ // " volume " << m_volume << " rate " << m_rate << endl;
+ // Only override the language if user specified a language code.
+ if (!m_chosenTalkerCode.fullLanguageCode().isEmpty())
+ talkerCode->setFullLanguageCode(m_chosenTalkerCode.fullLanguageCode());
+ talkerCode->setVoice(m_chosenTalkerCode.voice());
+ talkerCode->setGender(m_chosenTalkerCode.gender());
+ talkerCode->setPlugInName(m_chosenTalkerCode.plugInName());
+ talkerCode->setVolume(m_chosenTalkerCode.volume());
+ talkerCode->setRate(m_chosenTalkerCode.rate());
+ return inputText;
+}
diff --git a/kttsd/filters/talkerchooser/talkerchooserproc.h b/kttsd/filters/talkerchooser/talkerchooserproc.h
new file mode 100644
index 0000000..07cde68
--- /dev/null
+++ b/kttsd/filters/talkerchooser/talkerchooserproc.h
@@ -0,0 +1,87 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generic Talker Chooser Filter Configuration class.
+ -------------------
+ Copyright:
+ (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ******************************************************************************/
+
+#ifndef _TALKERCHOOSERPROC_H_
+#define _TALKERCHOOSERPROC_H_
+
+// KTTS includes.
+#include "filterproc.h"
+#include "talkercode.h"
+
+class TalkerChooserProc : virtual public KttsFilterProc
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor.
+ */
+ TalkerChooserProc( QObject *parent, const char *name, const QStringList &args = QStringList() );
+
+ /**
+ * Destructor.
+ */
+ virtual ~TalkerChooserProc();
+
+ /**
+ * Initialize the filter.
+ * @param config Settings object.
+ * @param configGroup Settings Group.
+ * @return False if filter is not ready to filter.
+ *
+ * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain
+ * separate configuration files of their own.
+ */
+ virtual bool init(KConfig *config, const QString &configGroup);
+
+ /**
+ * Returns True if the plugin supports asynchronous processing,
+ * i.e., supports asyncConvert method.
+ * @return True if this plugin supports asynchronous processing.
+ *
+ * If the plugin returns True, it must also implement @ref getState .
+ * It must also emit @ref filteringFinished when filtering is completed.
+ * If the plugin returns True, it must also implement @ref stopFiltering .
+ * It must also emit @ref filteringStopped when filtering has been stopped.
+ */
+ virtual bool supportsAsync();
+
+ /**
+ * Convert input, returning output. Runs synchronously.
+ * @param inputText Input text.
+ * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
+ * use for synthing the text. Useful for extracting hints about
+ * how to filter the text. For example, languageCode.
+ * @param appId The DCOP appId of the application that queued the text.
+ * Also useful for hints about how to do the filtering.
+ */
+ virtual QString convert(const QString& inputText, TalkerCode* talkerCode, const QCString& appId);
+
+private:
+
+ QString m_re;
+ QStringList m_appIdList;
+ TalkerCode m_chosenTalkerCode;
+};
+
+#endif // _TALKERCHOOSERPROC_H_