// Read the command set from settings. bool QsciCommandSet::readSettings(QSettings &qs, const char *prefix) { bool rc = true; QString skey; for (int i = 0; i < cmds.count(); ++i) { QsciCommand *cmd = cmds.at(i); skey.sprintf("%s/keymap/c%d/", prefix, cmd->msgId()); int key; bool ok; // Read the key. key = qs.readNumEntry(skey + "key", 0, &ok); if (ok) cmd->setKey(key); else rc = false; // Read the alternate key. key = qs.readNumEntry(skey + "alt", 0, &ok); if (ok) cmd->setAlternateKey(key); else rc = false; } return rc; }
// Write the command set to settings. bool QsciCommandSet::writeSettings(QSettings &qs, const char *prefix) { bool rc = true; QString skey; for (int i = 0; i < cmds.count(); ++i) { QsciCommand *cmd = cmds.at(i); skey.sprintf("%s/keymap/c%d/", prefix, cmd->msgId()); // Write the key. if (!qs.writeEntry(skey + "key", cmd->key())) rc = false; // Write the alternate key. if (!qs.writeEntry(skey + "alt", cmd->alternateKey())) rc = false; } return rc; }