forked from qt-creator/qt-creator
QmlDesigner: Fix setting position from qml2puppet
Change-Id: I1348fa3d761be7b185d5324a73e8cdd543be50e9 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
#include <designersupportdelegate.h>
|
#include <designersupportdelegate.h>
|
||||||
|
|
||||||
|
#include <QVector3D>
|
||||||
#include <QQmlProperty>
|
#include <QQmlProperty>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
@@ -118,18 +119,45 @@ void Qt5InformationNodeInstanceServer::objectClicked(const QVariant &object)
|
|||||||
selectInstance(instance);
|
selectInstance(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<Qt5InformationNodeInstanceServer::InstancePropertyValueTriple>
|
||||||
|
Qt5InformationNodeInstanceServer::vectorToPropertyValue(
|
||||||
|
const ServerNodeInstance &instance,
|
||||||
|
const PropertyName &propertyName,
|
||||||
|
const QVariant &variant)
|
||||||
|
{
|
||||||
|
QVector<InstancePropertyValueTriple> result;
|
||||||
|
|
||||||
|
auto vector3d = variant.value<QVector3D>();
|
||||||
|
|
||||||
|
if (vector3d.isNull())
|
||||||
|
return result;
|
||||||
|
|
||||||
|
const PropertyName dot = propertyName.isEmpty() ? "" : ".";
|
||||||
|
|
||||||
|
InstancePropertyValueTriple propTriple;
|
||||||
|
propTriple.instance = instance;
|
||||||
|
propTriple.propertyName = propertyName + dot + PropertyName("x");
|
||||||
|
propTriple.propertyValue = vector3d.x();
|
||||||
|
result.append(propTriple);
|
||||||
|
propTriple.propertyName = propertyName + dot + PropertyName("y");
|
||||||
|
propTriple.propertyValue = vector3d.y();
|
||||||
|
result.append(propTriple);
|
||||||
|
propTriple.propertyName = propertyName + dot + PropertyName("z");
|
||||||
|
propTriple.propertyValue = vector3d.z();
|
||||||
|
result.append(propTriple);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Qt5InformationNodeInstanceServer::handleObjectPositionCommit(const QVariant &object)
|
void Qt5InformationNodeInstanceServer::handleObjectPositionCommit(const QVariant &object)
|
||||||
{
|
{
|
||||||
QObject *obj = object.value<QObject *>();
|
auto *obj = object.value<QObject *>();
|
||||||
if (obj) {
|
if (obj) {
|
||||||
ServerNodeInstance instance = instanceForObject(obj);
|
/* We do have to split position into position.x, position.y, position.z */
|
||||||
QVector<InstancePropertyValueTriple> modifiedpropertyList;
|
nodeInstanceClient()->valuesModified(createValuesModifiedCommand(vectorToPropertyValue(
|
||||||
InstancePropertyValueTriple propTriple;
|
instanceForObject(obj),
|
||||||
propTriple.instance = instance;
|
"position",
|
||||||
propTriple.propertyName = "position";
|
obj->property("position"))));
|
||||||
propTriple.propertyValue = obj->property(propTriple.propertyName.constData());
|
|
||||||
modifiedpropertyList.append(propTriple);
|
|
||||||
nodeInstanceClient()->valuesModified(createValuesModifiedCommand(modifiedpropertyList));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,6 +61,9 @@ private:
|
|||||||
QObject *createEditView3D(QQmlEngine *engine);
|
QObject *createEditView3D(QQmlEngine *engine);
|
||||||
void setup3DEditView(const QList<ServerNodeInstance> &instanceList);
|
void setup3DEditView(const QList<ServerNodeInstance> &instanceList);
|
||||||
QObject *findRootNodeOf3DViewport(const QList<ServerNodeInstance> &instanceList) const;
|
QObject *findRootNodeOf3DViewport(const QList<ServerNodeInstance> &instanceList) const;
|
||||||
|
QVector<InstancePropertyValueTriple> vectorToPropertyValue(const ServerNodeInstance &instance,
|
||||||
|
const PropertyName &propertyName,
|
||||||
|
const QVariant &variant);
|
||||||
|
|
||||||
QSet<ServerNodeInstance> m_parentChangedSet;
|
QSet<ServerNodeInstance> m_parentChangedSet;
|
||||||
QList<ServerNodeInstance> m_completedComponentList;
|
QList<ServerNodeInstance> m_completedComponentList;
|
||||||
|
Reference in New Issue
Block a user