unsigned int delShortcut(void* ocl_ptr) { unsigned int i,id=0; // Look if the pointer don't exist if(!getShortcut(ocl_ptr)){ return num_shortcuts; } if(num_shortcuts == 1){ num_shortcuts = 0; if(shortcuts) free(shortcuts); shortcuts=NULL; return 0; } shortcut *backup = shortcuts; shortcuts = (shortcut*)malloc( (num_shortcuts - 1) * sizeof(shortcut)); if(!shortcuts){ if(backup) free(backup); backup=NULL; num_shortcuts = 0; return 0; } // Store queues not affected for(i=0;i<num_shortcuts;i++){ if(ocl_ptr == backup[i].ocl_ptr){ continue; } shortcuts[id] = backup[i]; id++; } num_shortcuts--; if(backup) free(backup); backup=NULL; return num_shortcuts; }
unsigned int addShortcut(void* ocl_ptr, int* socket) { // Look if the shortcut already exist if(getShortcut(ocl_ptr)){ return num_shortcuts; } if(!shortcuts){ shortcuts = (shortcut*)malloc( (num_shortcuts + 1) * sizeof(shortcut)); if(!shortcuts){ num_shortcuts = 0; return 0; } } else{ shortcuts = (shortcut*)realloc( shortcuts, (num_shortcuts + 1) * sizeof(shortcut)); if(!shortcuts){ num_shortcuts = 0; return 0; } } // Store new shortcut shortcuts[num_shortcuts].ocl_ptr = ocl_ptr; shortcuts[num_shortcuts].socket = socket; num_shortcuts++; return num_shortcuts; }
void Shortcut::resetToDefault() { QList<Shortcut1*> sl = loadDefaultShortcuts(); foreach(Shortcut1* sc, sl) { Shortcut* s = getShortcut(sc->key); if (s) { s->setKeys(sc->keys); s->setStandardKey(sc->standardKey); } }
void ShortcutManager::saveSettings() { shortcutSettings->beginGroup("LocalShortcuts"); shortcutSettings->setValue(KEY_SHORTCUT_NEW, getShortcut(Config::shortcutNew)); shortcutSettings->setValue(KEY_SHORTCUT_SAVE, getShortcut(Config::shortcutSave)); shortcutSettings->setValue(KEY_SHORTCUT_COPY, getShortcut(Config::shortcutCopy)); shortcutSettings->setValue(KEY_SHORTCUT_OPT, getShortcut(Config::shortcutOptions)); shortcutSettings->setValue(KEY_SHORTCUT_HELP, getShortcut(Config::shortcutHelp)); shortcutSettings->setValue(KEY_SHORTCUT_CLOSE, getShortcut(Config::shortcutClose)); shortcutSettings->endGroup(); shortcutSettings->beginGroup("GlobalShortcuts"); shortcutSettings->setValue(KEY_SHORTCUT_FULL, getShortcut(Config::shortcutFullScreen)); shortcutSettings->setValue(KEY_SHORTCUT_ACTW, getShortcut(Config::shortcutActiveWnd)); shortcutSettings->setValue(KEY_SHORTCUT_AREA, getShortcut(Config::shortcutAreaSelect)); shortcutSettings->endGroup(); }
void Shortcut::load() { QFile f(dataPath + "/shortcuts.xml"); if (!f.exists()) f.setFileName(":/data/shortcuts.xml"); if (!f.open(QIODevice::ReadOnly)) { qDebug("Cannot open shortcuts <%s>", qPrintable(f.fileName())); return; } if (MScore::debugMode) qDebug("read shortcuts from <%s>", qPrintable(f.fileName())); XmlReader e(&f); while (e.readNextStartElement()) { if (e.name() == "Shortcuts") { while (e.readNextStartElement()) { if (e.name() == "SC") { Shortcut* sc = 0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "key") { QString val(e.readElementText()); sc = getShortcut(val.toLatin1().data()); if (!sc) qDebug("cannot find shortcut <%s>", qPrintable(val)); else sc->clear(); } else if (tag == "std") { int i = e.readInt(); if(sc) sc->_standardKey = QKeySequence::StandardKey(i); } else if (tag == "seq") { QString s = e.readElementText(); if(sc) sc->_keys.append(Shortcut::keySeqFromString(s, QKeySequence::PortableText)); // sc->_keys.append(QKeySequence::fromString(e.readElementText(), QKeySequence::PortableText)); } else e.unknown(); } } else e.unknown(); } } else e.unknown(); } dirty = false; }
void Shortcut::load() { QFile f(dataPath + "/shortcuts.xml"); if (!f.exists()) f.setFileName(":/data/shortcuts.xml"); if (!f.open(QIODevice::ReadOnly)) { printf("cannot open shortcuts\n"); return; } QDomDocument doc; int line, column; QString err; if (!doc.setContent(&f, false, &err, &line, &column)) { printf("error reading shortcuts.xml at line %d column %d: %s\n", line, column, qPrintable(err)); return; } f.close(); QString key; for (QDomElement e = doc.documentElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.tagName() == "Shortcuts") { for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) { if (ee.tagName() == "SC") { Shortcut* sc = 0; for (QDomElement eee = ee.firstChildElement(); !eee.isNull(); eee = eee.nextSiblingElement()) { const QString& tag(eee.tagName()); const QString& val(eee.text()); if (tag == "key") { sc = getShortcut(val.toAscii().data()); if (!sc) { printf("cannot find shortcut <%s>\n", qPrintable(val)); break; } sc->clear(); } else if (tag == "std") sc->_standardKey = QKeySequence::StandardKey(val.toInt()); else if (tag == "seq") sc->_keys.append(QKeySequence::fromString(val, QKeySequence::PortableText)); else domError(eee); } } else domError(ee); } } else domError(e); } dirty = false; }
void StelScriptMgr::initActions() { StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager(); QSignalMapper* mapper = new QSignalMapper(this); foreach(const QString script, getScriptList()) { QString shortcut = getShortcut(script); QString actionId = "actionScript/" + script; StelAction* action = actionMgr->addAction( actionId, N_("Scripts"), q_(getName(script).trimmed()), mapper, "map()", shortcut); mapper->setMapping(action, script); }
static void populateIconPalette(Palette* p, const IconAction* a) { while (a->subtype != -1) { Icon* ik = new Icon(gscore); ik->setSubtype(a->subtype); Shortcut* s = getShortcut(a->action); QAction* action = getAction(s); QIcon icon(action->icon()); ik->setAction(a->action, icon); p->append(ik, s->help); ++a; } }
void Shortcut::load() { QFile f(dataPath + "/shortcuts.xml"); if (!f.exists()) f.setFileName(":/data/shortcuts.xml"); if (!f.open(QIODevice::ReadOnly)) { printf("cannot open shortcuts\n"); return; } XmlReader e(&f); QString key; while (e.readNextStartElement()) { if (e.name() == "Shortcuts") { while (e.readNextStartElement()) { if (e.name() == "SC") { Shortcut* sc = 0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "key") { QString val(e.readElementText()); sc = getShortcut(val.toLatin1().data()); if (!sc) { printf("cannot find shortcut <%s>\n", qPrintable(val)); break; } sc->clear(); } else if (tag == "std") sc->_standardKey = QKeySequence::StandardKey(e.readInt()); else if (tag == "seq") sc->_keys.append(QKeySequence::fromString(e.readElementText(), QKeySequence::PortableText)); else if (tag == "code") sc->_keys.append(QKeySequence(e.readInt())); else e.unknown(); } } else e.unknown(); } } else e.unknown(); } dirty = false; }
QKeySequence ShortcutsSettings::getSingleShortcut(QString name) { return getShortcut(name).at(0); }
QAction* getAction(const char* id) { Shortcut* s = getShortcut(id); return getAction(s); }