-rw-r--r-- | noncore/apps/keyz-cfg/cfgfile.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/apps/keyz-cfg/cfgfile.cpp b/noncore/apps/keyz-cfg/cfgfile.cpp index 81d1ee1..be7150e 100644 --- a/noncore/apps/keyz-cfg/cfgfile.cpp +++ b/noncore/apps/keyz-cfg/cfgfile.cpp @@ -121,48 +121,53 @@ bool CfgParser::load(QString file, CfgFile& cfg) { cfg.replaceEntry(file, label); } if (ardelay != -1) { cfg.setAutorepeatDelay(ardelay); } if (arperiod != -1) { cfg.setAutorepeatPeriod(arperiod); } return true; } bool CfgParser::save(QString file, CfgFile& cfg) { FILE* f = fopen((const char*) file.local8Bit(), "w"); + if (!f) { + oerr << "Could not write config file!" << oendl; + return false; + } fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" " "author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(), cfg.getAutorepeatPeriod()); QList<CfgEntry>& entries = cfg.getEntries(); int n; for(n=0; n < (int) entries.count(); n++) { CfgEntry* entry = entries.at(n); QString l = entry->getLabel(); - if (!l.isEmpty()) { + if (l.isEmpty()) { + l = entry->getFile(); + } fprintf(f, "\t<label name=\"%s\" state=\"km%d:*\"/>\n", (const char*) l.utf8(), n); } - } for(n=0; n < (int) entries.count(); n++) { CfgEntry* entry = entries.at(n); fprintf(f, "\t<include file=\"%s\" prefix=\"km%d\"/>\n", (const char*) entry->getFile().utf8(), n); } int k = n-1; char* states[] = { "LShift", "LShift-Caps", "LShift-Num", "LShift-Num-Caps", 0}; for(n=0; n < (int) entries.count(); n++) { QString nstate = "km" + QString::number(n+1); if (n == k) { nstate = "km" + QString::number(0); } |