#include "NodeStyle.hpp"
#include
#include
#include
#include
#include
#include "StyleCollection.hpp"
using QtNodes::NodeStyle;
inline void initResources()
{
Q_INIT_RESOURCE(resources);
}
NodeStyle::NodeStyle()
{
// Explicit resources inialization for preventing the static initialization
// order fiasco: https://isocpp.org/wiki/faq/ctors#static-init-order
initResources();
// This configuration is stored inside the compiled unit and is loaded statically
loadJsonFile(":DefaultStyle.json");
}
NodeStyle::NodeStyle(const QVariant &style)
{
if(style.userType() == QMetaType::QVariantMap)
{
loadJson(style.toJsonObject());
}
else *this = style.value();
}
NodeStyle::NodeStyle(QString jsonText)
{
loadJsonText(jsonText);
}
NodeStyle::NodeStyle(QJsonObject const &json)
{
loadJson(json);
}
NodeStyle &NodeStyle::operator=(const NodeStyle &other) noexcept
{
DashedBoundaryColor = other.DashedBoundaryColor;
NormalBoundaryColor = other.NormalBoundaryColor;
SelectedBoundaryColor = other.SelectedBoundaryColor;
GradientColor0 = other.GradientColor0;
GradientColor1 = other.GradientColor1;
GradientColor2 = other.GradientColor2;
GradientColor3 = other.GradientColor3;
ShadowColor = other.ShadowColor;
FontColor = other.FontColor;
FontColorFaded = other.FontColorFaded;
ConnectionPointColor = other.ConnectionPointColor;
FilledConnectionPointColor = other.FilledConnectionPointColor;
WarningColor = other.WarningColor;
ErrorColor = other.ErrorColor;
PenWidth = other.PenWidth;
HoveredPenWidth = other.HoveredPenWidth;
ConnectionPointDiameter = other.ConnectionPointDiameter;
Opacity = other.Opacity;
return *this;
}
void NodeStyle::setNodeStyle(QString jsonText)
{
NodeStyle style(jsonText);
StyleCollection::setNodeStyle(style);
}
#ifdef STYLE_DEBUG
#define NODE_STYLE_CHECK_UNDEFINED_VALUE(v, variable) \
{ \
if (v.type() == QJsonValue::Undefined || v.type() == QJsonValue::Null) \
qWarning()