2018-12-31 15:48:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// util
|
|
|
|
#include <utils/Logger.h>
|
|
|
|
#include <effectengine/EffectDefinition.h>
|
|
|
|
#include <effectengine/EffectSchema.h>
|
|
|
|
#include <utils/settings.h>
|
|
|
|
|
|
|
|
class EffectFileHandler : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
friend class HyperionDaemon;
|
|
|
|
EffectFileHandler(const QString& rootPath, const QJsonDocument& effectConfig, QObject* parent = nullptr);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static EffectFileHandler* efhInstance;
|
2020-11-14 17:58:56 +01:00
|
|
|
static EffectFileHandler* getInstance() { return efhInstance; }
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Get all available effects
|
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
std::list<EffectDefinition> getEffects() const { return _availableEffects; }
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Get all available schemas
|
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
std::list<EffectSchema> getEffectSchemas() const { return _effectSchemas; }
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Save an effect
|
2020-03-26 17:59:41 +01:00
|
|
|
/// @param obj The effect args
|
|
|
|
/// @return If not empty, it contains the error
|
2018-12-31 15:48:29 +01:00
|
|
|
///
|
2020-03-26 17:59:41 +01:00
|
|
|
QString saveEffect(const QJsonObject& obj);
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Delete an effect by name.
|
2020-03-26 17:59:41 +01:00
|
|
|
/// @param effectName The effect name to delete
|
|
|
|
/// @return If not empty, it contains the error
|
2018-12-31 15:48:29 +01:00
|
|
|
///
|
2020-03-26 17:59:41 +01:00
|
|
|
QString deleteEffect(const QString& effectName);
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
///
|
|
|
|
/// @brief Handle settings update from Hyperion Settingsmanager emit
|
|
|
|
/// @param type settingyType from enum
|
|
|
|
/// @param config configuration object
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
///
|
|
|
|
/// @brief Emits whenever the data changes for an effect
|
|
|
|
///
|
|
|
|
void effectListChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
/// @brief refresh available schemas and effects
|
|
|
|
///
|
|
|
|
void updateEffects();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Load the effect definition, called by updateEffects()
|
|
|
|
///
|
|
|
|
bool loadEffectDefinition(const QString & path, const QString & effectConfigFile, EffectDefinition &effectDefinition);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief load effect schemas, called by updateEffects()
|
|
|
|
///
|
|
|
|
bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QJsonObject _effectConfig;
|
|
|
|
Logger* _log;
|
|
|
|
const QString _rootPath;
|
|
|
|
|
|
|
|
// available effects
|
|
|
|
std::list<EffectDefinition> _availableEffects;
|
|
|
|
|
|
|
|
// all schemas
|
|
|
|
std::list<EffectSchema> _effectSchemas;
|
|
|
|
};
|