• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeaccessibility API Reference
  • KDE Home
  • Contact Us
 

jovie

  • sources
  • kde-4.12
  • kdeaccessibility
  • jovie
  • filters
  • talkerchooser
talkerchooserproc.cpp
Go to the documentation of this file.
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2  Generic Talker Chooser Filter Configuration class.
3  -------------------
4  Copyright:
5  (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
6  -------------------
7  Original author: Gary Cramblitt <garycramblitt@comcast.net>
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  ******************************************************************************/
23 
24 // Talker Chooser includes.
25 #include "talkerchooserproc.h"
26 #include "talkerchooserproc.moc"
27 
28 // Qt includes.
29 #include <QtCore/QRegExp>
30 
31 // KDE includes.
32 #include <kdebug.h>
33 #include <kconfig.h>
34 #include <kconfiggroup.h>
35 
36 // KTTS includes.
37 #include "talkercode.h"
38 
39 TalkerChooserProc::TalkerChooserProc( QObject *parent, const QVariantList& args ) :
40  KttsFilterProc(parent, args)
41 {
42  Q_UNUSED(args);
43  // kDebug() << "TalkerChooserProc::TalkerChooserProc: Running";
44 }
45 
46 TalkerChooserProc::~TalkerChooserProc()
47 {
48  // kDebug() << "TalkerChooserProc::~TalkerChooserProc: Running";
49 }
50 
51 bool TalkerChooserProc::init(KConfig* c, const QString& configGroup){
52  // kDebug() << "PlugInProc::init: Running";
53  KConfigGroup config( c, configGroup );
54  m_re = config.readEntry( "MatchRegExp" );
55  m_appIdList = config.readEntry( "AppIDs", QStringList() );
56  m_chosenTalkerCode = TalkerCode(config.readEntry("TalkerCode"), false);
57  // Legacy settings.
58  QString s = config.readEntry( "LanguageCode" );
59  if (!s.isEmpty()) m_chosenTalkerCode.setLanguage(s);
60  s = config.readEntry( "SynthInName" );
61  //if (!s.isEmpty()) m_chosenTalkerCode.setPlugInName(s);
62  s = config.readEntry( "Gender" );
63  //if (!s.isEmpty()) m_chosenTalkerCode.setGender(s);
64  s = config.readEntry( "Volume" );
65  //if (!s.isEmpty()) m_chosenTalkerCode.setVolume(s);
66  s = config.readEntry( "Rate" );
67  //if (!s.isEmpty()) m_chosenTalkerCode.setRate(s);
68  return true;
69 }
70 
71 /*virtual*/ bool TalkerChooserProc::supportsAsync() { return false; }
72 
73 /*virtual*/ QString TalkerChooserProc::convert(const QString& inputText, TalkerCode* talkerCode,
74  const QString& appId)
75 {
76  if ( !m_re.isEmpty() )
77  {
78  int pos = inputText.indexOf( QRegExp(m_re) );
79  if ( pos < 0 ) return inputText;
80  }
81  // If appId doesn't match, return input unmolested.
82  if ( !m_appIdList.isEmpty() )
83  {
84  // kDebug() << "TalkerChooserProc::convert: converting " << inputText << " if appId "
85  // << appId << " matches " << m_appIdList << endl;
86  bool found = false;
87  QString appIdStr = appId;
88  for (int ndx=0; ndx < m_appIdList.count(); ++ndx )
89  {
90  if ( appIdStr.contains(m_appIdList[ndx]) )
91  {
92  found = true;
93  break;
94  }
95  }
96  if ( !found )
97  {
98  // kDebug() << "TalkerChooserProc::convert: appId not found";
99  return inputText;
100  }
101  }
102 
103  // Set the talker.
104  *talkerCode = m_chosenTalkerCode;
105  return inputText;
106 }
TalkerCode::setLanguage
void setLanguage(const QString &language)
Definition: talkercode.cpp:159
TalkerChooserProc::~TalkerChooserProc
virtual ~TalkerChooserProc()
Destructor.
Definition: talkerchooserproc.cpp:46
TalkerChooserProc::TalkerChooserProc
TalkerChooserProc(QObject *parent, const QVariantList &args)
Constructor.
Definition: talkerchooserproc.cpp:39
QObject
KttsFilterProc
Definition: filterproc.h:38
TalkerChooserProc::convert
virtual QString convert(const QString &inputText, TalkerCode *talkerCode, const QString &appId)
Convert input, returning output.
Definition: talkerchooserproc.cpp:73
talkercode.h
TalkerCode
Definition: talkercode.h:38
talkerchooserproc.h
TalkerChooserProc::supportsAsync
virtual bool supportsAsync()
Returns True if the plugin supports asynchronous processing, i.e., supports asyncConvert method...
Definition: talkerchooserproc.cpp:71
TalkerChooserProc::init
virtual bool init(KConfig *c, const QString &configGroup)
Initialize the filter.
Definition: talkerchooserproc.cpp:51
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:32:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

jovie

Skip menu "jovie"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeaccessibility API Reference

Skip menu "kdeaccessibility API Reference"
  • jovie

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal