QmlDesigner: Add effect maker runtime nodes binding mechanism

Still some issues related to UI components because it's never tested
Also quick fix for generated paths on windows (not tested)

Task-number: QDS-10987
Change-Id: Ifed4b0f687e8da78206985e031692aa6c9faf947
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Amr Essam
2023-10-18 18:33:42 +03:00
committed by Amr Elsayed
parent a9a74992de
commit 12aeed97b3
7 changed files with 44 additions and 9 deletions

View File

@@ -22,5 +22,6 @@ add_qtc_plugin(EffectMakerNew
effectmakercontextobject.cpp effectmakercontextobject.h
shaderfeatures.cpp shaderfeatures.h
syntaxhighlighterdata.cpp syntaxhighlighterdata.h
propertyhandler.cpp propertyhandler.h
BUILD_DEFAULT OFF
)

View File

@@ -5,6 +5,7 @@
#include "effectutils.h"
#include "effectmakeruniformsmodel.h"
#include "propertyhandler.h"
#include "uniform.h"
#include <QFile>
@@ -100,8 +101,11 @@ void CompositionNode::parse(const QString &qenPath)
// parse properties
QJsonArray jsonProps = json.value("properties").toArray();
for (const auto /*QJsonValueRef*/ &prop : jsonProps)
m_unifomrsModel.addUniform(new Uniform(prop.toObject()));
for (const auto /*QJsonValueRef*/ &prop : jsonProps) {
const auto uniform = new Uniform(prop.toObject());
m_unifomrsModel.addUniform(uniform);
g_propertyData.insert(uniform->name(), uniform->value());
}
// Seek through code to get tags
QStringList shaderCodeLines;

View File

@@ -781,11 +781,11 @@ void EffectMakerModel::updateCustomUniforms()
}
}
QString valueString = value.isEmpty() ? QString() : QString(": %1").arg(value);
QString bindedValueString = bindedValue.isEmpty() ? QString() : QString(": %1").arg(bindedValue);
QString boundValueString = bindedValue.isEmpty() ? QString() : QString(": %1").arg(bindedValue);
// Custom values are not readonly, others inside the effect can be
QString readOnly = uniform->useCustomValue() ? QString() : QStringLiteral("readonly ");
previewEffectPropertiesString += " " + readOnly + "property " + type + " "
+ propertyName + valueString + '\n';
+ propertyName + boundValueString + '\n';
// Define type properties are not added into exports
if (!isDefine) {
if (uniform->useCustomValue()) {
@@ -797,7 +797,7 @@ void EffectMakerModel::updateCustomUniforms()
}
exportedEffectPropertiesString += QStringLiteral(" ") + readOnly
+ "property " + type + " " + propertyName
+ bindedValueString + '\n';
+ boundValueString + '\n';
} else {
// Custom values are not added into root
exportedRootPropertiesString += " property " + type + " " + propertyName
@@ -951,8 +951,8 @@ QString EffectMakerModel::getQmlComponentString(bool localFiles)
s += '\n' + customImagesString;
s += '\n';
s += l2 + "vertexShader: 'file://" + m_vertexShaderFilename + "'\n";
s += l2 + "fragmentShader: 'file://" + m_fragmentShaderFilename + "'\n";
s += l2 + "vertexShader: 'file:///" + m_vertexShaderFilename + "'\n";
s += l2 + "fragmentShader: 'file:///" + m_fragmentShaderFilename + "'\n";
s += l2 + "anchors.fill: parent\n";
if (m_shaderFeatures.enabled(ShaderFeatures::GridMesh)) {
QString gridSize = QString("%1, %2").arg(m_shaderFeatures.gridMeshWidth()).arg(m_shaderFeatures.gridMeshHeight());

View File

@@ -3,6 +3,7 @@
#include "effectmakeruniformsmodel.h"
#include "propertyhandler.h"
#include "uniform.h"
#include <utils/qtcassert.h>
@@ -48,7 +49,9 @@ bool EffectMakerUniformsModel::setData(const QModelIndex &index, const QVariant
if (!index.isValid() || !roleNames().contains(role))
return false;
m_uniforms.at(index.row())->setValue(value);
auto uniform = m_uniforms.at(index.row());
uniform->setValue(value);
g_propertyData.insert(uniform->name(), value);
emit dataChanged(index, index, {role});
return true;

View File

@@ -7,8 +7,8 @@
#include "effectmakermodel.h"
#include "effectmakernodesmodel.h"
#include "effectmakerview.h"
#include "propertyhandler.h"
#include "nodeinstanceview.h"
#include "qmldesignerconstants.h"
#include "qmldesignerplugin.h"
#include "qqmlcontext.h"
@@ -65,6 +65,8 @@ EffectMakerWidget::EffectMakerWidget(EffectMakerView *view)
QmlDesigner::QmlDesignerPlugin::trackWidgetFocusTime(this, QmlDesigner::Constants::EVENT_EFFECTMAKER_TIME);
m_quickWidget->rootContext()->setContextProperty("g_propertyData", &g_propertyData);
auto map = m_quickWidget->registerPropertyMap("EffectMakerBackend");
map->setProperties({{"effectMakerNodesModel", QVariant::fromValue(m_effectMakerNodesModel.data())},
{"effectMakerModel", QVariant::fromValue(m_effectMakerModel.data())},

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "propertyhandler.h"
namespace EffectMaker {
QQmlPropertyMap g_propertyData;
}

View File

@@ -0,0 +1,15 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
#include <QQmlPropertyMap>
namespace EffectMaker {
// This will be used for binding dynamic properties
// changes between C++ and QML.
extern QQmlPropertyMap g_propertyData;
}