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
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QtDebug>
|
||||
#include <set>
|
||||
|
||||
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<std::pair<QString, QString>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue