SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / kcmkttsmgr / kcmkttsmgr.h
blob419cf66d08af5ddbacdb39e9b5df92da4fe77ae6
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 KControl module for KTTSD configuration and job management
3 -------------------
4 Copyright : (C) 2002-2003 by José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org>
5 Copyright : (C) 2004-2005 by Gary Cramblitt <garycramblitt@comcast.net>
6 -------------------
7 Original author: José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org>
8 Current Maintainer: 2004 by Gary Cramblitt <garycramblitt@comcast.net>
9 ******************************************************************************/
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; version 2 of the License. *
16 * *
17 ***************************************************************************/
19 /**
20 * @author José Pablo Ezequiel "Pupeno" Fernández
21 * @author Gary Cramblitt
24 #ifndef KCMKTTSMGR_H
25 #define KCMKTTSMGR_H
27 // Qt includes.
28 #include <QtCore/QMap>
29 #include <QtCore/QAbstractListModel>
30 #include <QtCore/QModelIndex>
32 // KDE includes.
33 #include <kcmodule.h>
34 #include <kdebug.h>
35 #include <kparts/part.h>
37 // KTTS includes.
38 #include "talkercode.h"
39 #include "talkerlistmodel.h"
40 #include "addtalker.h"
41 #include "ui_kcmkttsmgrwidget.h"
42 #include "kspeechinterface.h"
44 class PlugInConf;
45 class KttsFilterConf;
46 class QTreeWidget;
47 class QTreeWidgetItem;
48 class KAboutData;
49 class KConfig;
50 class QAction;
52 class FilterItem
54 public:
55 QString id;
56 QString userFilterName;
57 QString plugInName;
58 QString desktopEntryName;
59 bool enabled;
60 bool multiInstance;
63 typedef QList<FilterItem> FilterList;
65 class FilterListModel : public QAbstractListModel
67 Q_OBJECT
68 public:
69 explicit FilterListModel(FilterList filters = FilterList(), QObject *parent = 0);
71 FilterList datastore() { return m_filters; }
72 void setDatastore(FilterList filters = FilterList()) { m_filters = filters; }
73 int rowCount(const QModelIndex &parent = QModelIndex()) const;
74 int columnCount(const QModelIndex &parent = QModelIndex()) const;
75 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
76 QModelIndex parent(const QModelIndex & index ) const;
77 QVariant data(const QModelIndex &index, int role) const;
78 QVariant headerData(int section, Qt::Orientation orientation,
79 int role = Qt::DisplayRole) const;
80 Qt::ItemFlags flags(const QModelIndex &index) const;
81 bool removeRow(int row, const QModelIndex & parent = QModelIndex());
83 FilterItem getRow(int row) const;
84 bool appendRow(FilterItem& filter);
85 bool updateRow(int row, FilterItem& filter);
86 bool swap(int i, int j);
87 void clear();
88 protected:
89 FilterList m_filters;
92 class SbdFilterListModel : public FilterListModel
94 Q_OBJECT
95 public:
96 explicit SbdFilterListModel(FilterList filters = FilterList(), QObject *parent = 0);
98 int columnCount(const QModelIndex &parent = QModelIndex()) const;
99 QVariant data(const QModelIndex &index, int role) const;
100 QVariant headerData(int section, Qt::Orientation orientation,
101 int role = Qt::DisplayRole) const;
102 Qt::ItemFlags flags(const QModelIndex &index) const;
105 class KCMKttsMgr :
106 public KCModule,
107 private Ui::KCMKttsMgrWidget
109 Q_OBJECT
111 public:
112 KCMKttsMgr(QWidget *parent, const QVariantList &);
114 ~KCMKttsMgr();
117 * This method is invoked whenever the module should read its
118 * configuration (most of the times from a config file) and update the
119 * user interface. This happens when the user clicks the "Reset" button in
120 * the control center, to undo all of his changes and restore the currently
121 * valid settings. NOTE that this is not called after the modules is loaded,
122 * so you probably want to call this method in the constructor.
124 void load();
127 * This function gets called when the user wants to save the settings in
128 * the user interface, updating the config files or wherever the
129 * configuration is stored. The method is called when the user clicks "Apply"
130 * or "Ok".
132 void save();
135 * This function is called to set the settings in the module to sensible
136 * default values. It gets called when hitting the "Default" button. The
137 * default values should probably be the same as the ones the application
138 * uses when started without a config file.
140 void defaults();
143 * This is a static method which gets called to realize the modules settings
144 * durign the startup of KDE. NOTE that most modules do not implement this
145 * method, but modules like the keyboard and mouse modules, which directly
146 * interact with the X-server, need this method. As this method is static,
147 * it can avoid to create an instance of the user interface, which is often
148 * not needed in this case.
150 static void init();
153 * This function returns the small quickhelp.
154 * That is displayed in the sidebar in the KControl
156 QString quickHelp() const;
159 * Return the about information for this module
161 const KAboutData* aboutData() const;
163 public slots:
165 * This slot is used to emit the signal changed when any widget changes the configuration
167 void configChanged()
169 if (!m_suppressConfigChanged)
171 // kDebug() << "KCMKttsMgr::configChanged: Running";
172 m_changed = true;
173 emit changed(true);
177 protected slots:
178 /** DCOP Methods connected to DCOP Signals emitted by KTTSD. */
179 /** Most of these are not used */
182 * This signal is emitted when KTTSD starts or restarts after a call to reinit.
184 virtual void kttsdStarted();
186 * This signal is emitted just before KTTSD exits.
188 virtual void kttsdExiting();
190 // virtual void resizeEvent( QResizeEvent ev );
192 private:
193 enum widgetPages
195 wpGeneral = 0, // General tab.
196 wpTalkers = 1, // Talkers tab.
197 wpFilters = 2, // Filters tab.
198 wpInterruption = 3, // Interruption tab.
199 wpAudio = 4, // Audio tab.
200 wpJobs = 5 // Jobs tab.
204 * Conversion functions for percent boxes to/from sliders.
206 int percentToSlider(int percentValue);
207 int sliderToPercent(int sliderValue);
210 * Given a language code and plugin name, returns a normalized default talker code.
211 * @param languageCode Language code.
212 * @param plugInName Name of the plugin.
213 * @return Full normalized talker code.
215 * Example returned from defaultTalkerCode("en", "Festival")
216 * <voice lang="en" name="fixed" gender="neutral"/>
217 * <prosody volume="medium" rate="medium"/>
218 * <kttsd synthesizer="Festival" />
220 QString defaultTalkerCode(const QString &languageCode, const QString &plugInName);
223 * Loads the configuration plugin for a named Talker plugin.
224 * @param name DesktopEntryName of the Synthesizer.
225 * @return Pointer to the configuration plugin for the Talker.
227 PlugInConf* loadTalkerPlugin(const QString& name);
230 * Loads the configuration plugin for a named Filter plugin.
231 * @param plugInName DesktopEntryName of the plugin.
232 * @return Pointer to the configuration plugin for the Filter.
234 KttsFilterConf* loadFilterPlugin(const QString& plugInName);
237 * Display the Talker Configuration Dialog.
239 void configureTalker();
242 * Display the Filter Configuration Dialog.
244 void configureFilterItem( bool sbd );
245 void configureFilter();
248 * Add a filter.
250 void addFilter( bool sbd );
253 * Remove a filter.
255 void removeFilter( bool sbd );
258 * Count number of configured Filters with the specified plugin name.
260 int countFilterPlugins(const QString& filterPlugInName);
263 * Uses KTrader to convert a translated Filter Plugin Name to DesktopEntryName.
264 * @param name The translated plugin name. From Name= line in .desktop file.
265 * @return DesktopEntryName. The name of the .desktop file (less .desktop).
266 * QString() if not found.
268 QString FilterNameToDesktopEntryName(const QString& name);
271 * Uses KTrader to convert a DesktopEntryName into a translated Filter Plugin Name.
272 * @param desktopEntryName The DesktopEntryName.
273 * @return The translated Name of the plugin, from Name= line in .desktop file.
275 QString FilterDesktopEntryNameToName(const QString& desktopEntryName);
279 * A convenience method that finds an item in a TreeViewWidget, assuming there is at most
280 * one occurrence of the item. Returns 0 if not found.
281 * @param tw The TreeViewWidget to search.
282 * @param sought The string sought.
283 * @param col Column of the TreeViewWidget to search.
284 * @return The item of the TreeViewWidget found or null if not found.
286 * An exact match is performed.
288 QTreeWidgetItem* findTreeWidgetItem(QTreeWidget* tw, const QString& sought, int col);
291 * DBUS KSpeech Interface.
293 org::kde::KSpeech* m_kspeech;
296 * Object holding all the configuration
298 KConfig *m_config;
301 * KTTS Job Manager.
303 KParts::ReadOnlyPart *m_jobMgrPart;
306 * Plugin configuration dialog.
308 KDialog* m_configDlg;
311 * Sentence Boundary Detector button popup menu actions.
313 QAction* m_sbdBtnEdit;
314 QAction* m_sbdBtnUp;
315 QAction* m_sbdBtnDown;
316 QAction* m_sbdBtnAdd;
317 QAction* m_sbdBtnRemove;
320 * Talker(synth) Plugin currently loaded into configuration dialog.
322 PlugInConf *m_loadedTalkerPlugIn;
325 * Filter Plugin currently loaded into configuration dialog.
327 KttsFilterConf *m_loadedFilterPlugIn;
330 * Model containing list of Talker Codes.
332 TalkerListModel m_talkerListModel;
335 * Last talker ID. Used to generate a new ID.
337 int m_lastTalkerID;
340 * Models containing normal and SBD filters.
342 FilterListModel m_filterListModel;
343 SbdFilterListModel m_sbdFilterListModel;
346 * Last filter ID. Used to generate a new ID.
348 int m_lastFilterID;
351 * Last SBD filter ID. Used to generate to new ID.
353 int m_lastSbdID;
356 * True if the configuration has been changed.
358 bool m_changed;
361 * When True, suppresses emission of changed() signal. Used to suppress this
362 * signal while loading configuration.
364 bool m_suppressConfigChanged;
367 * Dictionary mapping language names to codes.
369 QMap<QString, QString> m_languagesToCodes;
372 * A QMap of languages codes indexed by synthesizer that supports them.
374 SynthToLangMap m_synthToLangMap;
376 private slots:
378 * Update the status of the Talker/Filter buttons.
380 void updateTalkerButtons();
381 void updateFilterButtons();
382 void updateSbdButtons();
385 * Slots for the Talker/Filter Configuration dialogs.
387 void slotConfigTalkerDlg_ConfigChanged();
388 void slotConfigFilterDlg_ConfigChanged();
389 void slotConfigTalkerDlg_DefaultClicked();
390 void slotConfigFilterDlg_DefaultClicked();
391 void slotConfigTalkerDlg_CancelClicked();
392 void slotConfigFilterDlg_CancelClicked();
395 * General tab slots.
397 void slotEnableKttsd_toggled(bool checked);
398 void slotAutoStartMgrCheckBox_toggled(bool checked);
401 * Talker tab slots.
403 void slotAddTalkerButton_clicked();
404 void slotRemoveTalkerButton_clicked();
405 void slotHigherTalkerPriorityButton_clicked();
406 void slotLowerTalkerPriorityButton_clicked();
407 void slotConfigureTalkerButton_clicked();
411 * Filters tab slots.
413 void slotFilterListView_clicked(const QModelIndex & index);
414 void slotAddNormalFilterButton_clicked();
415 void slotAddSbdFilterButton_clicked();
416 void slotRemoveNormalFilterButton_clicked();
417 void slotRemoveSbdFilterButton_clicked();
418 void slotHigherNormalFilterPriorityButton_clicked();
419 void slotHigherSbdFilterPriorityButton_clicked();
420 void slotLowerNormalFilterPriorityButton_clicked();
421 void slotLowerSbdFilterPriorityButton_clicked();
422 void slotConfigureNormalFilterButton_clicked();
423 void slotConfigureSbdFilterButton_clicked();
426 * Interruption tab slots.
428 void slotTextPreMsgCheck_toggled(bool checked);
429 void slotTextPreSndCheck_toggled(bool checked);
430 void slotTextPostMsgCheck_toggled(bool checked);
431 void slotTextPostSndCheck_toggled(bool checked);
434 * Audio tab slots.
436 void timeBox_valueChanged(int percentValue);
437 void timeSlider_valueChanged(int sliderValue);
438 void keepAudioCheckBox_toggled(bool checked);
439 void slotPhononRadioButton_toggled(bool state);
440 void slotAlsaRadioButton_toggled(bool state);
441 void slotPcmComboBox_activated();
444 * Other slots.
446 void slotTabChanged();
449 #endif