mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
update
This commit is contained in:
@@ -18,33 +18,46 @@
|
||||
#include <effectengine/EffectEngine.h>
|
||||
#include <effectengine/Effect.h>
|
||||
#include <effectengine/EffectModule.h>
|
||||
#include <effectengine/EffectFileHandler.h>
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
EffectEngine::EffectEngine(Hyperion * hyperion, const QJsonObject & jsonEffectConfig)
|
||||
EffectEngine::EffectEngine(Hyperion * hyperion)
|
||||
: _hyperion(hyperion)
|
||||
, _effectConfig(jsonEffectConfig)
|
||||
, _availableEffects()
|
||||
, _activeEffects()
|
||||
, _log(Logger::getInstance("EFFECTENGINE"))
|
||||
, _effectFileHandler(EffectFileHandler::getInstance())
|
||||
{
|
||||
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
|
||||
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
// connect the Hyperion channel clear feedback
|
||||
connect(_hyperion, SIGNAL(channelCleared(int)), this, SLOT(channelCleared(int)));
|
||||
connect(_hyperion, SIGNAL(allChannelsCleared()), this, SLOT(allChannelsCleared()));
|
||||
|
||||
// read all effects
|
||||
readEffects();
|
||||
// get notifications about refreshed effect list
|
||||
connect(_effectFileHandler, &EffectFileHandler::effectListChanged, this, &EffectEngine::handleUpdatedEffectList);
|
||||
|
||||
// register smooth cfgs and fill available effects
|
||||
handleUpdatedEffectList();
|
||||
}
|
||||
|
||||
EffectEngine::~EffectEngine()
|
||||
{
|
||||
}
|
||||
|
||||
const bool EffectEngine::saveEffect(const QJsonObject& obj, QString& resultMsg)
|
||||
{
|
||||
return _effectFileHandler->saveEffect(obj, resultMsg);
|
||||
}
|
||||
|
||||
const bool EffectEngine::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
{
|
||||
return _effectFileHandler->deleteEffect(effectName, resultMsg);
|
||||
}
|
||||
|
||||
const std::list<ActiveEffectDefinition> &EffectEngine::getActiveEffects()
|
||||
{
|
||||
_availableActiveEffects.clear();
|
||||
@@ -63,6 +76,11 @@ const std::list<ActiveEffectDefinition> &EffectEngine::getActiveEffects()
|
||||
return _availableActiveEffects;
|
||||
}
|
||||
|
||||
const std::list<EffectSchema> & EffectEngine::getEffectSchemas()
|
||||
{
|
||||
return _effectFileHandler->getEffectSchemas();
|
||||
}
|
||||
|
||||
void EffectEngine::cacheRunningEffects()
|
||||
{
|
||||
_cachedActiveEffects.clear();
|
||||
@@ -90,175 +108,26 @@ void EffectEngine::startCachedEffects()
|
||||
_cachedActiveEffects.clear();
|
||||
}
|
||||
|
||||
bool EffectEngine::loadEffectDefinition(const QString &path, const QString &effectConfigFile, EffectDefinition & effectDefinition)
|
||||
void EffectEngine::handleUpdatedEffectList()
|
||||
{
|
||||
QString fileName = path + QDir::separator() + effectConfigFile;
|
||||
|
||||
// Read and parse the effect json config file
|
||||
QJsonObject configEffect;
|
||||
if(!JsonUtils::readFile(fileName, configEffect, _log))
|
||||
return false;
|
||||
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
// validate effect config with effect schema(path)
|
||||
if(!JsonUtils::validate(fileName, configEffect, ":effect-schema", _log))
|
||||
return false;
|
||||
|
||||
// setup the definition
|
||||
effectDefinition.file = fileName;
|
||||
QJsonObject config = configEffect;
|
||||
QString scriptName = config["script"].toString();
|
||||
effectDefinition.name = config["name"].toString();
|
||||
if (scriptName.isEmpty())
|
||||
return false;
|
||||
|
||||
QFile fileInfo(scriptName);
|
||||
|
||||
if (scriptName.mid(0, 1) == ":" )
|
||||
{
|
||||
(!fileInfo.exists())
|
||||
? effectDefinition.script = ":/effects/"+scriptName.mid(1)
|
||||
: effectDefinition.script = scriptName;
|
||||
} else
|
||||
{
|
||||
(!fileInfo.exists())
|
||||
? effectDefinition.script = path + QDir::separator() + scriptName
|
||||
: effectDefinition.script = scriptName;
|
||||
}
|
||||
|
||||
effectDefinition.args = config["args"].toObject();
|
||||
effectDefinition.smoothCfg = SMOOTHING_MODE_PAUSE;
|
||||
if (effectDefinition.args["smoothing-custom-settings"].toBool())
|
||||
{
|
||||
effectDefinition.smoothCfg = _hyperion->addSmoothingConfig(
|
||||
effectDefinition.args["smoothing-time_ms"].toInt(),
|
||||
effectDefinition.args["smoothing-updateFrequency"].toDouble(),
|
||||
0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
effectDefinition.smoothCfg = _hyperion->addSmoothingConfig(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EffectEngine::loadEffectSchema(const QString &path, const QString &effectSchemaFile, EffectSchema & effectSchema)
|
||||
{
|
||||
QString fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
||||
|
||||
// Read and parse the effect schema file
|
||||
QJsonObject schemaEffect;
|
||||
if(!JsonUtils::readFile(fileName, schemaEffect, _log))
|
||||
return false;
|
||||
|
||||
// setup the definition
|
||||
QString scriptName = schemaEffect["script"].toString();
|
||||
effectSchema.schemaFile = fileName;
|
||||
fileName = path + QDir::separator() + scriptName;
|
||||
QFile pyFile(fileName);
|
||||
|
||||
if (scriptName.isEmpty() || !pyFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
||||
Error( _log, "Python script '%s' in effect schema '%s' could not be loaded", QSTRING_CSTR(scriptName), QSTRING_CSTR(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
pyFile.close();
|
||||
|
||||
effectSchema.pyFile = (scriptName.mid(0, 1) == ":" ) ? ":/effects/"+scriptName.mid(1) : path + QDir::separator() + scriptName;
|
||||
effectSchema.pySchema = schemaEffect;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EffectEngine::readEffects()
|
||||
{
|
||||
// clear all lists
|
||||
_availableEffects.clear();
|
||||
_effectSchemas.clear();
|
||||
|
||||
// read all effects
|
||||
const QJsonArray & paths = _effectConfig["paths"].toArray();
|
||||
const QJsonArray & disabledEfx = _effectConfig["disable"].toArray();
|
||||
|
||||
QStringList efxPathList;
|
||||
efxPathList << ":/effects/";
|
||||
QStringList disableList;
|
||||
|
||||
for(auto p : paths)
|
||||
for (auto def : _effectFileHandler->getEffects())
|
||||
{
|
||||
efxPathList << p.toString().replace("$ROOT",_hyperion->getRootPath());
|
||||
}
|
||||
for(auto efx : disabledEfx)
|
||||
{
|
||||
disableList << efx.toString();
|
||||
}
|
||||
|
||||
QMap<QString, EffectDefinition> availableEffects;
|
||||
for (const QString & path : efxPathList )
|
||||
{
|
||||
QDir directory(path);
|
||||
if (!directory.exists())
|
||||
// add smoothing configs to Hyperion
|
||||
if (def.args["smoothing-custom-settings"].toBool())
|
||||
{
|
||||
if(directory.mkpath(path))
|
||||
{
|
||||
Warning(_log, "New Effect path \"%s\" created successfull", QSTRING_CSTR(path) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(_log, "Failed to create Effect path \"%s\", please check permissions", QSTRING_CSTR(path) );
|
||||
}
|
||||
def.smoothCfg = _hyperion->addSmoothingConfig(
|
||||
def.args["smoothing-time_ms"].toInt(),
|
||||
def.args["smoothing-updateFrequency"].toDouble(),
|
||||
0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int efxCount = 0;
|
||||
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
for (const QString & filename : filenames)
|
||||
{
|
||||
EffectDefinition def;
|
||||
if (loadEffectDefinition(path, filename, def))
|
||||
{
|
||||
InfoIf(availableEffects.find(def.name) != availableEffects.end(), _log,
|
||||
"effect overload effect '%s' is now taken from '%s'", QSTRING_CSTR(def.name), QSTRING_CSTR(path) );
|
||||
|
||||
if ( disableList.contains(def.name) )
|
||||
{
|
||||
Info(_log, "effect '%s' not loaded, because it is disabled in hyperion config", QSTRING_CSTR(def.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
availableEffects[def.name] = def;
|
||||
efxCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Info(_log, "%d effects loaded from directory %s", efxCount, QSTRING_CSTR(path));
|
||||
|
||||
// collect effect schemas
|
||||
efxCount = 0;
|
||||
directory = path.endsWith("/") ? (path + "schema/") : (path + "/schema/");
|
||||
QStringList pynames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
for (const QString & pyname : pynames)
|
||||
{
|
||||
EffectSchema pyEffect;
|
||||
if (loadEffectSchema(path, pyname, pyEffect))
|
||||
{
|
||||
_effectSchemas.push_back(pyEffect);
|
||||
efxCount++;
|
||||
}
|
||||
}
|
||||
InfoIf(efxCount > 0, _log, "%d effect schemas loaded from directory %s", efxCount, QSTRING_CSTR((path + "schema/")));
|
||||
def.smoothCfg = _hyperion->addSmoothingConfig(true);
|
||||
}
|
||||
_availableEffects.push_back(def);
|
||||
}
|
||||
|
||||
for(auto item : availableEffects)
|
||||
{
|
||||
_availableEffects.push_back(item);
|
||||
}
|
||||
|
||||
ErrorIf(_availableEffects.size()==0, _log, "no effects found, check your effect directories");
|
||||
|
||||
emit effectListUpdated();
|
||||
}
|
||||
|
||||
|
322
libsrc/effectengine/EffectFileHandler.cpp
Normal file
322
libsrc/effectengine/EffectFileHandler.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
#include <effectengine/EffectFileHandler.h>
|
||||
|
||||
// util
|
||||
#include <utils/JsonUtils.h>
|
||||
|
||||
// qt
|
||||
#include <QJsonArray>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
|
||||
// createEffect helper
|
||||
struct find_schema: std::unary_function<EffectSchema, bool>
|
||||
{
|
||||
QString pyFile;
|
||||
find_schema(QString pyFile):pyFile(pyFile) { }
|
||||
bool operator()(EffectSchema const& schema) const
|
||||
{
|
||||
return schema.pyFile == pyFile;
|
||||
}
|
||||
};
|
||||
|
||||
// deleteEffect helper
|
||||
struct find_effect: std::unary_function<EffectDefinition, bool>
|
||||
{
|
||||
QString effectName;
|
||||
find_effect(QString effectName) :effectName(effectName) { }
|
||||
bool operator()(EffectDefinition const& effectDefinition) const
|
||||
{
|
||||
return effectDefinition.name == effectName;
|
||||
}
|
||||
};
|
||||
|
||||
EffectFileHandler* EffectFileHandler::efhInstance;
|
||||
|
||||
EffectFileHandler::EffectFileHandler(const QString& rootPath, const QJsonDocument& effectConfig, QObject* parent)
|
||||
: QObject(parent)
|
||||
, _effectConfig()
|
||||
, _log(Logger::getInstance("EFFECTFILES"))
|
||||
, _rootPath(rootPath)
|
||||
{
|
||||
EffectFileHandler::efhInstance = this;
|
||||
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
|
||||
// init
|
||||
handleSettingsUpdate(settings::EFFECTS, effectConfig);
|
||||
}
|
||||
|
||||
void EffectFileHandler::handleSettingsUpdate(const settings::type& type, const QJsonDocument& config)
|
||||
{
|
||||
if(type == settings::EFFECTS)
|
||||
{
|
||||
_effectConfig = config.object();
|
||||
// update effects and schemas
|
||||
updateEffects();
|
||||
}
|
||||
}
|
||||
|
||||
const bool EffectFileHandler::deleteEffect(const QString& effectName, QString& resultMsg)
|
||||
{
|
||||
std::list<EffectDefinition> effectsDefinition = getEffects();
|
||||
std::list<EffectDefinition>::iterator it = std::find_if(effectsDefinition.begin(), effectsDefinition.end(), find_effect(effectName));
|
||||
|
||||
if (it != effectsDefinition.end())
|
||||
{
|
||||
QFileInfo effectConfigurationFile(it->file);
|
||||
if (effectConfigurationFile.absoluteFilePath().mid(0, 1) != ":" )
|
||||
{
|
||||
if (effectConfigurationFile.exists())
|
||||
{
|
||||
bool result = QFile::remove(effectConfigurationFile.absoluteFilePath());
|
||||
if (result)
|
||||
{
|
||||
updateEffects();
|
||||
return true;
|
||||
} else
|
||||
resultMsg = "Can't delete effect configuration file: " + effectConfigurationFile.absoluteFilePath() + ". Please check permissions";
|
||||
} else
|
||||
resultMsg = "Can't find effect configuration file: " + effectConfigurationFile.absoluteFilePath();
|
||||
} else
|
||||
resultMsg = "Can't delete internal effect: " + effectName;
|
||||
} else
|
||||
resultMsg = "Effect " + effectName + " not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool EffectFileHandler::saveEffect(const QJsonObject& message, QString& resultMsg)
|
||||
{
|
||||
if (!message["args"].toObject().isEmpty())
|
||||
{
|
||||
QString scriptName;
|
||||
(message["script"].toString().mid(0, 1) == ":" )
|
||||
? scriptName = ":/effects//" + message["script"].toString().mid(1)
|
||||
: scriptName = message["script"].toString();
|
||||
|
||||
std::list<EffectSchema> effectsSchemas = getEffectSchemas();
|
||||
std::list<EffectSchema>::iterator it = std::find_if(effectsSchemas.begin(), effectsSchemas.end(), find_schema(scriptName));
|
||||
|
||||
if (it != effectsSchemas.end())
|
||||
{
|
||||
if(!JsonUtils::validate("EffectFileHandler", message["args"].toObject(), it->schemaFile, _log))
|
||||
{
|
||||
resultMsg = "Error during arg validation against schema, please consult the Hyperion Log";
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject effectJson;
|
||||
QJsonArray effectArray;
|
||||
effectArray = _effectConfig["paths"].toArray();
|
||||
|
||||
if (effectArray.size() > 0)
|
||||
{
|
||||
if (message["name"].toString().trimmed().isEmpty() || message["name"].toString().trimmed().startsWith("."))
|
||||
{
|
||||
resultMsg = "Can't save new effect. Effect name is empty or begins with a dot.";
|
||||
return false;
|
||||
}
|
||||
|
||||
effectJson["name"] = message["name"].toString();
|
||||
effectJson["script"] = message["script"].toString();
|
||||
effectJson["args"] = message["args"].toObject();
|
||||
|
||||
std::list<EffectDefinition> availableEffects = getEffects();
|
||||
std::list<EffectDefinition>::iterator iter = std::find_if(availableEffects.begin(), availableEffects.end(), find_effect(message["name"].toString()));
|
||||
|
||||
QFileInfo newFileName;
|
||||
if (iter != availableEffects.end())
|
||||
{
|
||||
newFileName.setFile(iter->file);
|
||||
if (newFileName.absoluteFilePath().mid(0, 1) == ":")
|
||||
{
|
||||
resultMsg = "The effect name '" + message["name"].toString() + "' is assigned to an internal effect. Please rename your effekt.";
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
// TODO global special keyword handling
|
||||
QString f = effectArray[0].toString().replace("$ROOT",_rootPath) + "/" + message["name"].toString().replace(QString(" "), QString("")) + QString(".json");
|
||||
newFileName.setFile(f);
|
||||
}
|
||||
|
||||
if(!JsonUtils::write(newFileName.absoluteFilePath(), effectJson, _log))
|
||||
{
|
||||
resultMsg = "Error while saving effect, please check the Hyperion Log";
|
||||
return false;
|
||||
}
|
||||
|
||||
Info(_log, "Reload effect list");
|
||||
updateEffects();
|
||||
resultMsg = "";
|
||||
return true;
|
||||
} else
|
||||
resultMsg = "Can't save new effect. Effect path empty";
|
||||
} else
|
||||
resultMsg = "Missing schema file for Python script " + message["script"].toString();
|
||||
} else
|
||||
resultMsg = "Missing or empty Object 'args'";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EffectFileHandler::updateEffects()
|
||||
{
|
||||
// clear all lists
|
||||
_availableEffects.clear();
|
||||
_effectSchemas.clear();
|
||||
|
||||
// read all effects
|
||||
const QJsonArray & paths = _effectConfig["paths"].toArray();
|
||||
const QJsonArray & disabledEfx = _effectConfig["disable"].toArray();
|
||||
|
||||
QStringList efxPathList;
|
||||
efxPathList << ":/effects/";
|
||||
QStringList disableList;
|
||||
|
||||
for(auto p : paths)
|
||||
{
|
||||
efxPathList << p.toString().replace("$ROOT",_rootPath);
|
||||
}
|
||||
for(auto efx : disabledEfx)
|
||||
{
|
||||
disableList << efx.toString();
|
||||
}
|
||||
|
||||
QMap<QString, EffectDefinition> availableEffects;
|
||||
for (const QString & path : efxPathList )
|
||||
{
|
||||
QDir directory(path);
|
||||
if (!directory.exists())
|
||||
{
|
||||
if(directory.mkpath(path))
|
||||
{
|
||||
Info(_log, "New Effect path \"%s\" created successfull", QSTRING_CSTR(path) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(_log, "Failed to create Effect path \"%s\", please check permissions", QSTRING_CSTR(path) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int efxCount = 0;
|
||||
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
for (const QString & filename : filenames)
|
||||
{
|
||||
EffectDefinition def;
|
||||
if (loadEffectDefinition(path, filename, def))
|
||||
{
|
||||
InfoIf(availableEffects.find(def.name) != availableEffects.end(), _log,
|
||||
"effect overload effect '%s' is now taken from '%s'", QSTRING_CSTR(def.name), QSTRING_CSTR(path) );
|
||||
|
||||
if ( disableList.contains(def.name) )
|
||||
{
|
||||
Info(_log, "effect '%s' not loaded, because it is disabled in hyperion config", QSTRING_CSTR(def.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
availableEffects[def.name] = def;
|
||||
efxCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Info(_log, "%d effects loaded from directory %s", efxCount, QSTRING_CSTR(path));
|
||||
|
||||
// collect effect schemas
|
||||
efxCount = 0;
|
||||
directory = path.endsWith("/") ? (path + "schema/") : (path + "/schema/");
|
||||
QStringList pynames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
for (const QString & pyname : pynames)
|
||||
{
|
||||
EffectSchema pyEffect;
|
||||
if (loadEffectSchema(path, pyname, pyEffect))
|
||||
{
|
||||
_effectSchemas.push_back(pyEffect);
|
||||
efxCount++;
|
||||
}
|
||||
}
|
||||
InfoIf(efxCount > 0, _log, "%d effect schemas loaded from directory %s", efxCount, QSTRING_CSTR((path + "schema/")));
|
||||
}
|
||||
}
|
||||
|
||||
for(auto item : availableEffects)
|
||||
{
|
||||
_availableEffects.push_back(item);
|
||||
}
|
||||
|
||||
ErrorIf(_availableEffects.size()==0, _log, "no effects found, check your effect directories");
|
||||
|
||||
emit effectListChanged();
|
||||
}
|
||||
|
||||
bool EffectFileHandler::loadEffectDefinition(const QString &path, const QString &effectConfigFile, EffectDefinition & effectDefinition)
|
||||
{
|
||||
QString fileName = path + QDir::separator() + effectConfigFile;
|
||||
|
||||
// Read and parse the effect json config file
|
||||
QJsonObject configEffect;
|
||||
if(!JsonUtils::readFile(fileName, configEffect, _log))
|
||||
return false;
|
||||
|
||||
// validate effect config with effect schema(path)
|
||||
if(!JsonUtils::validate(fileName, configEffect, ":effect-schema", _log))
|
||||
return false;
|
||||
|
||||
// setup the definition
|
||||
effectDefinition.file = fileName;
|
||||
QJsonObject config = configEffect;
|
||||
QString scriptName = config["script"].toString();
|
||||
effectDefinition.name = config["name"].toString();
|
||||
if (scriptName.isEmpty())
|
||||
return false;
|
||||
|
||||
QFile fileInfo(scriptName);
|
||||
|
||||
if (scriptName.mid(0, 1) == ":" )
|
||||
{
|
||||
(!fileInfo.exists())
|
||||
? effectDefinition.script = ":/effects/"+scriptName.mid(1)
|
||||
: effectDefinition.script = scriptName;
|
||||
} else
|
||||
{
|
||||
(!fileInfo.exists())
|
||||
? effectDefinition.script = path + QDir::separator() + scriptName
|
||||
: effectDefinition.script = scriptName;
|
||||
}
|
||||
|
||||
effectDefinition.args = config["args"].toObject();
|
||||
effectDefinition.smoothCfg = 1; // pause config
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EffectFileHandler::loadEffectSchema(const QString &path, const QString &effectSchemaFile, EffectSchema & effectSchema)
|
||||
{
|
||||
QString fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
||||
|
||||
// Read and parse the effect schema file
|
||||
QJsonObject schemaEffect;
|
||||
if(!JsonUtils::readFile(fileName, schemaEffect, _log))
|
||||
return false;
|
||||
|
||||
// setup the definition
|
||||
QString scriptName = schemaEffect["script"].toString();
|
||||
effectSchema.schemaFile = fileName;
|
||||
fileName = path + QDir::separator() + scriptName;
|
||||
QFile pyFile(fileName);
|
||||
|
||||
if (scriptName.isEmpty() || !pyFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
||||
Error( _log, "Python script '%s' in effect schema '%s' could not be loaded", QSTRING_CSTR(scriptName), QSTRING_CSTR(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
pyFile.close();
|
||||
|
||||
effectSchema.pyFile = (scriptName.mid(0, 1) == ":" ) ? ":/effects/"+scriptName.mid(1) : path + QDir::separator() + scriptName;
|
||||
effectSchema.pySchema = schemaEffect;
|
||||
|
||||
return true;
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <effectengine/Effect.h>
|
||||
#include <effectengine/EffectModule.h>
|
||||
@@ -44,10 +45,9 @@ PyObject *EffectModule::json2python(const QJsonValue &jsonData)
|
||||
return Py_BuildValue("");
|
||||
case QJsonValue::Double:
|
||||
{
|
||||
if (std::rint(jsonData.toDouble()) != jsonData.toDouble())
|
||||
{
|
||||
if (std::round(jsonData.toDouble()) != jsonData.toDouble())
|
||||
return Py_BuildValue("d", jsonData.toDouble());
|
||||
}
|
||||
|
||||
return Py_BuildValue("i", jsonData.toInt());
|
||||
}
|
||||
case QJsonValue::Bool:
|
||||
|
Reference in New Issue
Block a user