Commit fdb95e3d authored by patrick pereira's avatar patrick pereira 🏃
Browse files

exercisecontroller: Search for exercises in XDG_DATA_DIRS for macos


Signed-off-by: patrick pereira's avatarPatrick José Pereira <patrickelectric@gmail.com>
parent 550d6076
...@@ -62,6 +62,7 @@ target_link_libraries(minuet ...@@ -62,6 +62,7 @@ target_link_libraries(minuet
Qt5::QuickControls2 Qt5::QuickControls2
Qt5::Svg Qt5::Svg
Minuet::Interfaces Minuet::Interfaces
Minuet::Utils
) )
if(ANDROID) if(ANDROID)
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QRandomGenerator> #include <QRandomGenerator>
#include <utils/xdgdatadirs.h>
namespace Minuet namespace Minuet
{ {
...@@ -124,6 +126,17 @@ bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject ...@@ -124,6 +126,17 @@ bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("minuet/") + directoryName, QStandardPaths::LocateDirectory); jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("minuet/") + directoryName, QStandardPaths::LocateDirectory);
#else #else
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName, QStandardPaths::LocateDirectory); jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName, QStandardPaths::LocateDirectory);
#ifdef Q_OS_MACOS
if (jsonDirs.isEmpty()) {
const QStringList xdgDataDirs = Utils::getXdgDataDirs();
for (const auto &dirPath : xdgDataDirs) {
const QDir testDir(QDir(dirPath).absoluteFilePath(QStringLiteral("minuet/") + directoryName));
if (testDir.exists()) {
jsonDirs << testDir.absolutePath();
}
}
}
#endif
#endif #endif
foreach (const QString &jsonDirString, jsonDirs) { foreach (const QString &jsonDirString, jsonDirs) {
QDir jsonDir(jsonDirString); QDir jsonDir(jsonDirString);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment