32 #include "kcmkttsmgr.moc"
38 #include <QtGui/QWidget>
39 #include <QtGui/QTabWidget>
40 #include <QtGui/QCheckBox>
41 #include <QtGui/QLayout>
42 #include <QtGui/QRadioButton>
43 #include <QtGui/QSlider>
44 #include <QtGui/QLabel>
45 #include <QtGui/QTreeWidget>
46 #include <QtGui/QHeaderView>
47 #include <QtCore/QTextStream>
48 #include <QtGui/QMenu>
51 #include <klineedit.h>
52 #include <kurlrequester.h>
54 #include <kstandarddirs.h>
55 #include <kaboutdata.h>
57 #include <knuminput.h>
58 #include <kcombobox.h>
59 #include <kinputdialog.h>
60 #include <kmessagebox.h>
61 #include <kfiledialog.h>
62 #include <ktoolinvocation.h>
65 #include <kpluginfactory.h>
66 #include <kpluginloader.h>
67 #include <kservicetypetrader.h>
84 K_PLUGIN_FACTORY (KCMKttsMgrFactory, registerPlugin<KCMKttsMgr>();)
85 K_EXPORT_PLUGIN (KCMKttsMgrFactory (
"jovie"))
97 if (!parent.isValid())
111 if (!parent.isValid())
112 return createIndex (row, column, 0);
114 return QModelIndex();
120 return QModelIndex();
125 if (!index.isValid())
128 if (index.row() < 0 || index.row() >=
m_filters.count())
131 if (index.column() < 0 || index.column() >= 2)
134 if (role == Qt::DisplayRole || role == Qt::EditRole)
135 switch (index.column()) {
140 return m_filters.at (index.row()).userFilterName;
144 if (role == Qt::CheckStateRole)
145 switch (index.column()) {
150 return Qt::Unchecked;
162 if (!index.isValid())
163 return Qt::ItemIsEnabled;
165 switch (index.column()) {
167 return QAbstractItemModel::flags (index) | Qt::ItemIsEnabled |
168 Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
171 return QAbstractItemModel::flags (index) | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
174 return QAbstractItemModel::flags (index) | Qt::ItemIsEnabled;
179 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
182 return QLatin1String(
"" );
184 return i18n (
"Filter");
191 beginRemoveRows (parent, row, row);
237 KCModule (KCMKttsMgrFactory::componentData(), parent),
248 m_suppressConfigChanged =
false;
254 talkersView->setModel (&m_talkerListModel);
255 filtersView->setModel (&m_filterListModel);
256 talkersView->setSelectionBehavior (QAbstractItemView::SelectRows);
257 filtersView->setSelectionBehavior (QAbstractItemView::SelectRows);
258 talkersView->setRootIsDecorated (
false);
259 filtersView->setRootIsDecorated (
false);
260 talkersView->setItemsExpandable (
false);
261 filtersView->setItemsExpandable (
false);
265 higherTalkerPriorityButton->setIcon (KIcon ( QLatin1String(
"go-up" )));
266 lowerTalkerPriorityButton->setIcon (KIcon ( QLatin1String(
"go-down" )));
267 removeTalkerButton->setIcon (KIcon ( QLatin1String(
"user-trash" )));
268 configureTalkerButton->setIcon (KIcon ( QLatin1String(
"configure" )));
271 higherFilterPriorityButton->setIcon (KIcon ( QLatin1String(
"go-up" )));
272 lowerFilterPriorityButton->setIcon (KIcon ( QLatin1String(
"go-down" )));
273 removeFilterButton->setIcon (KIcon ( QLatin1String(
"user-trash" )));
274 configureFilterButton->setIcon (KIcon ( QLatin1String(
"configure" )));
277 m_config =
new KConfig (QLatin1String(
"kttsdrc" ));
282 connect (enableJovieCheckBox, SIGNAL (toggled(
bool)),
283 SLOT (slotEnableJovie_toggled(
bool)));
286 connect (addTalkerButton, SIGNAL (clicked()),
287 this, SLOT (slotAddTalkerButton_clicked()));
288 connect (higherTalkerPriorityButton, SIGNAL (clicked()),
289 this, SLOT (slotHigherTalkerPriorityButton_clicked()));
290 connect (lowerTalkerPriorityButton, SIGNAL (clicked()),
291 this, SLOT (slotLowerTalkerPriorityButton_clicked()));
292 connect (removeTalkerButton, SIGNAL (clicked()),
293 this, SLOT (slotRemoveTalkerButton_clicked()));
294 connect (configureTalkerButton, SIGNAL (clicked()),
295 this, SLOT (slotConfigureTalkerButton_clicked()));
296 connect (talkersView, SIGNAL (clicked(QModelIndex)),
297 this, SLOT (updateTalkerButtons()));
300 connect (addFilterButton, SIGNAL (clicked()),
301 this, SLOT (slotAddFilterButton_clicked()));
302 connect (higherFilterPriorityButton, SIGNAL (clicked()),
303 this, SLOT (slotHigherFilterPriorityButton_clicked()));
304 connect (lowerFilterPriorityButton, SIGNAL (clicked()),
305 this, SLOT (slotLowerFilterPriorityButton_clicked()));
306 connect (removeFilterButton, SIGNAL (clicked()),
307 this, SLOT (slotRemoveFilterButton_clicked()));
308 connect (configureFilterButton, SIGNAL (clicked()),
309 this, SLOT (slotConfigureFilterButton_clicked()));
310 connect (filtersView, SIGNAL (clicked(QModelIndex)),
311 this, SLOT (updateFilterButtons()));
312 connect (filtersView, SIGNAL (clicked(QModelIndex)),
313 this, SLOT (slotFilterListView_clicked(QModelIndex)));
317 connect (mainTab, SIGNAL (currentChanged(
int)),
318 this, SLOT (slotTabChanged()));
321 if (QDBusConnection::sessionBus().interface()->isServiceRegistered (QLatin1String(
"org.kde.jovie" )))
325 slotEnableJovie_toggled (enableJovieCheckBox->isChecked());
330 for (
int i = 0; i < m_filterListModel.
columnCount(); ++i)
331 filtersView->resizeColumnToContents (i);
332 for (
int i = 0; i < m_talkerListModel.
columnCount(); ++i)
333 talkersView->resizeColumnToContents (i);
337 if (m_talkerListModel.
rowCount() == 0)
338 mainTab->setCurrentIndex (wpTalkers);
339 else if (enableJovieCheckBox->isChecked())
340 mainTab->setCurrentIndex (wpJobs);
366 m_suppressConfigChanged =
true;
369 KConfigGroup generalConfig (m_config,
"General");
372 enableJovieCheckBox->setChecked (generalConfig.readEntry (
"EnableJovie",
373 enableJovieCheckBox->isChecked()));
385 m_languagesToCodes.clear();
386 for (
int i = 0; i < m_talkerListModel.
rowCount(); ++i) {
388 m_languagesToCodes[language] = language;
417 m_filterListModel.
clear();
418 QStringList filterIDsList = generalConfig.readEntry (
"FilterIDs", QStringList());
420 if (!filterIDsList.isEmpty()) {
421 QStringList::ConstIterator itEnd = filterIDsList.constEnd();
422 for (QStringList::ConstIterator it = filterIDsList.constBegin(); it != itEnd; ++it) {
423 QString filterID = *it;
425 KConfigGroup filterConfig (m_config, QLatin1String(
"Filter_" ) + filterID);
426 QString desktopEntryName = filterConfig.readEntry (
"DesktopEntryName", QString());
432 QString filterPlugInName;
433 filterPlugInName = FilterDesktopEntryNameToName (desktopEntryName);
434 if (!filterPlugInName.isEmpty()) {
439 fi.
userFilterName = filterConfig.readEntry (
"UserFilterName", filterPlugInName);
440 fi.
multiInstance = filterConfig.readEntry (
"MultiInstance",
false);
441 fi.
enabled = filterConfig.readEntry (
"Enabled",
false);
444 if (filterID.toInt() > m_lastFilterID) m_lastFilterID = filterID.toInt();
501 QString filterIDs = filterIDsList.join (QLatin1String(
"," ));
502 generalConfig.writeEntry (
"FilterIDs", filterIDs);
506 updateTalkerButtons();
507 updateFilterButtons();
510 m_suppressConfigChanged =
false;
525 m_config->deleteGroup (
"General", 0);
528 KConfigGroup generalConfig (m_config,
"General");
532 bool enableJovieWasToggled =
false;
542 enableJovieCheckBox->setEnabled (
true);
544 generalConfig.writeEntry (
"EnableKttsd", enableJovieCheckBox->isChecked());
547 QList<TalkerCode> talkers;
548 QStringList talkerIDsList;
549 KConfigGroup talkerGroup (m_config,
"Talkers");
550 talkerGroup.deleteGroup();
551 for (
int i = 0; i < m_talkerListModel.
rowCount(); ++i) {
554 talkerGroup.writeEntry (talker.name(), talker.getTalkerCode());
555 talkerIDsList << talker.
name();
558 QString talkerIDs = talkerIDsList.join (QLatin1String(
"," ));
559 generalConfig.writeEntry (
"TalkerIDs", talkerIDs);
562 QStringList groupList = m_config->groupList();
563 int groupListCount = groupList.count();
564 for (
int groupNdx = 0; groupNdx < groupListCount; ++groupNdx) {
565 QString groupName = groupList[groupNdx];
566 if (groupName.left (7) == QLatin1String(
"Talker_" )) {
567 QString groupTalkerID = groupName.mid (7);
568 if (!talkerIDsList.contains (groupTalkerID))
569 m_config->deleteGroup (groupName, 0);
574 QStringList filterIDsList;
575 for (
int i = 0; i < m_filterListModel.
rowCount(); ++i) {
577 filterIDsList.append (fi.
id);
578 KConfigGroup filterConfig (m_config, QLatin1String(
"Filter_" ) + fi.
id);
579 filterConfig.writeEntry (
"Enabled", fi.
enabled);
581 QString filterIDs = filterIDsList.join (QLatin1String(
"," ));
582 generalConfig.writeEntry (
"FilterIDs", filterIDs);
585 for (
int groupNdx = 0; groupNdx < groupListCount; ++groupNdx) {
586 QString groupName = groupList[groupNdx];
587 if (groupName.left (7) == QLatin1String(
"Filter_" )) {
588 QString groupFilterID = groupName.mid (7);
589 if (!filterIDsList.contains (groupFilterID))
590 m_config->deleteGroup (groupName, 0);
597 if (m_jobMgrWidget) {
598 m_jobMgrWidget->
save();
602 if (enableJovieWasToggled)
603 slotEnableJovie_toggled (
false);
607 kDebug() <<
"Restarting Jovie";
613 void KCMKttsMgr::slotTabChanged()
619 int currentPageIndex = mainTab->currentIndex();
620 if (currentPageIndex == wpJobs) {
622 KMessageBox::information (
this,
623 i18n (
"You have made changes to the configuration but have not saved them yet. "
624 "Click Apply to save the changes or Cancel to abandon the changes."));
639 int currentPageIndex = mainTab->currentIndex();
664 "<h1>Text-to-Speech</h1>"
665 "<p>This is the configuration for the text-to-speech D-Bus service</p>"
666 "<p>This allows other applications to access text-to-speech resources</p>"
667 "<p>Be sure to configure a default language for the language you are using as this will be the language used by most of the applications</p>");
673 new KAboutData (I18N_NOOP (
"jovie"), 0, ki18n (
"KCMKttsMgr"),
674 0, KLocalizedString(), KAboutData::License_GPL,
675 ki18n (
"(c) 2010, Jeremy Whiting"));
677 about->addAuthor (ki18n (
"José Pablo Ezequiel Fernández"), ki18n (
"Author") ,
"pupeno@kde.org");
678 about->addAuthor (ki18n (
"Gary Cramblitt"), ki18n (
"Maintainer") ,
"garycramblitt@comcast.net");
679 about->addAuthor (ki18n (
"Olaf Schmidt"), ki18n (
"Contributor"),
"ojschmidt@kde.org");
680 about->addAuthor (ki18n (
"Paul Giannaros"), ki18n (
"Contributor"),
"ceruleanblaze@gmail.com");
690 KttsFilterConf* KCMKttsMgr::loadFilterPlugin (
const QString& plugInName)
695 KService::List offers = KServiceTypeTrader::self()->query (QLatin1String(
"Jovie/FilterPlugin" ),
696 QString (QLatin1String(
"DesktopEntryName == '%1'" )).arg (plugInName));
698 if (offers.count() == 1) {
701 KLibFactory *factory = KLibLoader::self()->factory (QLatin1String( offers[0]->library().toLatin1() ));
707 KLibLoader::createInstance<KttsFilterConf> (
708 QLatin1String( offers[0]->library().toLatin1() ), NULL, QStringList ( QLatin1String( offers[0]->library().toLatin1() )),
715 kDebug() <<
"KCMKttsMgr::loadFilterPlugin: Unable to instantiate KttsFilterConf class for plugin " << plugInName <<
" error: " << errorNo;
720 kDebug() <<
"KCMKttsMgr::loadFilterPlugin: Unable to create Factory object for plugin " << plugInName;
725 kDebug() <<
"KCMKttsMgr::loadFilterPlugin: KTrader did not return an offer for plugin " << plugInName;
732 void KCMKttsMgr::slotAddTalkerButton_clicked()
734 QPointer<AddTalker> dlg =
new AddTalker (
this);
735 if (dlg->exec() == QDialog::Accepted) {
742 const QModelIndex modelIndex = m_talkerListModel.
index (m_talkerListModel.
rowCount() - 1,
744 talkersView->scrollTo (modelIndex);
747 talkersView->setCurrentIndex (modelIndex);
748 updateTalkerButtons();
755 kDebug() <<
"KCMKttsMgr::addTalker: done.";
758 void KCMKttsMgr::slotAddFilterButton_clicked()
766 void KCMKttsMgr::addFilter()
768 QTreeView* lView = filtersView;
772 QStringList filterPlugInNames;
773 for (
int i = 0; i < model->
rowCount(); ++i) {
776 if (!filterPlugInNames.contains (fi.
plugInName))
781 KService::List offers = KServiceTypeTrader::self()->query (QLatin1String(
"Jovie/FilterPlugin" ));
782 for (
int i = 0; i < offers.count() ; ++i) {
783 QString filterPlugInName = offers[i]->name();
784 if (countFilterPlugins (filterPlugInName) == 0) {
785 QString desktopEntryName = FilterNameToDesktopEntryName (filterPlugInName);
788 filterPlugInNames.append (filterPlugInName);
796 if (filterPlugInNames.count() == 0)
return;
799 bool okChosen =
false;
800 QString filterPlugInName;
801 if (filterPlugInNames.count() > 1) {
802 filterPlugInName = KInputDialog::getItem (
803 i18n (
"Select Filter"),
810 if (!okChosen)
return;
812 filterPlugInName = filterPlugInNames[0];
817 QString filterID = QString::number (m_lastFilterID + 1);
820 m_config->deleteGroup (QLatin1String (
"Filter_") + filterID, 0);
824 QString desktopEntryName = FilterNameToDesktopEntryName (filterPlugInName);
826 if (desktopEntryName.isEmpty())
return;
829 m_loadedFilterPlugIn = loadFilterPlugin (desktopEntryName);
830 if (!m_loadedFilterPlugIn)
return;
833 m_loadedFilterPlugIn->
load (m_config, QLatin1String (
"Filter_") + filterID);
839 if (!m_loadedFilterPlugIn) {
849 if (!userFilterName.isEmpty()) {
851 m_loadedFilterPlugIn->
save (m_config, QLatin1String (
"Filter_" ) + filterID);
854 m_lastFilterID = filterID.toInt();
860 KConfigGroup filterConfig (m_config, QLatin1String (
"Filter_" ) + filterID);
861 filterConfig.writeEntry (
"DesktopEntryName", desktopEntryName);
862 filterConfig.writeEntry (
"UserFilterName", userFilterName);
863 filterConfig.writeEntry (
"MultiInstance", multiInstance);
864 filterConfig.writeEntry (
"Enabled",
true);
878 QModelIndex modelIndex = model->
index (model->
rowCount() - 1, 0, QModelIndex());
879 lView->scrollTo (modelIndex);
882 lView->setCurrentIndex (modelIndex);
883 updateFilterButtons();
890 delete m_loadedFilterPlugIn;
891 m_loadedFilterPlugIn = 0;
901 void KCMKttsMgr::slotRemoveTalkerButton_clicked()
906 QModelIndex modelIndex = talkersView->currentIndex();
907 if (!modelIndex.isValid())
return;
910 QString talkerID = m_talkerListModel.
getRow (modelIndex.row()).name();
911 m_config->deleteGroup (QLatin1String (
"Talker_") + talkerID, 0);
914 m_talkerListModel.
removeRow (modelIndex.row());
916 updateTalkerButtons();
922 void KCMKttsMgr::slotRemoveFilterButton_clicked()
930 void KCMKttsMgr::removeFilter()
935 QTreeView* lView = filtersView;
937 QModelIndex modelIndex = lView->currentIndex();
938 if (!modelIndex.isValid())
return;
939 QString filterID = model->
getRow (modelIndex.row()).
id;
942 updateFilterButtons();
945 kDebug() <<
"KCMKttsMgr::removeFilter: removing FilterID = " << filterID <<
" from config file.";
946 m_config->deleteGroup (QLatin1String (
"Filter_") + filterID, 0);
952 void KCMKttsMgr::slotHigherTalkerPriorityButton_clicked()
954 QModelIndex modelIndex = talkersView->currentIndex();
955 if (!modelIndex.isValid())
return;
956 m_talkerListModel.
swap (modelIndex.row(), modelIndex.row() - 1);
957 modelIndex = m_talkerListModel.
index (modelIndex.row() - 1, 0, QModelIndex());
958 talkersView->scrollTo (modelIndex);
959 talkersView->setCurrentIndex (modelIndex);
960 updateTalkerButtons();
964 void KCMKttsMgr::slotHigherFilterPriorityButton_clicked()
966 QModelIndex modelIndex = filtersView->currentIndex();
967 if (!modelIndex.isValid())
return;
968 m_filterListModel.
swap (modelIndex.row(), modelIndex.row() - 1);
969 modelIndex = m_filterListModel.
index (modelIndex.row() - 1, 0, QModelIndex());
970 filtersView->scrollTo (modelIndex);
971 filtersView->setCurrentIndex (modelIndex);
972 updateFilterButtons();
976 void KCMKttsMgr::slotLowerTalkerPriorityButton_clicked()
978 QModelIndex modelIndex = talkersView->currentIndex();
979 if (!modelIndex.isValid())
return;
980 m_talkerListModel.
swap (modelIndex.row(), modelIndex.row() + 1);
981 modelIndex = m_talkerListModel.
index (modelIndex.row() + 1, 0, QModelIndex());
982 talkersView->scrollTo (modelIndex);
983 talkersView->setCurrentIndex (modelIndex);
984 updateTalkerButtons();
988 void KCMKttsMgr::slotLowerFilterPriorityButton_clicked()
990 QModelIndex modelIndex = filtersView->currentIndex();
991 if (!modelIndex.isValid())
return;
992 m_filterListModel.
swap (modelIndex.row(), modelIndex.row() + 1);
993 modelIndex = m_filterListModel.
index (modelIndex.row() + 1, 0, QModelIndex());
994 filtersView->scrollTo (modelIndex);
995 filtersView->setCurrentIndex (modelIndex);
996 updateFilterButtons();
1003 void KCMKttsMgr::updateTalkerButtons()
1006 QModelIndex modelIndex = talkersView->currentIndex();
1007 if (modelIndex.isValid()) {
1008 removeTalkerButton->setEnabled (
true);
1009 configureTalkerButton->setEnabled (
true);
1010 higherTalkerPriorityButton->setEnabled (modelIndex.row() != 0);
1011 lowerTalkerPriorityButton->setEnabled (modelIndex.row() < (m_talkerListModel.
rowCount() - 1));
1013 removeTalkerButton->setEnabled (
false);
1014 configureTalkerButton->setEnabled (
false);
1015 higherTalkerPriorityButton->setEnabled (
false);
1016 lowerTalkerPriorityButton->setEnabled (
false);
1024 void KCMKttsMgr::updateFilterButtons()
1027 QModelIndex modelIndex = filtersView->currentIndex();
1028 if (modelIndex.isValid()) {
1029 removeFilterButton->setEnabled (
true);
1030 configureFilterButton->setEnabled (
true);
1031 higherFilterPriorityButton->setEnabled (modelIndex.row() != 0);
1032 lowerFilterPriorityButton->setEnabled (modelIndex.row() < (m_filterListModel.
rowCount() - 1));
1034 removeFilterButton->setEnabled (
false);
1035 configureFilterButton->setEnabled (
false);
1036 higherFilterPriorityButton->setEnabled (
false);
1037 lowerFilterPriorityButton->setEnabled (
false);
1045 void KCMKttsMgr::slotEnableJovie_toggled (
bool)
1048 static bool reenter;
1049 if (reenter)
return;
1052 bool kttsdRunning = (QDBusConnection::sessionBus().interface()->isServiceRegistered (QLatin1String(
"org.kde.jovie" )));
1056 if (enableJovieCheckBox->isChecked()) {
1057 if (!kttsdRunning) {
1060 if (KToolInvocation::startServiceByDesktopName (QLatin1String(
"jovie" ), QStringList(), &error)) {
1061 kDebug() <<
"Starting Jovie failed with message " << error;
1062 enableJovieCheckBox->setChecked (
false);
1075 m_kspeech =
new OrgKdeKSpeechInterface (QLatin1String(
"org.kde.jovie" ), QLatin1String(
"/KSpeech" ), QDBusConnection::sessionBus());
1076 m_kspeech->kttsdExit();
1091 bool kttsdLoaded = (m_jobMgrWidget != 0);
1095 if (m_jobMgrWidget) {
1098 mainTab->addTab (m_jobMgrWidget, i18n (
"Jobs"));
1101 kDebug() <<
"KCMKttsMgr::jovieStarted: Could not create kttsjobmgr part.";
1105 enableJovieCheckBox->setChecked (
true);
1106 m_kspeech =
new OrgKdeKSpeechInterface (QLatin1String(
"org.kde.jovie" ), QLatin1String(
"/KSpeech" ), QDBusConnection::sessionBus());
1107 m_kspeech->setParent (
this);
1108 m_kspeech->setApplicationName (QLatin1String(
"KCMKttsMgr" ));
1109 m_kspeech->setIsSystemManager (
true);
1115 connect (QDBusConnection::sessionBus().interface(), SIGNAL (serviceUnregistered(QString)),
1117 connect (QDBusConnection::sessionBus().interface(), SIGNAL (serviceOwnerChanged(QString,QString,QString)),
1120 kttsdVersion->setText (i18n (
"Jovie Version: %1", m_kspeech->version()));
1123 enableJovieCheckBox->setChecked (
false);
1131 if (service == QLatin1String (
"org.kde.jovie")) {
1139 if (service == QLatin1String (
"org.kde.jovie") && newOwner.isEmpty()) {
1150 if (m_jobMgrWidget) {
1151 mainTab->removeTab (wpJobs);
1152 delete m_jobMgrWidget;
1156 enableJovieCheckBox->setChecked (
false);
1157 disconnect (QDBusConnection::sessionBus().interface(), 0,
this, 0);
1160 kttsdVersion->setText (i18n (
"Jovie not running"));
1166 void KCMKttsMgr::slotConfigureTalkerButton_clicked()
1169 QModelIndex modelIndex = talkersView->currentIndex();
1171 if (!modelIndex.isValid())
1176 QPointer<AddTalker> dlg =
new AddTalker (
this);
1177 dlg->setTalkerCode(tc);
1178 if (dlg->exec() == QDialog::Accepted) {
1182 m_talkerListModel.
updateRow(modelIndex.row(), code);
1188 void KCMKttsMgr::slotConfigureFilterButton_clicked()
1190 configureFilterItem();
1196 void KCMKttsMgr::configureFilterItem()
1201 lView = filtersView;
1202 model = &m_filterListModel;
1203 QModelIndex modelIndex = lView->currentIndex();
1204 if (!modelIndex.isValid())
return;
1206 QString filterID = fi.
id;
1209 if (desktopEntryName.isEmpty())
return;
1210 m_loadedFilterPlugIn = loadFilterPlugin (desktopEntryName);
1211 if (!m_loadedFilterPlugIn)
return;
1216 m_loadedFilterPlugIn->
load (m_config, QLatin1String (
"Filter_") + filterID);
1222 if (!m_loadedFilterPlugIn) {
1232 if (!userFilterName.isEmpty()) {
1234 m_loadedFilterPlugIn->
save (m_config, QLatin1String (
"Filter_") + filterID);
1237 KConfigGroup filterConfig (m_config, QLatin1String (
"Filter_") + filterID);
1238 filterConfig.writeEntry (
"DesktopEntryName", desktopEntryName);
1239 filterConfig.writeEntry (
"UserFilterName", userFilterName);
1240 filterConfig.writeEntry (
"Enabled",
true);
1252 model->
updateRow (modelIndex.row(), fi);
1265 void KCMKttsMgr::configureFilter()
1267 if (!m_loadedFilterPlugIn)
return;
1268 m_configDlg =
new KDialog (
this);
1269 m_configDlg->setCaption (i18n (
"Filter Configuration"));
1270 m_configDlg->setButtons (KDialog::Help | KDialog::Default | KDialog::Ok | KDialog::Cancel);
1271 m_configDlg->setDefaultButton (KDialog::Cancel);
1272 m_loadedFilterPlugIn->setMinimumSize (m_loadedFilterPlugIn->minimumSizeHint());
1273 m_loadedFilterPlugIn->show();
1274 m_configDlg->setMainWidget (m_loadedFilterPlugIn);
1275 m_configDlg->setHelp (QLatin1String(
"configure-filter" ), QLatin1String(
"jovie" ));
1276 m_configDlg->enableButtonOk (
false);
1277 connect (m_loadedFilterPlugIn, SIGNAL (changed(
bool)),
this, SLOT (slotConfigFilterDlg_ConfigChanged()));
1278 connect (m_configDlg, SIGNAL (defaultClicked()),
this, SLOT (slotConfigFilterDlg_DefaultClicked()));
1279 connect (m_configDlg, SIGNAL (cancelClicked()),
this, SLOT (slotConfigFilterDlg_CancelClicked()));
1281 m_configDlg->exec();
1287 int KCMKttsMgr::countFilterPlugins (
const QString& filterPlugInName)
1290 for (
int i = 0; i < m_filterListModel.
rowCount(); ++i) {
1292 if (fi.
plugInName == filterPlugInName) ++cnt;
1297 void KCMKttsMgr::slotConfigTalkerDlg_ConfigChanged()
1302 void KCMKttsMgr::slotConfigFilterDlg_ConfigChanged()
1304 m_configDlg->enableButtonOk (!m_loadedFilterPlugIn->
userPlugInName().isEmpty());
1307 void KCMKttsMgr::slotConfigTalkerDlg_DefaultClicked()
1312 void KCMKttsMgr::slotConfigFilterDlg_DefaultClicked()
1317 void KCMKttsMgr::slotConfigTalkerDlg_CancelClicked()
1323 void KCMKttsMgr::slotConfigFilterDlg_CancelClicked()
1325 delete m_loadedFilterPlugIn;
1326 m_loadedFilterPlugIn = 0;
1335 QString KCMKttsMgr::FilterNameToDesktopEntryName (
const QString& name)
1337 if (name.isEmpty())
return QString();
1338 const KService::List offers = KServiceTypeTrader::self()->query (QLatin1String(
"Jovie/FilterPlugin" ));
1339 for (
int ndx = 0; ndx < offers.count(); ++ndx)
1340 if (offers[ndx]->name() == name)
1341 return offers[ndx]->desktopEntryName();
1350 QString KCMKttsMgr::FilterDesktopEntryNameToName (
const QString& desktopEntryName)
1352 if (desktopEntryName.isEmpty())
return QString();
1353 KService::List offers = KServiceTypeTrader::self()->query (QLatin1String(
"Jovie/FilterPlugin" ),
1354 QString (QLatin1String(
"DesktopEntryName == '%1'" )).arg (desktopEntryName));
1356 if (offers.count() == 1)
1357 return offers[0]->name();
1363 void KCMKttsMgr::slotFilterListView_clicked (
const QModelIndex & index)
1365 if (!index.isValid())
return;
1366 if (index.column() != 0)
return;
1367 if (index.row() < 0 || index.row() >= m_filterListModel.
rowCount())
return;
1370 m_filterListModel.
updateRow (index.row(), fi);
void kttsdExiting()
This signal is emitted just before KTTS exits.
const bool autoexitMgrCheckBoxValue
void jovieStarted()
DCOP Methods connected to D-Bus Signals emitted by KTTSD.
bool updateRow(int row, TalkerCode &talker)
Updates a row of the model/view with information from specified TalkerCode.
QList< KttsFilterProc * > FilterList
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
void jovieExiting()
This slot is called just before Jovie exits.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
bool swap(int i, int j)
Swaps two rows of the model/view.
QVariant data(const QModelIndex &index, int role) const
QModelIndex parent(const QModelIndex &index) const
void save()
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.
int rowCount(const QModelIndex &parent=QModelIndex()) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
QString quickHelp() const
This function returns the small quickhelp.
virtual void defaults()
This function is called to set the settings in the module to sensible default values.
KCMKttsMgr(QWidget *parent, const QVariantList &)
Constructor.
QString name() const
Properties.
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
bool updateRow(int row, FilterItem &filter)
void slotServiceOwnerChanged(const QString &, const QString &, const QString &)
QString getTalkerCode() const
const KAboutData * aboutData() const
Return the about information for this module.
static void init()
This is a static method which gets called to realize the modules settings durign the startup of KDE...
bool appendRow(TalkerCode &talker)
Adds a new row to the model/view containing the specified TalkerCode.
void save()
apply current settings, i.e.
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
virtual QString userPlugInName()
Returns the name of the plugin.
bool appendRow(FilterItem &filter)
virtual void load(KConfig *config, const QString &configGroup)
This method is invoked whenever the module should read its configuration (most of the times from a co...
FilterItem getRow(int row) const
void defaults()
This function is called to set the settings in the module to sensible default values.
void load()
This method is invoked whenever the module should read its configuration (most of the times from a co...
virtual void save(KConfig *config, 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.
TalkerCode getRow(int row) const
Returns the TalkerCode for a specified row of the model/view.
void slotServiceUnregistered(const QString &)
virtual bool supportsMultiInstance()
Indicates whether the plugin supports multiple instances.
Qt::ItemFlags flags(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
void loadTalkerCodesFromConfig(KConfig *config)
Loads the TalkerCodes into the model/view from the config file.
void kttsdStarted()
This signal is emitted when KTTSD starts.
const bool autostartMgrCheckBoxValue
void configChanged()
This slot is used to emit the signal changed when any widget changes the configuration.