// 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,
                static_cast<int>(cmd->command()));

        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;
}
Example #2
0
// Find a command.
QsciCommand *QsciCommandSet::find(QsciCommand::Command command) const
{
    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        if (cmd->command() == command)
            return cmd;
    }

    // This should never happen.
    return 0;
}
Example #3
0
// 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,
                static_cast<int>(cmd->command()));

        // Write the key.
        qs.setValue(skey + "key", cmd->key());

        // Write the alternate key.
        qs.setValue(skey + "alt", cmd->key());
    }

    return rc;
}