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