QmlDesigner: Create the CompositionNode class

This one is used to represent an effect with its attributes while editing the current composition.
Also some refactoring to remove the composition properties from EffectNode.

Change-Id: Idd0137db98cb608f3ead49ba3208e4480a185e88
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Amr Essam
2023-08-16 11:35:10 +03:00
committed by Amr Elsayed
parent c78e0965c0
commit ce8423a42b
5 changed files with 106 additions and 62 deletions

View File

@@ -0,0 +1,63 @@
// 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 "compositionnode.h"
#include <QFileInfo>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
namespace QmlDesigner {
CompositionNode::CompositionNode(const QString &qenPath)
{
parse(qenPath);
}
QString CompositionNode::fragmentCode() const
{
return m_fragmentCode;
}
QString CompositionNode::vertexCode() const
{
return m_vertexCode;
}
QString CompositionNode::description() const
{
return m_description;
}
void CompositionNode::parse(const QString &qenPath)
{
QFile loadFile(qenPath);
if (!loadFile.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open effect file.");
return;
}
QByteArray loadData = loadFile.readAll();
QJsonParseError parseError;
QJsonDocument jsonDoc(QJsonDocument::fromJson(loadData, &parseError));
if (parseError.error != QJsonParseError::NoError) {
QString error = QString("Error parsing the effect node: %1:").arg(qenPath);
QString errorDetails = QString("%1: %2").arg(parseError.offset).arg(parseError.errorString());
qWarning() << qPrintable(error);
qWarning() << qPrintable(errorDetails);
return;
}
QJsonObject json = jsonDoc.object();
QFileInfo fi(loadFile);
// TODO: QDS-10467
// Parse the effect from QEN file
// The process from the older implementation has the concept of `project`
// and it contains source & dest nodes that we don't need
}
}