SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / filters / stringreplacer / stringreplacerconf.h
blob2edc0e53fc8ae5bf9ff95da5124b16085797e03e
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 Generic String Replacement Filter Configuration class.
3 -------------------
4 Copyright:
5 (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
6 -------------------
7 Original author: Gary Cramblitt <garycramblitt@comcast.net>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ******************************************************************************/
24 #ifndef _STRINGREPLACERCONF_H_
25 #define _STRINGREPLACERCONF_H_
27 // Qt includes.
28 #include <QtGui/QWidget>
30 // KDE includes.
31 #include <kconfig.h>
32 #include <kdebug.h>
34 // KTTS includes.
35 #include "filterconf.h"
37 // StringReplacer includes.
38 #include "ui_stringreplacerconfwidget.h"
39 #include "ui_editreplacementwidget.h"
41 class KDialog;
43 class StringReplacerConf : public KttsFilterConf, public Ui::StringReplacerConfWidget
45 Q_OBJECT
47 public:
48 /**
49 * Constructor
51 explicit StringReplacerConf( QWidget *parent, const QStringList &args = QStringList() );
53 /**
54 * Destructor
56 virtual ~StringReplacerConf();
58 enum SubstitutionType {
59 stWord, // Word
60 stRegExp // Regular Expression
63 /**
64 * This method is invoked whenever the module should read its
65 * configuration (most of the times from a config file) and update the
66 * user interface. This happens when the user clicks the "Reset" button in
67 * the control center, to undo all of his changes and restore the currently
68 * valid settings. Note that KTTSMGR calls this when the plugin is
69 * loaded, so it not necessary to call it in your constructor.
70 * The plugin should read its configuration from the specified group
71 * in the specified config file.
72 * @param config Pointer to a KConfig object.
73 * @param configGroup Call config->setGroup with this argument before
74 * loading your configuration.
76 * When a plugin is first added to KTTSMGR, @e load will be called with
77 * a Null @e configGroup. In this case, the plugin will not have
78 * any instance-specific parameters to load, but it may still wish
79 * to load parameters that apply to all instances of the plugin.
81 virtual void load(KConfig *config, const QString &configGroup);
83 /**
84 * This function gets called when the user wants to save the settings in
85 * the user interface, updating the config files or wherever the
86 * configuration is stored. The method is called when the user clicks "Apply"
87 * or "Ok". The plugin should save its configuration in the specified
88 * group of the specified config file.
89 * @param config Pointer to a KConfig object.
90 * @param configGroup Call config->setGroup with this argument before
91 * saving your configuration.
93 virtual void save(KConfig *config, const QString &configGroup);
95 /**
96 * This function is called to set the settings in the module to sensible
97 * default values. It gets called when hitting the "Default" button. The
98 * default values should probably be the same as the ones the application
99 * uses when started without a config file. Note that defaults should
100 * be applied to the on-screen widgets; not to the config file.
102 virtual void defaults();
105 * Indicates whether the plugin supports multiple instances. Return
106 * False if only one instance of the plugin can be configured.
107 * @return True if multiple instances are possible.
109 virtual bool supportsMultiInstance();
112 * Returns the name of the plugin. Displayed in Filters tab of KTTSMgr.
113 * If there can be more than one instance of a filter, it should return
114 * a unique name for each instance. The name should be translated for
115 * the user if possible. If the plugin is not correctly configured,
116 * return an empty string.
117 * @return Filter instance name.
119 virtual QString userPlugInName();
121 private slots:
122 void slotLanguageBrowseButton_clicked();
123 void slotAddButton_clicked();
124 void slotUpButton_clicked();
125 void slotDownButton_clicked();
126 void slotEditButton_clicked();
127 void slotRemoveButton_clicked();
128 void slotMatchLineEdit_textChanged(const QString& text);
129 void slotTypeButtonGroup_clicked();
130 void slotMatchButton_clicked();
131 void slotLoadButton_clicked();
132 void slotSaveButton_clicked();
133 void slotClearButton_clicked();
135 // EnablesDisables buttons depending upon current item in list view.
136 void enableDisableButtons();
138 private:
139 // Converts a Substitution Type to displayable string.
140 QString substitutionTypeToString(const int substitutionType);
141 // Displays the add/edit string replacement dialog.
142 void addOrEditSubstitution(bool isAdd);
143 // Loads word list and settings from a file. Clearing configuration if clear is True.
144 QString loadFromFile( const QString& filename, bool clear);
145 // Saves word list and settings to a file.
146 QString saveToFile( const QString& filename );
149 // Edit Dialog and widget.
150 KDialog* m_editDlg;
151 Ui::EditReplacementWidget* m_editWidget;
152 // True if kdeutils Regular Expression Editor is installed.
153 bool m_reEditorInstalled;
154 // Language Codes.
155 QStringList m_languageCodeList;
158 #endif //_STRINGREPLACERCONF_H_