4 /***************************************************************************
7 begin : Son Aug 10 13:26:57 EDT 2003
8 copyright : (C) 2003 by Robert Vogl
9 email : voglrobe@saphir
10 ***************************************************************************/
12 /***************************************************************************
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. *
19 ***************************************************************************/
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>
39 #include <kactionclasses.h>
41 #include <dcopobject.h>
42 #include <kbookmarkmanager.h>
43 #include <kbookmarkmenu.h>
45 // App specific includes
48 #define KSAYIT_BOOKMARKXMLFILE "/.ksayitbookmarks.xml"
50 // forward declaration of the KSayIt classes
52 class DocTreeViewImpl
;
53 class KSayItSystemTray
;
54 class FXPluginHandler
;
57 class KSayItBookmarkHandler
;
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.
71 class KSayItApp
: public KMainWindow
, public DCOPObject
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);
84 /** DCOP interface for say operation
85 \param msg The text to speak.
87 ASYNC
dcopSayText(QString msg
);
89 /** DCOP interface for stop operation
93 /** DCOP interface to say DocBook file
95 ASYNC
dcopSayXmlFile(KURL url
);
99 /** emitted when the Configuration was modified
101 void signalConfigChanged();
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.
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.
129 /** changes the statusbar contents for the standard label permanently, used to indicate
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.
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.
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.
219 /** Hides the MainWindow
221 void slotCloseMainWindow();
223 /** Dialog to edit the Key associations
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
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
);
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
);
277 /** read general Options again and initialize all variables.
281 /** initializes the KActions of the application */
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.
296 /** resets the editor. Do not create an empty document.
300 /** start to say the text on the KTTSD's Job-Stack.
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
);
328 KSayItViewImpl
*view
;
329 KSayItSystemTray
*tray
;
331 DocTreeViewImpl
*treeview
;
332 KBookmarkManager
*bkManager
;
333 KSayItBookmarkHandler
*bkHandler
;
334 KBookmarkMenu
*bkMenu
;
337 KToggleAction
*statusBarAction
;
341 KAction
*next_sentence
;
342 KAction
*prev_sentence
;
350 KAction
*preferences
;
352 KActionMenu
*bookmarkmenu
;
358 FXPluginHandler
*m_fxpluginhandler
;
361 bool m_textview_empty
;
362 bool m_enableChangeNotifications
;
363 QString m_currentBookmarkFile
;