26 #include "talkerchooserconf.moc"
33 #include <klineedit.h>
35 #include <kcombobox.h>
36 #include <kpushbutton.h>
38 #include <kstandarddirs.h>
39 #include <kregexpeditorinterface.h>
40 #include <kfiledialog.h>
41 #include <kservicetypetrader.h>
59 m_reEditorInstalled = !KServiceTypeTrader::self()->query(QLatin1String(
"KRegExpEditor/KRegExpEditor" )).isEmpty();
60 reEditorButton->setEnabled(m_reEditorInstalled);
62 connect(nameLineEdit, SIGNAL(textChanged(QString)),
64 connect(reLineEdit, SIGNAL(textChanged(QString)),
66 connect(reEditorButton, SIGNAL(clicked()),
67 this, SLOT(slotReEditorButton_clicked()));
68 connect(appIdLineEdit, SIGNAL(textChanged(QString)),
70 connect(talkerButton, SIGNAL(clicked()),
71 this, SLOT(slotTalkerButton_clicked()));
73 connect(loadButton, SIGNAL(clicked()),
74 this, SLOT(slotLoadButton_clicked()));
75 connect(saveButton, SIGNAL(clicked()),
76 this, SLOT(slotSaveButton_clicked()));
77 connect(clearButton, SIGNAL(clicked()),
78 this, SLOT(slotClearButton_clicked()));
93 KConfigGroup config( c, configGroup );
94 nameLineEdit->setText( config.readEntry(
"UserFilterName", nameLineEdit->text() ) );
96 config.readEntry(
"MatchRegExp", reLineEdit->text()) );
97 appIdLineEdit->setText(
98 config.readEntry(
"AppIDs", appIdLineEdit->text()) );
100 m_talkerCode =
TalkerCode(config.readEntry(
"TalkerCode"),
false);
102 QString s = config.readEntry(
"LanguageCode" );
104 s = config.readEntry(
"SynthInName" );
106 s = config.readEntry(
"Gender" );
108 s = config.readEntry(
"Volume" );
110 s = config.readEntry(
"Rate" );
118 KConfigGroup config( c, configGroup );
119 config.writeEntry(
"UserFilterName", nameLineEdit->text() );
120 config.writeEntry(
"MatchRegExp", reLineEdit->text() );
121 config.writeEntry(
"AppIDs", appIdLineEdit->text().remove(QLatin1Char(
' ' )) );
122 config.writeEntry(
"TalkerCode", m_talkerCode.
getTalkerCode());
135 nameLineEdit->setText( i18n(
"Talker Chooser") );
137 reLineEdit->clear( );
139 appIdLineEdit->clear();
141 m_talkerCode =
TalkerCode( QString(),
false );
162 if (talkerLineEdit->text().isEmpty())
return QString();
163 if (appIdLineEdit->text().isEmpty() &&
164 reLineEdit->text().isEmpty())
return QString();
165 QString instName = nameLineEdit->text();
166 if (instName.isEmpty())
return QString();
170 void TalkerChooserConf::slotReEditorButton_clicked()
173 if ( !m_reEditorInstalled )
return;
175 KServiceTypeTrader::createInstanceFromQuery<KDialog>( QLatin1String(
"KRegExpEditor/KRegExpEditor" ));
179 KRegExpEditorInterface *reEditor =
180 qobject_cast<KRegExpEditorInterface *>(editorDialog);
181 Q_ASSERT( reEditor );
182 reEditor->setRegExp( reLineEdit->text() );
183 int dlgResult = editorDialog->exec();
184 if ( dlgResult == QDialog::Accepted )
186 QString re = reEditor->regExp();
187 reLineEdit->setText( re );
193 void TalkerChooserConf::slotTalkerButton_clicked()
196 QPointer<SelectTalkerDlg> dlg =
new SelectTalkerDlg(
this,
"selecttalkerdialog", i18n(
"Select Talker"), talkerCode,
true);
197 int dlgResult = dlg->exec();
198 if ( dlgResult != KDialog::Accepted )
return;
199 m_talkerCode =
TalkerCode( dlg->getSelectedTalkerCode(), false );
205 void TalkerChooserConf::slotLoadButton_clicked()
207 QStringList dataDirs = KGlobal::dirs()->findAllResources(
"data", QLatin1String(
"kttsd/talkerchooser/" ));
209 if (!dataDirs.isEmpty()) dataDir = dataDirs.last();
210 QString filename = KFileDialog::getOpenFileName(
212 QLatin1String(
"*rc|" ) + i18n(
"Talker Chooser Config (*rc)" ),
214 QLatin1String(
"talkerchooser_loadfile" ));
215 if ( filename.isEmpty() )
return;
216 KConfig* cfg =
new KConfig( filename );
217 load( cfg, QLatin1String(
"Filter" ) );
222 void TalkerChooserConf::slotSaveButton_clicked()
224 QString filename = KFileDialog::getSaveFileName(
225 KGlobal::dirs()->saveLocation(
"data" ,QLatin1String(
"kttsd/talkerchooser/" ),
false ) ,
226 QLatin1String(
"*rc|" ) + i18n(
"Talker Chooser Config (*rc)" ),
228 QLatin1String(
"talkerchooser_savefile" ));
229 if ( filename.isEmpty() )
return;
230 KConfig* cfg =
new KConfig( filename );
231 save( cfg, QLatin1String(
"Filter" ) );
235 void TalkerChooserConf::slotClearButton_clicked()
237 nameLineEdit->setText( QString() );
238 reLineEdit->setText( QString() );
239 appIdLineEdit->setText( QString() );
240 m_talkerCode =
TalkerCode( QString(),
false );
virtual void defaults()
This function is called to set the settings in the module to sensible default values.
void setLanguage(const QString &language)
QString getTranslatedDescription() const
The Talker Code translated for display.
virtual bool supportsMultiInstance()
Indicates whether the plugin supports multiple instances.
virtual ~TalkerChooserConf()
Destructor.
virtual void load(KConfig *c, const QString &configGroup)
This method is invoked whenever the module should read its configuration (most of the times from a co...
virtual void save(KConfig *c, const QString &configGroup)
This function gets called when the user wants to save the settings in the user interface, updating the config files or wherever the configuration is stored.
QString getTalkerCode() const
void configChanged()
This slot is used internally when the configuration is changed.
virtual QString userPlugInName()
Returns the name of the plugin.
TalkerChooserConf(QWidget *parent, const QVariantList &args)
Constructor.