Read visualisations from subdirs https://bugs.gentoo.org/917064 https://github.com/clementine-player/Clementine/issues/7151 --- a/src/visualisations/projectmpresetmodel.cpp +++ b/src/visualisations/projectmpresetmodel.cpp @@ -27,22 +27,26 @@ #endif #include +#include #include +#include ProjectMPresetModel::ProjectMPresetModel(ProjectMVisualisation* vis, QObject* parent) : QAbstractItemModel(parent), vis_(vis) { // Find presets - QDir preset_dir(vis_->preset_url()); - QStringList presets( - preset_dir.entryList(QStringList() << "*.milk" - << "*.prjm", + QDirIterator it(vis_->preset_url(), + QStringList() << "*.milk" << "*.prjm", QDir::Files | QDir::NoDotAndDotDot | QDir::Readable, - QDir::Name | QDir::IgnoreCase)); + QDirIterator::Subdirectories); + std::set> files; + while (it.hasNext()) { + it.next(); + files.insert({it.filePath(), it.fileName()}); + } - for (const QString& filename : presets) { - all_presets_ << Preset(preset_dir.absoluteFilePath(filename), filename, - false); + for (const auto& [filePath, fileName] : files) { + all_presets_ << Preset(filePath, fileName, false); } } --- a/src/visualisations/projectmvisualisation.cpp +++ b/src/visualisations/projectmvisualisation.cpp @@ -93,7 +93,7 @@ void ProjectMVisualisation::InitProjectM() { if (!QFile::exists(path)) continue; // Don't use empty directories - if (QDir(path).entryList(QDir::Files | QDir::NoDotAndDotDot).isEmpty()) + if (QDir(path).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).isEmpty()) continue; preset_path = path;