• 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
  • kcmkttsmgr
kttsjobmgr.cpp
Go to the documentation of this file.
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2  A QWidget to allow configuring of current voice in Jovie
3  and permit user to stop, cancel, pause, resume, change Talker, etc.
4  -------------------
5  Copyright : (C) 2004,2005 by Gary Cramblitt <garycramblitt@comcast.net>
6  Copyright : (C) 2009-2010 by Jeremy Whiting <jpwhiting@kde.org>
7  -------------------
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 // KttsJobMgr includes.
25 #include "kttsjobmgr.h"
26 #include "kttsjobmgr.moc"
27 #include "ui_kttsjobmgr.h"
28 
29 // QT includes.
30 #include <QtCore/QObject>
31 #include <QtGui/QLabel>
32 #include <QtGui/QSplitter>
33 #include <QtGui/QClipboard>
34 #include <QtGui/QPushButton>
35 #include <QtCore/QList>
36 #include <QtGui/QTreeView>
37 #include <QtCore/QMimeData>
38 #include <QtDBus/QtDBus>
39 
40 // KDE includes.
41 #include <kcomponentdata.h>
42 #include <klocale.h>
43 #include <kaboutdata.h>
44 #include <kicon.h>
45 #include <kdebug.h>
46 #include <kencodingfiledialog.h>
47 #include <kinputdialog.h>
48 #include <ktextedit.h>
49 #include <kvbox.h>
50 #include <kdemacros.h>
51 #include <kspeech.h>
52 
53 // KTTS includes.
54 #include "talkercode.h"
55 #include "selecttalkerdlg.h"
56 #include "talkerwidget.h"
57 
58 KttsJobMgr::KttsJobMgr(QWidget *parent) :
59  QWidget(parent)
60 {
61  m_ui = new Ui::kttsjobmgr;
62  m_ui->setupUi(this);
63 
64  m_kspeech = new OrgKdeKSpeechInterface(QLatin1String( "org.kde.KSpeech" ), QLatin1String( "/KSpeech" ), QDBusConnection::sessionBus());
65  m_kspeech->setParent(this);
66 
67  // Establish ourself as a System Manager.
68  m_kspeech->setApplicationName(QLatin1String( "KCMKttsMgr" ));
69  m_kspeech->setIsSystemManager(true);
70 
71  // All the ktts components use the same catalog.
72  KGlobal::locale()->insertCatalog(QLatin1String( "jovie" ));
73 
74  // Hide the name field
75  m_ui->talkerWidget->setNameReadOnly(true);
76  connect (m_ui->talkerWidget, SIGNAL(talkerChanged()), this, SIGNAL(configChanged()));
77 
78  m_ui->stopButton->setIcon(KIcon( QLatin1String( "media-playback-stop" )));
79  connect (m_ui->stopButton, SIGNAL(clicked()), this, SLOT(slot_stop()));
80  m_ui->cancelButton->setIcon(KIcon( QLatin1String( "edit-clear" )));
81  connect (m_ui->cancelButton, SIGNAL(clicked()), this, SLOT(slot_cancel()));
82  m_ui->pauseButton->setIcon(KIcon( QLatin1String( "media-playback-pause" )));
83  connect (m_ui->pauseButton, SIGNAL(clicked()), this, SLOT(slot_pause()));
84  m_ui->resumeButton->setIcon(KIcon( QLatin1String( "media-playback-start" )));
85  connect (m_ui->resumeButton, SIGNAL(clicked()), this, SLOT(slot_resume()));
86 
87  m_ui->speak_clipboard->setIcon(KIcon( QLatin1String( "klipper" )));
88  connect (m_ui->speak_clipboard, SIGNAL(clicked()), this, SLOT(slot_speak_clipboard()));
89  m_ui->speak_file->setIcon(KIcon( QLatin1String( "document-open" )));
90  connect (m_ui->speak_file, SIGNAL(clicked()), this, SLOT(slot_speak_file()));
91 }
92 
93 KttsJobMgr::~KttsJobMgr()
94 {
95  KGlobal::locale()->removeCatalog(QLatin1String( "jovie" ));
96  delete m_ui;
97 }
98 
102 void KttsJobMgr::slot_stop()
103 {
104  m_kspeech->stop();
105 }
106 
107 void KttsJobMgr::slot_cancel()
108 {
109  m_kspeech->cancel();
110 }
111 
112 void KttsJobMgr::slot_pause()
113 {
114  m_kspeech->pause();
115 }
116 
117 void KttsJobMgr::slot_resume()
118 {
119  m_kspeech->resume();
120 }
121 
122 void KttsJobMgr::save()
123 {
124  TalkerCode talker = m_ui->talkerWidget->getTalkerCode();
125 
126  m_kspeech->setSpeed(talker.rate());
127  m_kspeech->setPitch(talker.pitch());
128  m_kspeech->setVolume(talker.volume());
129  m_kspeech->setVoiceType(talker.voiceType());
130  kDebug() << "setting output module to " << talker.outputModule();
131  m_kspeech->setOutputModule(talker.outputModule());
132  kDebug() << "setting language to " << talker.language();
133  m_kspeech->setLanguage(talker.language());
134 }
135 
136 void KttsJobMgr::load()
137 {
138 }
139 
140 void KttsJobMgr::slot_speak_clipboard()
141 {
142  m_kspeech->sayClipboard();
143 }
144 
145 void KttsJobMgr::slot_speak_file()
146 {
147  KEncodingFileDialog dlg;
148  KEncodingFileDialog::Result result = dlg.getOpenFileNameAndEncoding();
149  if (result.fileNames.count() == 1)
150  {
151  // kDebug() << "KttsJobMgr::slot_speak_file: calling setFile with filename " <<
152  // result.fileNames[0] << " and encoding " << result.encoding << endl;
153  m_kspeech->sayFile(result.fileNames[0], result.encoding);
154  }
155 }
156 
162 QString KttsJobMgr::cachedTalkerCodeToTalkerID(const QString& talkerCode)
163 {
164  // If in the cache, return that.
165  if (m_talkerCodesToTalkerIDs.contains(talkerCode))
166  return m_talkerCodesToTalkerIDs[talkerCode];
167  else
168  {
169  // Otherwise, retrieve Talker ID from KTTSD and cache it.
170  QString talkerID = m_kspeech->talkerToTalkerId(talkerCode);
171  m_talkerCodesToTalkerIDs[talkerCode] = talkerID;
172  // kDebug() << "KttsJobMgr::cachedTalkerCodeToTalkerID: talkerCode = " << talkerCode << " talkerID = " << talkerID;
173  return talkerID;
174  }
175 }
selecttalkerdlg.h
talkerwidget.h
TalkerCode::language
QString language() const
Definition: talkercode.cpp:119
QWidget
kttsjobmgr.h
TalkerCode::volume
int volume() const
Definition: talkercode.cpp:129
talkercode.h
KttsJobMgr::configChanged
void configChanged()
TalkerCode::rate
int rate() const
Definition: talkercode.cpp:134
KttsJobMgr::KttsJobMgr
KttsJobMgr(QWidget *parent=0)
Definition: kttsjobmgr.cpp:58
TalkerCode
Definition: talkercode.h:38
KttsJobMgr::save
void save()
apply current settings, i.e.
Definition: kttsjobmgr.cpp:122
KttsJobMgr::~KttsJobMgr
virtual ~KttsJobMgr()
Definition: kttsjobmgr.cpp:93
TalkerCode::voiceType
int voiceType() const
Definition: talkercode.cpp:124
TalkerCode::outputModule
QString outputModule() const
Definition: talkercode.cpp:149
KttsJobMgr::load
void load()
get the current settings from speech-dispatcher
Definition: kttsjobmgr.cpp:136
TalkerCode::pitch
int pitch() const
Definition: talkercode.cpp:139
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