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 ***************************************************************************/
28 // include files for Qt
29 #include <QStringList>
32 // include files for KDE
33 #include <kapplication.h>
34 #include <kmainwindow.h>
38 #include <kbookmarkmanager.h>
39 #include <kbookmarkmenu.h>
41 // App specific includes
44 #define KSAYIT_BOOKMARKXMLFILE "/.ksayitbookmarks.xml"
46 // forward declaration of the KSayIt classes
48 class DocTreeViewImpl
;
49 class KSayItSystemTray
;
50 // class FXPluginHandler;
53 class KSayItBookmarkHandler
;
56 * The base class for KSayIt application windows. It sets up the main
57 * window and reads the config file as well as providing a menubar, toolbar
58 * and statusbar. An instance of KSayItView creates the center view.
59 * KSayItApp reimplements the methods that KMainWindow provides for main window handling and supports
60 * full session management as well as using KActions.
67 class KSayItApp
: public KMainWindow
73 /** construtor of KSayItApp, calls all init functions to create the application.
75 KSayItApp(QWidget
* parent
=0, const char* name
=0, Qt::WFlags f
=0,
76 const QByteArray
&objID
=0);
79 // TODO: Replace with DBUS.
81 // /** DCOP interface for say operation
82 // \param msg The text to speak.
84 // ASYNC dcopSayText(QString msg);
86 // /** DCOP interface for stop operation
90 // /** DCOP interface to say DocBook file
92 // ASYNC dcopSayXmlFile(KUrl url);
96 /** emitted when the Configuration was modified
98 void signalConfigChanged();
101 /** Puts the given text on the Job-Stack of KTTSD.
102 * \param text The text to say.
104 void slotSetText(const QString
&text
);
106 /** Called from the ListView widget after one or many
107 * 'setText'-Calls. Starts to say the text.
111 /** Called when a node in the treeview was clicked and
112 * new content in the edit window must be shown.
113 * \str The new content of the EditView.
115 void slotTreeViewChanged(const QString
&str
);
117 /** save general Options like all bar positions and status as well as the geometry to
118 * the configuration file.
120 void slotSaveOptions();
122 /** closes the windows , then quits the application.
126 /** changes the statusbar contents for the standard label permanently, used to indicate
128 * @param text the text that is displayed in the statusbar
130 void slotStatusMsg(const QString
&text
);
132 /** opens the Preferences-Dialog.
134 void slotPreferences();
136 /** activated if "say" from tray was clicked.
138 void slotSayClipboard();
140 /** activated if "say" from app-window was clicked.
144 /** activated if "shut up" was clicked.
146 void slotStopActivated();
148 /** activated if "pause" was clicked.
150 void slotPauseActivated();
152 /** activated if "next sentence" was clicked.
154 void slotNextSentenceActivated();
156 /** activated if "previous sentence" was clicked.
158 void slotPrevSentenceActivated();
160 /** called if text processing was finished.
164 /** called to enable the copy/cut action, if text is selected in the TextEdit-View
165 \param enable Enable actions if true, disable actions if false.
167 void slotEnableCopyCut(bool enable
);
169 /** sets the Caption of the MainWindow */
170 void slotSetCaption(const QString
&caption
);
172 /** called when the Text was changed.
173 * \param empty True if the TextEdit view is empty.
175 void slotTextChanged(bool empty
);
177 /** enabled/disables the textedit window;
178 * \param enable true=enabled, false=disabled
180 void slotEnableTextedit(bool enable
);
182 /** toggles the statusbar
184 void slotToggleStatusBar();
186 /** Called when the ToolBar shall be configured by the user.
188 void slotConfigureToolbar();
190 /** Called to add a bookmark.
192 void slotAddBookmark();
194 /** Called to delete a bookmark
196 void slotDeleteBookmark(const QString
&url
, const QString
&title
);
198 /** Called to edit bookmarks.
200 void slotEditBookmarks();
202 /** Called from slotConfigureToolbar() if we have a new ToolBar-configuration.
204 void slotNewToolbarConfig();
206 /** called whenever the content of the clipboard changes.
207 * Checks if the content of the Clipboard is of type text/plain.
208 * Disables and enables the SystemTray-object.
210 void slotClipboardChanged();
212 /** Deletes the content of the Textview.
216 /** Hides the MainWindow
218 void slotCloseMainWindow();
220 /** Dialog to edit the Key associations
234 void slotFileSaveAs();
236 /** Called, when the TTS Library has finished processing.
238 void slotTTSFinished();
240 /** Edit mode switched on/off.
242 void slotEditToggled();
245 * Catches the signal from the TreeView object
246 * and forwards it to the BookmarkHandler object.
248 void slotNotifyBookmarkHandler(const QString
&ID
, const QString
&title
);
251 * Copies the content of the current bookmark file to the
252 * file designated by \p newname and install a new
254 * \param newname The name of the new bookmark file.
256 void slotChangeBookmarkFilename(const QString
&newname
);
258 /** Loads bookmark file corresponding to the given file.
259 * \param newname The name of the new file.
261 void slotSetBookmarkFilename(const QString
&newname
);
265 * Selects the item with the given ID in the TreeView.
266 * \param ID The ID of the item to select.
267 * \param title The title of the bookmark.
268 * \returns <tt>QString()</tt>, if the operation was successfull,
269 * an error message, if the ID was not found.
271 QString
setItemByBookmark( const QString
&ID
, const QString
&title
);
274 /** read general Options again and initialize all variables.
278 /** initializes the KActions of the application */
281 /** sets up the statusbar for the main window by initialzing a statuslabel.
283 void initStatusBar();
287 void initBookmarkManager(const QString
&filename
);
289 /** creates the centerwidget of the KTMainWindow instance and sets it as the view.
293 /** resets the editor. Do not create an empty document.
297 /** start to say the text on the KTTSD's Job-Stack.
301 /** reimplemented from baseclass
303 virtual void closeEvent(QCloseEvent
*ce
);
305 /** disable/enable Actions.
306 * \param actions An OR'ed integer of enum ACTIONS. A '1' is supposed
307 * as 'Action enabled'.
309 void setActions(int actions
);
312 * Returns the absolute pathname of the given bookmarkfile.
313 * This is the first KDE resource directory \p (share/apps) in which
314 * the user has write permissions. The relative path is
315 * \p ksayit/ksayit_bookmarks/.
316 * \param filename The name of the bookmark file.
317 * \returns The absolute pathname of the given bookmark file.
318 * Returns \p QString() if the operation was not successfull.
320 QString
getBookmarkDir(const QString
&filename
);
325 KSayItViewImpl
*view
;
326 KSayItSystemTray
*tray
;
328 DocTreeViewImpl
*treeview
;
329 KBookmarkManager
*bkManager
;
330 KSayItBookmarkHandler
*bkHandler
;
331 KBookmarkMenu
*bkMenu
;
334 KToggleAction
*statusBarAction
;
338 KAction
*next_sentence
;
339 KAction
*prev_sentence
;
347 KAction
*preferences
;
349 KActionMenu
*bookmarkmenu
;
355 // FXPluginHandler *m_fxpluginhandler;
358 bool m_textview_empty
;
359 bool m_enableChangeNotifications
;
360 QString m_currentBookmarkFile
;