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