QmlDesigner: Fix issues related to uniforms

Some types were parsed wrong for shader values

Change-Id: I4301d671dfa7bde1f23feacd64ceb5f0f9d247b9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Amr Essam
2023-10-26 17:41:54 +03:00
committed by Amr Elsayed
parent 37f00b47a9
commit 2473265541
3 changed files with 6 additions and 6 deletions

View File

@@ -230,7 +230,7 @@ const QString EffectMakerModel::getBufUniform()
for (const auto uniform : uniforms) {
// TODO: Check if uniform is already added.
if (uniform->type() != Uniform::Type::Sampler && uniform->type() != Uniform::Type::Define) {
QString type = Uniform::stringFromType(uniform->type());
QString type = Uniform::stringFromType(uniform->type(), true);
QString props = " " + type + " " + uniform->name() + ";\n";
s += props;
}
@@ -480,7 +480,7 @@ const QString EffectMakerModel::getConstVariables()
for (Uniform *uniform : uniforms) {
// TODO: Check if uniform is already added.
QString constValue = valueAsVariable(*uniform);
QString type = Uniform::stringFromType(uniform->type());
QString type = Uniform::stringFromType(uniform->type(), true);
s += QString("const %1 %2 = %3;\n").arg(type, uniform->name(), constValue);
}
if (!s.isEmpty())

View File

@@ -63,7 +63,7 @@ Uniform::Type Uniform::type() const
// String representation of the type for qml
QString Uniform::typeName() const
{
return Uniform::stringFromType(m_type);
return Uniform::stringFromType(m_type, false);
}
QVariant Uniform::value() const
@@ -258,7 +258,7 @@ QVariant Uniform::valueStringToVariant(const QString &value)
return variant;
}
QString Uniform::stringFromType(Uniform::Type type)
QString Uniform::stringFromType(Uniform::Type type, bool isShader)
{
if (type == Type::Bool)
return "bool";
@@ -273,7 +273,7 @@ QString Uniform::stringFromType(Uniform::Type type)
else if (type == Type::Vec4)
return "vec4";
else if (type == Type::Color)
return "color";
return isShader ? QString("vec4") : QString("color");
else if (type == Type::Sampler)
return "sampler2D";
else if (type == Type::Define)

View File

@@ -69,7 +69,7 @@ public:
bool enableMipmap() const;
static QString stringFromType(Uniform::Type type);
static QString stringFromType(Uniform::Type type, bool isShader);
static Uniform::Type typeFromString(const QString &typeString);
static QString typeToProperty(Uniform::Type type);