move job manager ui into a designer file, and simplify the code a bit
[kdeaccessibility.git] / kttsd / kttsjobmgr / kttsjobmgr.h
blob5d2d089c56fc7df0827e32ab7192b8e64d881928
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 -------------------
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
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_move();
106 void slot_job_change_talker();
107 void slot_speak_clipboard();
108 void slot_speak_file();
109 void slot_refresh();
110 void slot_job_prev_sen();
111 void slot_job_next_sen();
113 private:
115 * Get the Job Number of the currently-selected job in the Job List View.
116 * @return Job Number of currently-selected job.
117 * 0 if no currently-selected job.
119 int getCurrentJobNum();
122 * Enables or disables all the job-related buttons.
123 * @param enable True to enable the job-related butons. False to disable.
125 void enableJobActions(bool enable);
128 * Retrieves JobInfo from KTTSD, creates and fills JobInfo object.
129 * @param jobNum Job Number.
131 JobInfo* retrieveJobInfo(int jobNum);
134 * Refresh display of a single job in the JobListView.
135 * @param jobNum Job Number.
137 void refreshJob(int jobNum);
140 * Fill the Job List.
142 void refreshJobList();
145 * If nothing selected in Job List View and list not empty, select top item.
146 * If nothing selected and list is empty, disable job buttons.
148 void autoSelectInJobListView();
151 * DBUS KSpeech Interface.
153 org::kde::KSpeech* m_kspeech;
156 * Return the Talker ID corresponding to a Talker Code, retrieving from cached list if present.
157 * @param talkerCode Talker Code.
158 * @return Talker ID.
160 QString cachedTalkerCodeToTalkerID(const QString& talkerCode);
163 * Job ListView.
165 JobInfoListModel* m_jobListModel;
166 KttsJobMgrBrowserExtension *m_extension;
167 Ui::kttsjobmgr * m_ui;
168 QList<KPushButton*> m_jobButtons;
171 * This flag is set to True whenever we want to select the next job that
172 * is announced in a textSet signal.
174 bool m_selectOnTextSet;
177 * Cache mapping Talker Codes to Talker IDs.
179 QMap<QString,QString> m_talkerCodesToTalkerIDs;
182 class KttsJobMgrBrowserExtension : public KParts::BrowserExtension
184 Q_OBJECT
185 friend class KttsJobMgrPart;
186 public:
187 KttsJobMgrBrowserExtension(KttsJobMgrPart *parent);
188 virtual ~KttsJobMgrBrowserExtension();
191 #endif // KTTSJOBMGRPART_H