Read system projectm presets from subdirs
Fix #7151 Note that this requires C++17 patches from #7272 because I don't want to bother backporting the fix to syntax available in C++11
This commit is contained in:
parent
5968648aa1
commit
fb3d5ad476
|
@ -27,22 +27,26 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
ProjectMPresetModel::ProjectMPresetModel(ProjectMVisualisation* vis,
|
ProjectMPresetModel::ProjectMPresetModel(ProjectMVisualisation* vis,
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
: QAbstractItemModel(parent), vis_(vis) {
|
: QAbstractItemModel(parent), vis_(vis) {
|
||||||
// Find presets
|
// Find presets
|
||||||
QDir preset_dir(vis_->preset_url());
|
QDirIterator it(vis_->preset_url(),
|
||||||
QStringList presets(
|
QStringList() << "*.milk" << "*.prjm",
|
||||||
preset_dir.entryList(QStringList() << "*.milk"
|
|
||||||
<< "*.prjm",
|
|
||||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable,
|
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable,
|
||||||
QDir::Name | QDir::IgnoreCase));
|
QDirIterator::Subdirectories);
|
||||||
|
std::set<std::pair<QString, QString>> files;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
files.insert({it.filePath(), it.fileName()});
|
||||||
|
}
|
||||||
|
|
||||||
for (const QString& filename : presets) {
|
for (const auto& [filePath, fileName] : files) {
|
||||||
all_presets_ << Preset(preset_dir.absoluteFilePath(filename), filename,
|
all_presets_ << Preset(filePath, fileName, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ void ProjectMVisualisation::InitProjectM() {
|
||||||
if (!QFile::exists(path)) continue;
|
if (!QFile::exists(path)) continue;
|
||||||
|
|
||||||
// Don't use empty directories
|
// 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;
|
continue;
|
||||||
|
|
||||||
preset_path = path;
|
preset_path = path;
|
||||||
|
|
Loading…
Reference in New Issue