1 /***************************************************************************
4 begin : Son Aug 10 13:26:57 EDT 2003
5 copyright : (C) 2003 by Robert Vogl
6 email : voglrobe@saphir
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
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>
32 #include <kbookmarkmanager.h>
33 #include <kbookmarkmenu.h>
35 // App specific includes
38 #define KSAYIT_BOOKMARKXMLFILE "/.ksayitbookmarks.xml"
40 // forward declaration of the KSayIt classes
42 class DocTreeViewImpl
;
43 class KSayItSystemTray
;
44 // class FXPluginHandler;
47 class KSayItBookmarkHandler
;
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.
61 class KSayItApp
: public KMainWindow
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);
73 // TODO: Replace with DBUS.
75 // /** DCOP interface for say operation
76 // \param msg The text to speak.
78 // ASYNC dcopSayText(QString msg);
80 // /** DCOP interface for stop operation
84 // /** DCOP interface to say DocBook file
86 // ASYNC dcopSayXmlFile(KUrl url);
90 /** emitted when the Configuration was modified
92 void signalConfigChanged();
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.
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.
120 /** changes the statusbar contents for the standard label permanently, used to indicate
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.
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.
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.
210 /** Hides the MainWindow
212 void slotCloseMainWindow();
214 /** Dialog to edit the Key associations
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
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
);
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
);
268 /** read general Options again and initialize all variables.
272 /** initializes the KActions of the application */
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.
287 /** resets the editor. Do not create an empty document.
291 /** start to say the text on the KTTSD's Job-Stack.
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
);
319 KSayItViewImpl
*view
;
320 KSayItSystemTray
*tray
;
322 DocTreeViewImpl
*treeview
;
323 KBookmarkManager
*bkManager
;
324 KSayItBookmarkHandler
*bkHandler
;
325 KBookmarkMenu
*bkMenu
;
328 KToggleAction
*statusBarAction
;
332 KAction
*next_sentence
;
333 KAction
*prev_sentence
;
341 KAction
*preferences
;
343 KActionMenu
*bookmarkmenu
;
349 // FXPluginHandler *m_fxpluginhandler;
352 bool m_textview_empty
;
353 bool m_enableChangeNotifications
;
354 QString m_currentBookmarkFile
;