From a8ac61328b57dafd52968cbbecf5de51940b514a Mon Sep 17 00:00:00 2001 From: Amr Essam Date: Fri, 27 Oct 2023 17:02:45 +0300 Subject: [PATCH] QmlDesigner: Fix effect maker colors not update shaders Also some minor fixes and cleanups Change-Id: I3db71f41a703c19e53e2b7014de053a7759a4628 Reviewed-by: Mahmoud Badri --- .../effectmakernew/effectmakermodel.cpp | 27 +++++++++---------- src/plugins/effectmakernew/uniform.cpp | 2 +- src/plugins/effectmakernew/uniform.h | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/plugins/effectmakernew/effectmakermodel.cpp b/src/plugins/effectmakernew/effectmakermodel.cpp index 4e4bcacbdea..0745536cf23 100644 --- a/src/plugins/effectmakernew/effectmakermodel.cpp +++ b/src/plugins/effectmakernew/effectmakermodel.cpp @@ -390,12 +390,9 @@ QString EffectMakerModel::valueAsString(const Uniform &uniform) } else if (uniform.type() == Uniform::Type::Vec4) { QVector4D v4 = uniform.value().value(); return QString("Qt.vector4d(%1, %2, %3, %4)").arg(v4.x(), v4.y(), v4.z(), v4.w()); - } else if (uniform.type() == Uniform::Type::Color) { - QColor c = uniform.value().value(); - return QString("Qt.rgba(%1, %2, %3, %4)").arg(c.redF(), c.greenF(), c.blueF(), c.alphaF()); } else if (uniform.type() == Uniform::Type::Sampler) { return getImageElementName(uniform); - } else if (uniform.type() == Uniform::Type::Define) { + } else if (uniform.type() == Uniform::Type::Define || uniform.type() == Uniform::Type::Color) { return uniform.value().toString(); } else { qWarning() << QString("Unhandled const variable type: %1").arg(int(uniform.type())).toLatin1(); @@ -406,8 +403,11 @@ QString EffectMakerModel::valueAsString(const Uniform &uniform) // Get value in QML binding that used for previews QString EffectMakerModel::valueAsBinding(const Uniform &uniform) { - if (uniform.type() == Uniform::Type::Bool || uniform.type() == Uniform::Type::Int - || uniform.type() == Uniform::Type::Float || uniform.type() == Uniform::Type::Define) { + if (uniform.type() == Uniform::Type::Bool + || uniform.type() == Uniform::Type::Int + || uniform.type() == Uniform::Type::Float + || uniform.type() == Uniform::Type::Color + || uniform.type() == Uniform::Type::Define) { return "g_propertyData." + uniform.name(); } else if (uniform.type() == Uniform::Type::Vec2) { QString sx = QString("g_propertyData.%1.x").arg(uniform.name()); @@ -424,12 +424,6 @@ QString EffectMakerModel::valueAsBinding(const Uniform &uniform) QString sz = QString("g_propertyData.%1.z").arg(uniform.name()); QString sw = QString("g_propertyData.%1.w").arg(uniform.name()); return QString("Qt.vector4d(%1, %2, %3, %4)").arg(sx, sy, sz, sw); - } else if (uniform.type() == Uniform::Type::Color) { - QString sr = QString("g_propertyData.%1.r").arg(uniform.name()); - QString sg = QString("g_propertyData.%1.g").arg(uniform.name()); - QString sb = QString("g_propertyData.%1.b").arg(uniform.name()); - QString sa = QString("g_propertyData.%1.a").arg(uniform.name()); - return QString("Qt.rgba(%1, %2, %3, %4)").arg(sr, sg, sb, sa); } else if (uniform.type() == Uniform::Type::Sampler) { return getImageElementName(uniform); } else { @@ -748,10 +742,14 @@ void EffectMakerModel::handleQsbProcessExit(Utils::Process *qsbProcess, const QS --m_remainingQsbTargets; const QString errStr = qsbProcess->errorString(); - auto std = qsbProcess->stdErr(); + const QByteArray errStd = qsbProcess->readAllRawStandardError(); if (!errStr.isEmpty()) qWarning() << QString("Failed to generate QSB file for: %1 %2").arg(shader, errStr); + if (!errStd.isEmpty()) + qWarning() << QString("Failed to generate QSB file for: %1 %2") + .arg(shader, QString::fromUtf8(errStd)); + if (m_remainingQsbTargets <= 0) { Q_EMIT shadersBaked(); setShadersUpToDate(true); @@ -1005,7 +1003,8 @@ QString EffectMakerModel::getQmlComponentString(bool localFiles) 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()); + QString gridSize = QString("%1, %2").arg(m_shaderFeatures.gridMeshWidth()) + .arg(m_shaderFeatures.gridMeshHeight()); s += l2 + "mesh: GridMesh {\n"; s += l3 + QString("resolution: Qt.size(%1)\n").arg(gridSize); s += l2 + "}\n"; diff --git a/src/plugins/effectmakernew/uniform.cpp b/src/plugins/effectmakernew/uniform.cpp index 370adddc949..a9729b574ef 100644 --- a/src/plugins/effectmakernew/uniform.cpp +++ b/src/plugins/effectmakernew/uniform.cpp @@ -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, false); + return Uniform::stringFromType(m_type); } QVariant Uniform::value() const diff --git a/src/plugins/effectmakernew/uniform.h b/src/plugins/effectmakernew/uniform.h index 370c720410b..5146de6b67c 100644 --- a/src/plugins/effectmakernew/uniform.h +++ b/src/plugins/effectmakernew/uniform.h @@ -69,7 +69,7 @@ public: bool enableMipmap() const; - static QString stringFromType(Uniform::Type type, bool isShader); + static QString stringFromType(Uniform::Type type, bool isShader = false); static Uniform::Type typeFromString(const QString &typeString); static QString typeToProperty(Uniform::Type type);