2023-06-29 15:06:11 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#include "effectnode.h"
|
2023-12-05 16:05:06 +02:00
|
|
|
#include "compositionnode.h"
|
|
|
|
|
#include "uniform.h"
|
2023-06-29 15:06:11 +03:00
|
|
|
|
2023-08-14 11:12:04 +03:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
2024-01-26 14:55:50 +02:00
|
|
|
namespace EffectComposer {
|
2023-06-29 15:06:11 +03:00
|
|
|
|
2023-08-14 11:12:04 +03:00
|
|
|
EffectNode::EffectNode(const QString &qenPath)
|
|
|
|
|
: m_qenPath(qenPath)
|
|
|
|
|
{
|
2023-08-16 11:35:10 +03:00
|
|
|
const QFileInfo fileInfo = QFileInfo(qenPath);
|
|
|
|
|
|
2024-01-19 11:55:37 +02:00
|
|
|
QString iconPath = QStringLiteral("%1/icon/%2.svg").arg(fileInfo.absolutePath(),
|
|
|
|
|
fileInfo.baseName());
|
2023-08-16 11:35:10 +03:00
|
|
|
if (!QFileInfo::exists(iconPath)) {
|
|
|
|
|
QDir parentDir = QDir(fileInfo.absolutePath());
|
|
|
|
|
parentDir.cdUp();
|
|
|
|
|
|
|
|
|
|
iconPath = QStringLiteral("%1/%2").arg(parentDir.path(), "placeholder.svg");
|
|
|
|
|
}
|
|
|
|
|
m_iconPath = QUrl::fromLocalFile(iconPath);
|
2023-12-05 16:05:06 +02:00
|
|
|
|
|
|
|
|
CompositionNode node({}, qenPath);
|
|
|
|
|
|
2024-01-19 11:55:37 +02:00
|
|
|
m_name = node.name();
|
2024-01-19 12:38:13 +02:00
|
|
|
m_description = node.description();
|
2024-01-19 11:55:37 +02:00
|
|
|
|
|
|
|
|
const QList<Uniform *> uniforms = node.uniforms();
|
2024-02-05 14:59:46 +02:00
|
|
|
for (const Uniform *uniform : uniforms) {
|
2023-12-05 16:05:06 +02:00
|
|
|
m_uniformNames.insert(uniform->name());
|
2024-02-05 14:59:46 +02:00
|
|
|
if (uniform->type() == Uniform::Type::Sampler) {
|
|
|
|
|
m_defaultImagesHash.insert(
|
|
|
|
|
uniform->name(), uniform->defaultValue().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-14 11:12:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString EffectNode::name() const
|
|
|
|
|
{
|
|
|
|
|
return m_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString EffectNode::description() const
|
|
|
|
|
{
|
|
|
|
|
return m_description;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 13:41:27 +03:00
|
|
|
QString EffectNode::qenPath() const
|
|
|
|
|
{
|
|
|
|
|
return m_qenPath;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-05 16:05:06 +02:00
|
|
|
void EffectNode::setCanBeAdded(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
if (enabled != m_canBeAdded) {
|
|
|
|
|
m_canBeAdded = enabled;
|
|
|
|
|
emit canBeAddedChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EffectNode::hasUniform(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
return m_uniformNames.contains(name);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 14:55:50 +02:00
|
|
|
} // namespace EffectComposer
|
2023-09-15 15:36:15 +03:00
|
|
|
|