Remove this line
[kdeaccessibility.git] / kttsd / kttsjobmgr / kttsjobmgr.h
blob608b901da896a4eb8a2ef272e5f8b9c20920753d
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.
4 -------------------
5 Copyright : (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
6 Copyright : (C) 2009 by Jeremy Whiting <jeremy@scitools.com>
7 -------------------
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
27 // Qt includes
30 // KDE includes.
31 #include <kparts/browserextension.h>
33 // KTTS includes.
34 #include "kspeechinterface.h"
36 class QTreeView;
37 class KAboutData;
38 class KPushButton;
39 class KttsJobMgrBrowserExtension;
40 class KVBox;
41 class KTextEdit;
42 class JobInfo;
43 class JobInfoListModel;
45 namespace Ui
47 class kttsjobmgr;
50 class KttsJobMgrPart:
51 public KParts::ReadOnlyPart
53 Q_OBJECT
54 public:
55 KttsJobMgrPart(QWidget *parentWidget, QObject *parent, const QStringList& args=QStringList());
56 virtual ~KttsJobMgrPart();
57 static KAboutData* createAboutData();
59 protected:
60 virtual bool openFile();
61 virtual bool closeUrl();
63 /** Slots connected to DBUS Signals emitted by KTTSD. */
64 protected Q_SLOTS:
65 /**
66 * This signal is emitted when KTTSD starts or restarts after a call to reinit.
68 Q_SCRIPTABLE void kttsdStarted();
70 /**
71 * This signal is emitted each time the state of a job changes.
72 * @param appId The DBUS sender ID of the application that
73 * submitted the job.
74 * @param jobNum Job Number.
75 * @param state Job state. @see KSpeech::JobState.
77 Q_SCRIPTABLE void jobStateChanged(const QString &appId, int jobNum, int state);
79 /**
80 * This signal is emitted when a marker is processed.
81 * Currently only emits mtSentenceBegin and mtSentenceEnd.
82 * @param appId The DBUS sender ID of the application that submitted the job.
83 * @param jobNum Job Number of the job emitting the marker.
84 * @param markerType The type of marker.
85 * Currently either mtSentenceBegin or mtSentenceEnd.
86 * @param markerData Data for the marker.
87 * Currently, this is the sequence number of the sentence
88 * begun or ended. Sequence numbers begin at 1.
90 Q_SCRIPTABLE void marker(const QString &appId, int jobNum, int markerType, const QString &markerData);
92 private slots:
93 /**
94 * This slot is connected to the Job List View clicked signal.
96 void slot_jobListView_clicked();
98 /**
99 * Slots connected to buttons.
101 void slot_job_hold();
102 void slot_job_resume();
103 void slot_job_restart();
104 void slot_job_remove();
105 void slot_job_remove_all();
106 void slot_job_move();
107 void slot_job_change_talker();
108 void slot_speak_clipboard();
109 void slot_speak_file();
110 void slot_refresh();
111 void slot_job_prev_sen();
112 void slot_job_next_sen();
114 private:
116 * Get the Job Number of the currently-selected job in the Job List View.
117 * @return Job Number of currently-selected job.
118 * 0 if no currently-selected job.
120 int getCurrentJobNum();
123 * Enables or disables all the job-related buttons.
124 * @param enable True to enable the job-related butons. False to disable.
126 void enableJobActions(bool enable);
129 * Retrieves JobInfo from KTTSD, creates and fills JobInfo object.
130 * @param jobNum Job Number.
132 JobInfo* retrieveJobInfo(int jobNum);
135 * Refresh display of a single job in the JobListView.
136 * @param jobNum Job Number.
138 void refreshJob(int jobNum);
141 * Fill the Job List.
143 void refreshJobList();
146 * If nothing selected in Job List View and list not empty, select top item.
147 * If nothing selected and list is empty, disable job buttons.
149 void autoSelectInJobListView();
152 * DBUS KSpeech Interface.
154 org::kde::KSpeech* m_kspeech;
157 * Return the Talker ID corresponding to a Talker Code, retrieving from cached list if present.
158 * @param talkerCode Talker Code.
159 * @return Talker ID.
161 QString cachedTalkerCodeToTalkerID(const QString& talkerCode);
164 * Job ListView.
166 JobInfoListModel* m_jobListModel;
167 KttsJobMgrBrowserExtension *m_extension;
168 Ui::kttsjobmgr * m_ui;
169 QList<KPushButton*> m_jobButtons;
172 * This flag is set to True whenever we want to select the next job that
173 * is announced in a textSet signal.
175 bool m_selectOnTextSet;
178 * Cache mapping Talker Codes to Talker IDs.
180 QMap<QString,QString> m_talkerCodesToTalkerIDs;
183 class KttsJobMgrBrowserExtension : public KParts::BrowserExtension
185 Q_OBJECT
186 friend class KttsJobMgrPart;
187 public:
188 KttsJobMgrBrowserExtension(KttsJobMgrPart *parent);
189 virtual ~KttsJobMgrBrowserExtension();
192 #endif // KTTSJOBMGRPART_H