コード例 #1
0
ファイル: chatcontainer.cpp プロジェクト: wordlet/mykonvi
        void ChatContainer::textEntered()
        {
            const QString &line = sterilizeUnicode(m_inputBar->toPlainText());

            if (line.isEmpty())
            {
                return;
            }

            const QString &cc = Preferences::self()->commandChar();
            if (line.startsWith(cc))
            {
                QString cmd = line.section(' ', 0, 0).toLower();
                kDebug() << "cmd" << cmd;
                if (cmd == cc + "clear")
                {
                    textView->clear();
                }
                else if (cmd == cc + "me")
                {
                    QString toSend = line.section(' ', 1);
                    //kDebug() << "toSend" << toSend;
                    if (toSend.isEmpty())
                    {
                        getTextView()->appendServerMessage(i18n("Usage"), i18n("Usage: %1ME text", Preferences::self()->commandChar()));
                    }
                    else
                    {
                        m_chat->sendAction(toSend);
                        appendAction(m_chat->ownNick(), toSend);
                    }
                }
                else if (cmd == cc + "close")
                {
                    closeYourself(false);
                }
                else
                {
                    getTextView()->appendServerMessage(i18n("Error"), i18n("Unknown command."));
                }
            }
            else
            {
                textPasted(line);
            }
            m_inputBar->clear();
        }
コード例 #2
0
 void setMethodBodyByAssignment(std::function<R(const typename fakeit::test_arg<arglist>::type...)> method) {
     appendAction(new RepeatForever<R, arglist...>(method));
     commit();
 }
コード例 #3
0
ファイル: actioncollection.cpp プロジェクト: KDE/simon
bool ActionCollection::deSerialize(const QDomElement& actionCollectionElem)
{
  if (actionCollectionElem.isNull())
    return false;

  qDeleteAll(listInterfaceCommands);
  listInterfaceCommands.clear();

  QDomElement listsElement = actionCollectionElem.firstChildElement("lists");

  if (listsElement.isNull()) {
    QHash<CommandListElements::Element, VoiceInterfaceCommand*> baseConfig = ScenarioManager::getInstance()->
      getListBaseConfiguration();

    QHashIterator<CommandListElements::Element, VoiceInterfaceCommand*> i(baseConfig);
    while (i.hasNext()) {
      i.next();
      // i.value() is not a valid command
      listInterfaceCommands.insertMulti(i.key(), new VoiceInterfaceCommand(*(i.value())));
    }
  }
  else {
    QDomElement commandElem = listsElement.firstChildElement();

    while (!commandElem.isNull()) {
      VoiceInterfaceCommand *com = VoiceInterfaceCommand::createInstance(commandElem);

      int elementId = commandElem.attribute("element").toInt();

      commandElem = commandElem.nextSiblingElement("voiceInterfaceCommand");

      if (!com) continue;

      listInterfaceCommands.insert((CommandListElements::Element) elementId, com);
    }
  }

  QDomElement autorunElem = actionCollectionElem.firstChildElement("autorun");
  m_autorunActive = autorunElem.attribute("active") == "1";
  m_autorunCommand = autorunElem.firstChildElement("trigger").text();
  m_autorunType = autorunElem.firstChildElement("category").text();

  //clean member
  qDeleteAll(m_actions);
  m_actions.clear();

  QDomElement pluginElem = actionCollectionElem.firstChildElement("plugin");
  while (!pluginElem.isNull()) {
    Action *a = Action::createAction(parentScenario, pluginElem, this);
    if (!a) {
      kDebug() << "Could not load action";
    }
    else {
      //m_actions << a;
      appendAction(a, true /*silent*/);
    }

    pluginElem = pluginElem.nextSiblingElement("plugin");
  }
  proxy->update();
  reset();

  if (m_autorunActive)
  {
    bool succ = triggerCommand(m_autorunType, m_autorunCommand, true /* silent */);
    kDebug() << "Executed autorun command; Success: " << succ;
  }

  return true;
}