1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 A KPart to display running jobs in KTTSD and permit user to stop, rewind,
3 advance, change Talker, etc.
5 Copyright : (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
7 Current Maintainer: Gary Cramblitt <garycramblitt@comcast.net>
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.
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.
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 ******************************************************************************/
24 #ifndef KTTSJOBMGRPART_H
25 #define KTTSJOBMGRPART_H
31 #include <kparts/browserextension.h>
34 #include "kspeechinterface.h"
38 class KttsJobMgrBrowserExtension
;
42 class JobInfoListModel
;
45 public KParts::ReadOnlyPart
49 KttsJobMgrPart(QWidget
*parentWidget
, QObject
*parent
, const QStringList
& args
=QStringList());
50 virtual ~KttsJobMgrPart();
51 static KAboutData
* createAboutData();
54 virtual bool openFile();
55 virtual bool closeUrl();
57 /** Slots connected to DBUS Signals emitted by KTTSD. */
60 * This signal is emitted when KTTSD starts or restarts after a call to reinit.
62 Q_SCRIPTABLE
void kttsdStarted();
65 * This signal is emitted each time the state of a job changes.
66 * @param appId The DBUS sender ID of the application that
68 * @param jobNum Job Number.
69 * @param state Job state. @see KSpeech::JobState.
71 Q_SCRIPTABLE
void jobStateChanged(const QString
&appId
, int jobNum
, int state
);
74 * This signal is emitted when a marker is processed.
75 * Currently only emits mtSentenceBegin and mtSentenceEnd.
76 * @param appId The DBUS sender ID of the application that submitted the job.
77 * @param jobNum Job Number of the job emitting the marker.
78 * @param markerType The type of marker.
79 * Currently either mtSentenceBegin or mtSentenceEnd.
80 * @param markerData Data for the marker.
81 * Currently, this is the sequence number of the sentence
82 * begun or ended. Sequence numbers begin at 1.
84 Q_SCRIPTABLE
void marker(const QString
&appId
, int jobNum
, int markerType
, const QString
&markerData
);
88 * This slot is connected to the Job List View clicked signal.
90 void slot_jobListView_clicked();
93 * Slots connected to buttons.
96 void slot_job_resume();
97 void slot_job_restart();
98 void slot_job_remove();
100 void slot_job_change_talker();
101 void slot_speak_clipboard();
102 void slot_speak_file();
104 void slot_job_prev_sen();
105 void slot_job_next_sen();
109 * Get the Job Number of the currently-selected job in the Job List View.
110 * @return Job Number of currently-selected job.
111 * 0 if no currently-selected job.
113 int getCurrentJobNum();
116 * Enables or disables all the job-related buttons.
117 * @param enable True to enable the job-related butons. False to disable.
119 void enableJobActions(bool enable
);
122 * Retrieves JobInfo from KTTSD, creates and fills JobInfo object.
123 * @param jobNum Job Number.
125 JobInfo
* retrieveJobInfo(int jobNum
);
128 * Refresh display of a single job in the JobListView.
129 * @param jobNum Job Number.
131 void refreshJob(int jobNum
);
136 void refreshJobList();
139 * If nothing selected in Job List View and list not empty, select top item.
140 * If nothing selected and list is empty, disable job buttons.
142 void autoSelectInJobListView();
145 * DBUS KSpeech Interface.
147 org::kde::KSpeech
* m_kspeech
;
150 * Return the Talker ID corresponding to a Talker Code, retrieving from cached list if present.
151 * @param talkerCode Talker Code.
154 QString
cachedTalkerCodeToTalkerID(const QString
& talkerCode
);
159 QTreeView
* m_jobListView
;
160 JobInfoListModel
* m_jobListModel
;
161 KttsJobMgrBrowserExtension
*m_extension
;
164 * Current sentence box.
166 KTextEdit
* m_currentSentence
;
169 * Box containing buttons.
174 * This flag is set to True whenever we want to select the next job that
175 * is announced in a textSet signal.
177 bool m_selectOnTextSet
;
180 * Cache mapping Talker Codes to Talker IDs.
182 QMap
<QString
,QString
> m_talkerCodesToTalkerIDs
;
185 class KttsJobMgrBrowserExtension
: public KParts::BrowserExtension
188 friend class KttsJobMgrPart
;
190 KttsJobMgrBrowserExtension(KttsJobMgrPart
*parent
);
191 virtual ~KttsJobMgrBrowserExtension();
194 #endif // KTTSJOBMGRPART_H