示例#1
0
void Parser::sGesture() {
    if (m_reader.isEndElement() && m_reader.name() == "gesture") {
        state.removeLast();
        return;
    } else if (m_reader.isStartElement() && m_reader.name() == "action") {
        state.append("ACTION");
        auto attrs = m_reader.attributes();
        if (!attrs.hasAttribute("type"))
            throw(err("Attribute 'type' expected."));

        Group *g = Memory::getGroup(appKey);
        g->addGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        Gesture *gest = g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        gest->setAction(Lists::aT(attrs.value("type").toString()));
        //sAction(g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction))->getAction());->setAction(Lists::aT(attrs.value("type").toString()))
        QStringList params = m_reader.readElementText().split(":");
        foreach(const QString &p, params)
            gest->getAction()->addParam(p.section("=",0,0),p.section("=",1));

        state.removeLast();
    } else
示例#2
0
Gesture *GestureHandler::createGesture(const QString &type, int id, const QHash<QString, QVariant>& attrs,
    bool isComposedGesture) const
{
    // Creamos el gesto sin su acción
    Gesture *ret;
    if (isComposedGesture)
        ret = this->gestureFact->createComposedGesture(type, id, attrs);
    else
        ret = this->gestureFact->createSimpleGesture(type, id, attrs);

    if (ret == NULL)
        return NULL;

    // Vemos sobre que ventana se ha ejecutado
    Window gestureWindow = this->getGestureWindow(attrs.value(GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID).toInt());
    //if (gestureWindow == None)
    //    return NULL;
    QString appClass = this->getAppClass(gestureWindow);

    // Creamos y asignamos la acción asociada al gesto
    ActionTypeEnum::ActionType actionType = this->config->getAssociatedAction(appClass, ret->getType(),
            ret->getNumFingers(), ret->getDirection());
    QString actionSettings = this->config->getAssociatedSettings(appClass, ret->getType(), ret->getNumFingers(),
            ret->getDirection());
    QString timing = this->config->getAssociatedTiming(appClass, ret->getType(), ret->getNumFingers(),
            ret->getDirection());

    ret->setAction(this->actionFact->createAction(actionType, actionSettings, timing, gestureWindow));

    // Mostramos los datos sobre el gesto
    qDebug() << "[+] New gesture:";
    qDebug() << "\tType      -> " << GestureTypeEnum::getValue(ret->getType());
    qDebug() << "\tFingers   -> " << ret->getNumFingers();
    qDebug() << "\tDirection -> " << GestureDirectionEnum::getValue(ret->getDirection());
    qDebug() << "\tAction    -> " << ActionTypeEnum::getValue(actionType);
    qDebug() << "\tTiming    -> " << timing;
    qDebug() << "\tApp Class -> " << appClass;

    return ret;
}