1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
/***************************************************************************
ksayit.h - description
-------------------
begin : Son Aug 10 13:26:57 EDT 2003
copyright : (C) 2003 by Robert Vogl
email : voglrobe@saphir
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KSAYIT_H
#define KSAYIT_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
using namespace std;
// include files for Qt
#include <tqstringlist.h>
#include <tqclipboard.h>
// include files for KDE
#include <kapplication.h>
#include <kmainwindow.h>
#include <kaccel.h>
#include <kaction.h>
#include <kactionclasses.h>
#include <kurl.h>
#include <dcopobject.h>
#include <kbookmarkmanager.h>
#include <kbookmarkmenu.h>
// App specific includes
// appended to $HOME
#define KSAYIT_BOOKMARKXMLFILE "/.ksayitbookmarks.xml"
// forward declaration of the KSayIt classes
class KSayItViewImpl;
class DocTreeViewImpl;
class KSayItSystemTray;
class FXPluginHandler;
class EffectStack;
class KTTSDLib;
class KSayItBookmarkHandler;
/**
* The base class for KSayIt application windows. It sets up the main
* window and reads the config file as well as providing a menubar, toolbar
* and statusbar. An instance of KSayItView creates the center view.
* KSayItApp reimplements the methods that KMainWindow provides for main window handling and supports
* full session management as well as using KActions.
* @see KMainWindow
* @see KApplication
* @see KConfig
*
* @author Robert Vogl
*/
class KSayItApp : public KMainWindow, public DCOPObject
{
Q_OBJECT
K_DCOP
public:
/** construtor of KSayItApp, calls all init functions to create the application.
*/
KSayItApp(TQWidget* parent=0, const char* name=0, WFlags f=0,
const TQCString &objID=0);
~KSayItApp();
k_dcop:
/** DCOP interface for say operation
\param msg The text to speak.
*/
ASYNC dcopSayText(TQString msg);
/** DCOP interface for stop operation
*/
ASYNC dcopStop();
/** DCOP interface to say DocBook file
*/
ASYNC dcopSayXmlFile(KURL url);
signals:
/** emitted when the Configuration was modified
*/
void signalConfigChanged();
private slots:
/** Puts the given text on the Job-Stack of KTTSD.
* \param text The text to say.
*/
void slotSetText(const TQString &text);
/** Called from the ListView widget after one or many
* 'setText'-Calls. Starts to say the text.
*/
void slotSayNode();
/** Called when a node in the treeview was clicked and
* new content in the edit window must be shown.
* \str The new content of the EditView.
*/
void slotTreeViewChanged(const TQString &str);
/** save general Options like all bar positions and status as well as the geometry to
* the configuration file.
*/
void slotSaveOptions();
/** closes the windows , then quits the application.
*/
void slotFileQuit();
/** changes the statusbar contents for the standard label permanently, used to indicate
* current actions.
* @param text the text that is displayed in the statusbar
*/
void slotStatusMsg(const TQString &text);
/** opens the Preferences-Dialog.
*/
void slotPreferences();
/** activated if "say" from tray was clicked.
*/
void slotSayClipboard();
/** activated if "say" from app-window was clicked.
*/
void slotSayText();
/** activated if "shut up" was clicked.
*/
void slotStopActivated();
/** activated if "pause" was clicked.
*/
void slotPauseActivated();
/** activated if "next sentence" was clicked.
*/
void slotNextSentenceActivated();
/** activated if "previous sentence" was clicked.
*/
void slotPrevSentenceActivated();
/** called if text processing was finished.
*/
void slotFinished();
/** called to enable the copy/cut action, if text is selected in the TextEdit-View
\param enable Enable actions if true, disable actions if false.
*/
void slotEnableCopyCut(bool enable);
/** sets the Caption of the MainWindow */
void slotSetCaption(const TQString &caption);
/** called when the Text was changed.
* \param empty True if the TextEdit view is empty.
*/
void slotTextChanged(bool empty);
/** enabled/disables the textedit window;
* \param enable true=enabled, false=disabled
*/
void slotEnableTextedit(bool enable);
/** toggles the statusbar
*/
void slotToggleStatusBar();
/** Called when the ToolBar shall be configured by the user.
*/
void slotConfigureToolbar();
/** Called to add a bookmark.
*/
void slotAddBookmark();
/** Called to delete a bookmark
*/
void slotDeleteBookmark(const TQString &url, const TQString &title);
/** Called to edit bookmarks.
*/
void slotEditBookmarks();
/** Called from slotConfigureToolbar() if we have a new ToolBar-configuration.
*/
void slotNewToolbarConfig();
/** called whenever the content of the clipboard changes.
* Checks if the content of the Clipboard is of type text/plain.
* Disables and enables the SystemTray-object.
*/
void slotClipboardChanged();
/** Deletes the content of the Textview.
*/
void slotClear();
/** Hides the MainWindow
*/
void slotCloseMainWindow();
/** Dialog to edit the Key associations
*/
void slotEditKeys();
/** Open file action
*/
void slotFileOpen();
/** Save file
*/
void slotFileSave();
/** Save file as
*/
void slotFileSaveAs();
/** Called, when the TTS Library has finished processing.
*/
void slotTTSFinished();
/** Edit mode switched on/off.
*/
void slotEditToggled();
/**
* Catches the signal from the TreeView object
* and forwards it to the BookmarkHandler object.
*/
void slotNotifyBookmarkHandler(const TQString &ID, const TQString &title);
/**
* Copies the content of the current bookmark file to the
* file designated by \p newname and install a new
* BookmarkHandler.
* \param newname The name of the new bookmark file.
*/
void slotChangeBookmarkFilename(const TQString &newname);
/** Loads bookmark file corresponding to the given file.
* \param newname The name of the new file.
*/
void slotSetBookmarkFilename(const TQString &newname);
public:
/**
* Selects the item with the given ID in the TreeView.
* \param ID The ID of the item to select.
* \param title The title of the bookmark.
* \returns <tt>TQString::null</tt>, if the operation was successfull,
* an error message, if the ID was not found.
*/
TQString setItemByBookmark( const TQString &ID, const TQString &title );
private: // Methods
/** read general Options again and initialize all variables.
*/
void readOptions();
/** initializes the KActions of the application */
void initActions();
/** sets up the statusbar for the main window by initialzing a statuslabel.
*/
void initStatusBar();
/**
*/
void initBookmarkManager(const TQString &filename);
/** creates the centerwidget of the KTMainWindow instance and sets it as the view.
*/
void initView();
/** resets the editor. Do not create an empty document.
*/
void resetView();
/** start to say the text on the KTTSD's Job-Stack.
*/
void sayActivated();
/** reimplemented from baseclass
*/
virtual void closeEvent(TQCloseEvent *ce);
/** disable/enable Actions.
* \param actions An OR'ed integer of enum ACTIONS. A '1' is supposed
* as 'Action enabled'.
*/
void setActions(int actions);
/**
* Returns the absolute pathname of the given bookmarkfile.
* This is the first KDE resource directory \p (share/apps) in which
* the user has write permissions. The relative path is
* \p ksayit/ksayit_bookmarks/.
* \param filename The name of the bookmark file.
* \returns The absolute pathname of the given bookmark file.
* Returns \p TQString::null if the operation was not successfull.
*/
TQString getBookmarkDir(const TQString &filename);
private:
KConfig *config;
KSayItViewImpl *view;
KSayItSystemTray *tray;
EffectStack *es;
DocTreeViewImpl *treeview;
KBookmarkManager *bkManager;
KSayItBookmarkHandler *bkHandler;
KBookmarkMenu *bkMenu;
// KAction pointers
KToggleAction *statusBarAction;
KAction *say;
KAction *pause;
KAction *shutup;
KAction *next_sentence;
KAction *prev_sentence;
KAction *clear;
KAction *copy;
KAction *cut;
KAction *paste;
KAction *open;
KAction *save;
KAction *saveAs;
KAction *preferences;
KToggleAction *edit;
KActionMenu *bookmarkmenu;
// Misc stuff
QClipboard *cb;
TQString clip;
KTTSDLib *m_kttslib;
FXPluginHandler *m_fxpluginhandler;
bool m_ap_saying;
bool m_ap_paused;
bool m_textview_empty;
bool m_enableChangeNotifications;
TQString m_currentBookmarkFile;
};
#endif // KSAYIT_H
|