summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-05-11 19:06:48 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-06-14 14:36:19 +0000
commit6263af19264a4d2cb9b0f2ae6d5801438204c601 (patch)
treeef37eb65fe3818826d6e3ed2499abfbddfffb8e2
parent86148b286b2a562f44ca517c96a1c78d8d0eae31 (diff)
Pick the right type for QVariant channel targets
Animating a Parameter node would be impossible otherwise since the 'value' property is a QVariant so QChannelMapping has no chance of know what really is expected there. If a value is already set, we can automatically determine the QVariant's underlying type. If not, show a warning since we have no chance then. Start handling QMetaType::Float as well since a QVariant will ofen contain this, not a Double. Change-Id: I0ba2abbb2c8d85f2aa1a152ed4b8c6cd26f1fc97 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/animation/backend/animationutils.cpp2
-rw-r--r--src/animation/frontend/qchannelmapping.cpp9
2 files changed, 11 insertions, 0 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp
index c0287e9f2..c12ad99f7 100644
--- a/src/animation/backend/animationutils.cpp
+++ b/src/animation/backend/animationutils.cpp
@@ -61,6 +61,7 @@ int componentsForType(int type)
{
int componentCount = 1;
switch (type) {
+ case QMetaType::Float:
case QVariant::Double:
componentCount = 1;
break;
@@ -237,6 +238,7 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim
// Build the new value from the channel/fcurve evaluation results
QVariant v;
switch (mappingData.type) {
+ case QMetaType::Float:
case QVariant::Double: {
v = QVariant::fromValue(channelResults[mappingData.channelIndices[0]]);
break;
diff --git a/src/animation/frontend/qchannelmapping.cpp b/src/animation/frontend/qchannelmapping.cpp
index b3d3816a0..90504d942 100644
--- a/src/animation/frontend/qchannelmapping.cpp
+++ b/src/animation/frontend/qchannelmapping.cpp
@@ -74,6 +74,15 @@ void QChannelMappingPrivate::updatePropertyNameAndType()
QMetaProperty mp = mo->property(propertyIndex);
propertyName = mp.name();
type = mp.userType();
+ if (type == QMetaType::QVariant) {
+ QVariant currentValue = m_target->property(mp.name());
+ if (!currentValue.isNull()) {
+ type = currentValue.userType();
+ } else {
+ qWarning("QChannelMapping: Attempted to target QVariant property with no value set."
+ "Set a value first in order to be able to determine the type.");
+ }
+ }
}
if (m_type != type) {