void TToolbarEditor::setActiveActions(const QStringList& actions) { active_actions_table->clearContents(); QString action_name; bool ns, fs; int row = 0; for(int i = 0; i < actions.count(); i++) { stringToAction(actions[i], action_name, ns, fs); if (action_name == "separator") { insertSeparator(row, ns, fs); row++; } else { QAction* action = findAction(action_name, *all_actions); if (action) { insertRowFromAction(row, action, ns, fs); row++; } } } if (active_actions_table->rowCount() > 0) { active_actions_table->setCurrentCell(0, COL_DESC); } }
void KeyMap::load() { std::ifstream file(KEYS_FILENAME); std::string line; unsigned int linenum = 0; //Parse all lines while(std::getline(file, line)) { linenum++; if(line.empty()) continue; if(line[0] == '#') continue; //Is it a key or a scancode if(line.substr(0, 4) == "key ") { std::istringstream strm(line.substr(4)); std::string keyname; std::string actionname; //Get action name if(!(strm >> actionname)) { std::cerr << "Wrong line format in file " << KEYS_FILENAME << " at line " << linenum << "." << std::endl; continue; } strm.get();//Skip the space //Get key name if(!extractEnd(strm, keyname)) { std::cerr << "Wrong line format in file " << KEYS_FILENAME << " at line " << linenum << "." << std::endl; continue; } //Convert the names to a key/action pair sf::Keyboard::Key key = internalStringToKey(keyname); if(key == sf::Keyboard::Unknown) { std::cerr << "Error in file " << KEYS_FILENAME << " at line " << linenum << " : unknown key name." << std::endl; continue; } KeyAction action = stringToAction(actionname); if(action == KeyAction::None) { std::cerr << "Error in file " << KEYS_FILENAME << " at line " << linenum << " : unknown action name." << std::endl; continue; } //Put it it the keymap m_keymap[key] = action; } else if(line.substr(0, 5) == "scan ")
bool SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field, ExprDef *array_ndx, ExprDef *value, ActionsInfo *info) { unsigned action; enum action_field action_field; if (!stringToAction(elem, &action)) return false; if (!stringToField(field, &action_field)) { log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field); return false; } return handleAction[action](keymap, &info->actions[action], action_field, array_ndx, value); }
bool SetActionField(struct xkb_context *ctx, ActionsInfo *info, struct xkb_mod_set *mods, const char *elem, const char *field, ExprDef *array_ndx, ExprDef *value) { enum xkb_action_type action; enum action_field action_field; if (!stringToAction(elem, &action)) return false; if (!stringToField(field, &action_field)) { log_err(ctx, "\"%s\" is not a legal field name\n", field); return false; } return handleAction[action](ctx, mods, &info->actions[action], action_field, array_ndx, value); }
void JingleParser::handleStartElement(const std::string& element, const std::string &ns, const AttributeMap& attributes) { if (level == 0) { // <jingle > tag JinglePayload::ref payload = getPayloadInternal(); payload->setAction(stringToAction(attributes.getAttributeValue("action").get_value_or(""))); payload->setInitiator(JID(attributes.getAttributeValue("initiator").get_value_or(""))); payload->setResponder(JID(attributes.getAttributeValue("responder").get_value_or(""))); payload->setSessionID(attributes.getAttributeValue("sid").get_value_or("")); } if (level == 1) { PayloadParserFactory* payloadParserFactory = factories->getPayloadParserFactory(element, ns, attributes); if (payloadParserFactory) { currentPayloadParser.reset(payloadParserFactory->createPayloadParser()); } } if (level >= 1 && currentPayloadParser) { currentPayloadParser->handleStartElement(element, ns, attributes); } ++level; }
bool HandleActionDef(ExprDef *def, struct xkb_keymap *keymap, union xkb_action *action, ActionsInfo *info) { ExprDef *arg; const char *str; unsigned handler_type; if (def->expr.op != EXPR_ACTION_DECL) { log_err(keymap->ctx, "Expected an action definition, found %s\n", expr_op_type_to_string(def->expr.op)); return false; } str = xkb_atom_text(keymap->ctx, def->action.name); if (!stringToAction(str, &handler_type)) { log_err(keymap->ctx, "Unknown action %s\n", str); return false; } /* * Get the default values for this action type, as modified by * statements such as: * latchMods.clearLocks = True; */ *action = info->actions[handler_type]; /* * Now change the action properties as specified for this * particular instance, e.g. "modifiers" and "clearLocks" in: * SetMods(modifiers=Alt,clearLocks); */ for (arg = def->action.args; arg != NULL; arg = (ExprDef *) arg->common.next) { const ExprDef *value; ExprDef *field, *arrayRtrn; const char *elemRtrn, *fieldRtrn; enum action_field fieldNdx; if (arg->expr.op == EXPR_ASSIGN) { field = arg->binary.left; value = arg->binary.right; } else if (arg->expr.op == EXPR_NOT || arg->expr.op == EXPR_INVERT) { field = arg->unary.child; value = (const ExprDef *) &constFalse; } else { field = arg; value = (const ExprDef *) &constTrue; } if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn, &arrayRtrn)) return false; if (elemRtrn) { log_err(keymap->ctx, "Cannot change defaults in an action definition; " "Ignoring attempt to change %s.%s\n", elemRtrn, fieldRtrn); return false; } if (!stringToField(fieldRtrn, &fieldNdx)) { log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn); return false; } if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn, value)) return false; } return true; }