void TalkerChooserConf::slotClearButton_clicked() { m_widget->nameLineEdit->setText( QString::null ); m_widget->reLineEdit->setText( QString::null ); m_widget->appIdLineEdit->setText( QString::null ); m_talkerCode = TalkerCode( QString::null, false ); m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() ); configChanged(); }
void TalkerChooserConf::slotTalkerButton_clicked() { QString talkerCode = m_talkerCode.getTalkerCode(); SelectTalkerDlg dlg( m_widget, "selecttalkerdialog", i18n("Select Talker"), talkerCode, true ); int dlgResult = dlg.exec(); if ( dlgResult != KDialogBase::Accepted ) return; m_talkerCode = TalkerCode( dlg.getSelectedTalkerCode(), false ); m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() ); configChanged(); }
/** * This function is called to set the settings in the module to sensible * default values. It gets called when hitting the "Default" button. The * default values should probably be the same as the ones the application * uses when started without a config file. Note that defaults should * be applied to the on-screen widgets; not to the config file. */ void TalkerChooserConf::defaults(){ // kdDebug() << "TalkerChooserConf::defaults: Running" << endl; // Default name. m_widget->nameLineEdit->setText( i18n("Talker Chooser") ); // Default regular expression is blank. m_widget->reLineEdit->setText( "" ); // Default App ID is blank. m_widget->appIdLineEdit->setText( "" ); // Default to using default Talker. m_talkerCode = TalkerCode( QString::null, false ); m_widget->talkerLineEdit->setText( m_talkerCode.getTranslatedDescription() ); }
/** * Initialize the filter. * @param config Settings object. * @param configGroup Settings Group. * @return False if filter is not ready to filter. * * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain * separate configuration files of their own. */ bool TalkerChooserProc::init(KConfig* config, const QString& configGroup){ // kdDebug() << "PlugInProc::init: Running" << endl; config->setGroup( configGroup ); m_re = config->readEntry( "MatchRegExp" ); m_appIdList = config->readListEntry( "AppIDs" ); m_chosenTalkerCode = TalkerCode(config->readEntry("TalkerCode"), false); // Legacy settings. QString s = config->readEntry( "LanguageCode" ); if (!s.isEmpty()) m_chosenTalkerCode.setFullLanguageCode(s); s = config->readEntry( "SynthInName" ); if (!s.isEmpty()) m_chosenTalkerCode.setPlugInName(s); s = config->readEntry( "Gender" ); if (!s.isEmpty()) m_chosenTalkerCode.setGender(s); s = config->readEntry( "Volume" ); if (!s.isEmpty()) m_chosenTalkerCode.setVolume(s); s = config->readEntry( "Rate" ); if (!s.isEmpty()) m_chosenTalkerCode.setRate(s); return true; }
/** * This method is invoked whenever the module should read its * configuration (most of the times from a config file) and update the * user interface. This happens when the user clicks the "Reset" button in * the control center, to undo all of his changes and restore the currently * valid settings. Note that kttsmgr calls this when the plugin is * loaded, so it not necessary to call it in your constructor. * The plugin should read its configuration from the specified group * in the specified config file. * @param config Pointer to a KConfig object. * @param configGroup Call config->setGroup with this argument before * loading your configuration. */ void TalkerChooserConf::load(KConfig* config, const QString& configGroup){ // kdDebug() << "TalkerChooserConf::load: Running" << endl; config->setGroup( configGroup ); m_widget->nameLineEdit->setText( config->readEntry( "UserFilterName", m_widget->nameLineEdit->text() ) ); m_widget->reLineEdit->setText( config->readEntry("MatchRegExp", m_widget->reLineEdit->text()) ); m_widget->appIdLineEdit->setText( config->readEntry("AppIDs", m_widget->appIdLineEdit->text()) ); m_talkerCode = TalkerCode(config->readEntry("TalkerCode"), false); // Legacy settings. QString s = config->readEntry( "LanguageCode" ); if (!s.isEmpty()) m_talkerCode.setFullLanguageCode(s); s = config->readEntry( "SynthInName" ); if (!s.isEmpty()) m_talkerCode.setPlugInName(s); s = config->readEntry( "Gender" ); if (!s.isEmpty()) m_talkerCode.setGender(s); s = config->readEntry( "Volume" ); if (!s.isEmpty()) m_talkerCode.setVolume(s); s = config->readEntry( "Rate" ); if (!s.isEmpty()) m_talkerCode.setRate(s); m_widget->talkerLineEdit->setText(m_talkerCode.getTranslatedDescription()); }
/** * Loads notify events from a file. Clearing data if clear is True. */ void SpeechData::loadNotifyEventsFromFile( const QString& filename, bool clear) { // Open existing event list. QFile file( filename ); if ( !file.open( IO_ReadOnly ) ) { kdDebug() << "SpeechData::loadNotifyEventsFromFile: Unable to open file " << filename << endl; } // QDomDocument doc( "http://www.kde.org/share/apps/kttsd/stringreplacer/wordlist.dtd []" ); QDomDocument doc( "" ); if ( !doc.setContent( &file ) ) { file.close(); kdDebug() << "SpeechData::loadNotifyEventsFromFile: File not in proper XML format. " << filename << endl; } // kdDebug() << "StringReplacerConf::load: document successfully parsed." << endl; file.close(); if ( clear ) { notifyDefaultPresent = NotifyPresent::Passive; notifyDefaultOptions.action = NotifyAction::SpeakMsg; notifyDefaultOptions.talker = QString::null; notifyDefaultOptions.customMsg = QString::null; notifyAppMap.clear(); } // Event list. QDomNodeList eventList = doc.elementsByTagName("notifyEvent"); const int eventListCount = eventList.count(); for (int eventIndex = 0; eventIndex < eventListCount; ++eventIndex) { QDomNode eventNode = eventList.item(eventIndex); QDomNodeList propList = eventNode.childNodes(); QString eventSrc; QString event; QString actionName; QString message; TalkerCode talkerCode; const int propListCount = propList.count(); for (int propIndex = 0; propIndex < propListCount; ++propIndex) { QDomNode propNode = propList.item(propIndex); QDomElement prop = propNode.toElement(); if (prop.tagName() == "eventSrc") eventSrc = prop.text(); if (prop.tagName() == "event") event = prop.text(); if (prop.tagName() == "action") actionName = prop.text(); if (prop.tagName() == "message") message = prop.text(); if (prop.tagName() == "talker") talkerCode = TalkerCode(prop.text(), false); } NotifyOptions notifyOptions; notifyOptions.action = NotifyAction::action( actionName ); notifyOptions.talker = talkerCode.getTalkerCode(); notifyOptions.customMsg = message; if ( eventSrc != "default" ) { notifyOptions.eventName = NotifyEvent::getEventName( eventSrc, event ); NotifyEventMap notifyEventMap = notifyAppMap[ eventSrc ]; notifyEventMap[ event ] = notifyOptions; notifyAppMap[ eventSrc ] = notifyEventMap; } else { notifyOptions.eventName = QString::null; notifyDefaultPresent = NotifyPresent::present( event ); notifyDefaultOptions = notifyOptions; } } }