Index: sources/storage/Settings.cpp =================================================================== diff -u -r2216ac6ac7f77437a7c29ac8b4043be01bc4609e -r56ad953ae404fcf6956bd4f76b7a54b12d0285d3 --- sources/storage/Settings.cpp (.../Settings.cpp) (revision 2216ac6ac7f77437a7c29ac8b4043be01bc4609e) +++ sources/storage/Settings.cpp (.../Settings.cpp) (revision 56ad953ae404fcf6956bd4f76b7a54b12d0285d3) @@ -63,42 +63,61 @@ return 2; // TODO : Define an error enum when completed } + QList details; for (const auto &settingFile: settingFiles) { if (! isValid(settingFile.absoluteFilePath())) continue; QFile file(settingFile.absoluteFilePath()); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString group = ""; - while ( ! file.atEnd() ) { - QString line = file.readLine().replace('\n',"").trimmed(); - if (line.contains("[")) { - line.replace("[","").replace("]", ""); - group = line; + Detail detail; + detail.content = file.readAll().trimmed(); + if (detail.content.isEmpty()) continue; + detail.location = settingFile.absolutePath() + "/"; + detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path_Name); + details += detail; + } + } + + for (const auto &detail : details) { + QString group = ""; + QStringList lines = detail.content.split('\n'); + for (QString line : lines) { + // ignore empty lines + if ( line.trimmed().isEmpty() ) continue; + + // remove comments + int commentPosition = line.indexOf('#'); + if ( commentPosition == 0 ) continue; // comment line + if ( commentPosition > 0 ) // inline comment + line.truncate(commentPosition); + + if (line.contains("[") && line.contains("]")) { + line.replace("[","").replace("]", ""); + group = line.trimmed(); + } + else { + if ( group.isEmpty() ) { + continue; } else { - if ( group.isEmpty() ) { - continue; - } - else { - if ( ! line.isEmpty() ) { - QString key = ""; - QString value = ""; - if ( line.contains('=') ) { - QStringList keyValue = line.split('='); - key = keyValue[0].trimmed(); - value = keyValue[1].trimmed(); - } - else { - key = line; - } - QString location= settingFile.absolutePath() + "/"; - QString category= QString(location + settingFile.baseName()).remove(Storage::Settings_Path_Name); - _Settings.add(group, key, QVariant(value), location, category); - // DEBUG: qDebug() << group << key << value << location << category; + line = line.trimmed(); + if ( ! line.isEmpty() ) { + QString key = ""; + QString value = ""; + if ( line.contains('=') ) { + QStringList keyValue = line.split('='); + key = keyValue[0].trimmed(); + value = keyValue[1].trimmed(); } + else { + key = line; + } + _Settings.add(group, key, QVariant(value), detail.location, detail.category); + // DEBUG: qDebug() << group << key << value << location << category; } } } + // qDebug() << group << line; } } return 0;