14 #include "../CRESettings.h"
18 #include <QTextStream>
23 setProperty(
tipProperty, tr(
"Display all sound files."));
45 std::map<std::string, std::string> soundConf;
46 QFile file(dir.filePath(
"sounds.conf"));
47 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
48 QTextStream in(&file);
50 QString line = in.readLine();
51 if (line.isEmpty() || line.startsWith(
'#')) {
54 auto split = line.split(
':');
55 if (split.length() != 3) {
58 soundConf[split[0].toStdString()] = split[2].toStdString();
61 qDebug() << tr(
"Unable to open sound configuration file %1/sounds.conf").arg(path);
64 auto files = dir.entryList(QDir::Files, QDir::SortFlag::IgnoreCase | QDir::Name);
65 for (
auto file : files) {
66 if (file.endsWith(
".ogg") || file.endsWith(
".wav")) {
67 std::vector<std::string>
events;
68 for (
const auto &sc : soundConf) {
69 if (sc.second == file.toStdString()) {
70 events.push_back(sc.first);
76 if (file.endsWith(
".LICENSE")) {
77 auto name = file.left(file.length() - 8);
78 auto it = std::find_if(
mySounds.cbegin(),
mySounds.cend(), [&name] (
const auto &sound) { return sound->displayName() == name; });
80 auto br = bufferreader_init_from_file(
nullptr, dir.filePath(file).toStdString().data(),
"Failed to open LICENSE file %s: %s", llevError);
83 bufferreader_destroy(br);
98 for (
size_t i = 0; i <
mySounds.size(); ++i) {
100 return static_cast<int>(i);
108 return tr(
"No sound file found");
111 for (
const auto &sound :
mySounds) {
112 if (!sound->license().empty()) {
116 size_t percent = 100 * with /
mySounds.size();
117 if (percent == 100 && with <
mySounds.size()) {
120 return tr(
"%1 sound files with license information on %2 (%3%)").arg(with).arg(
mySounds.size()).arg(percent);