forked from qt-creator/qt-creator
QmlDesigner: Fix drag & drop 3D components into 2D/3D view
The created components do not have metadata files that contain the node's hints. With their help, a decision is made whether the item can be placed in the view. The fix is to add two hints that allow to create an item in the proper view. In addition, a metainfo has been added to check if an object is based on Object3D. This allows to check if the element is from QtQuick3D. This fix solves issues for non-project storage builds only. Task-number: QDS-15237 Pick-to: qds/4.7 Change-Id: Ib00c26989b0400d3aad48882f5c9f8fc1b5bef40 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
committed by
Shrief Gabr
parent
8c6bf9b221
commit
472b888112
@@ -194,6 +194,7 @@ public:
|
||||
NodeMetaInfo qtQuick3DMaterialMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DModelMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DNodeMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DObject3DMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DOrthographicCameraMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DParticles3DSpriteParticle3DMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DPerspectiveCameraMetaInfo() const;
|
||||
|
@@ -233,6 +233,7 @@ public:
|
||||
bool isQtQuick3DMaterial() const;
|
||||
bool isQtQuick3DModel(SL sl = {}) const;
|
||||
bool isQtQuick3DNode(SL sl = {}) const;
|
||||
bool isQtQuick3DObject3D(SL sl = {}) const;
|
||||
bool isQtQuick3DParticlesAbstractShape(SL sl = {}) const;
|
||||
bool isQtQuick3DParticles3DAffector3D(SL sl = {}) const;
|
||||
bool isQtQuick3DParticles3DAttractor3D(SL sl = {}) const;
|
||||
|
@@ -4650,6 +4650,25 @@ bool NodeMetaInfo::isQtQuick3DNode(SL sl) const
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeMetaInfo::isQtQuick3DObject3D(SL sl) const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
if (!isValid())
|
||||
return false;
|
||||
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"is QtQuick3D.Object3D",
|
||||
category(),
|
||||
keyValue("type id", m_typeId),
|
||||
keyValue("caller location", sl)};
|
||||
|
||||
using namespace Storage::Info;
|
||||
return isBasedOnCommonType<QtQuick3D, Object3D>(m_projectStorage, m_typeId);
|
||||
} else {
|
||||
return isValid() && isSubclassOf("QtQuick3D.Object3D");
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeMetaInfo::isQtQuick3DParticles3DAffector3D(SL sl) const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
|
@@ -372,6 +372,16 @@ void SubComponentManager::registerQmlFile(const QFileInfo &fileInfo, const QStri
|
||||
if (!qualifier.isEmpty())
|
||||
itemLibraryEntry.setRequiredImport(fixedQualifier);
|
||||
|
||||
const NodeMetaInfo nodeMetaInfo = model()->metaInfo(baseComponentName.toUtf8());
|
||||
if (nodeMetaInfo.isValid()) {
|
||||
QHash<QString, QString> hints;
|
||||
if (nodeMetaInfo.isBasedOn(model()->qtQuick3DObject3DMetaInfo()))
|
||||
hints["canBeDroppedInFormEditor"] = "false";
|
||||
if (nodeMetaInfo.isBasedOn(model()->qtQuick3DNodeMetaInfo()))
|
||||
hints["canBeDroppedInView3D"] = "true";
|
||||
itemLibraryEntry.addHints(hints);
|
||||
}
|
||||
|
||||
if (!model()->metaInfo().itemLibraryInfo()->containsEntry(itemLibraryEntry))
|
||||
model()->metaInfo().itemLibraryInfo()->addEntries({itemLibraryEntry});
|
||||
}
|
||||
|
@@ -2787,6 +2787,16 @@ NodeMetaInfo Model::qtQuick3DNodeMetaInfo() const
|
||||
}
|
||||
}
|
||||
|
||||
NodeMetaInfo Model::qtQuick3DObject3DMetaInfo() const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
using namespace Storage::Info;
|
||||
return createNodeMetaInfo<QtQuick3D, Object3D>();
|
||||
} else {
|
||||
return metaInfo("QtQuick3D.Object3D");
|
||||
}
|
||||
}
|
||||
|
||||
NodeMetaInfo Model::qtQuick3DPointLightMetaInfo() const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
|
@@ -71,6 +71,7 @@ inline constexpr char Material[] = "Material";
|
||||
inline constexpr char Model[] = "Model";
|
||||
inline constexpr char MouseArea[] = "MouseArea";
|
||||
inline constexpr char Node[] = "Node";
|
||||
inline constexpr char Object3D[] = "Object3D";
|
||||
inline constexpr char OrthographicCamera[] = "OrthographicCamera";
|
||||
inline constexpr char Particle3D[] = "Particle3D";
|
||||
inline constexpr char ParticleEmitter3D[] = "ParticleEmitter3D";
|
||||
@@ -223,6 +224,7 @@ class CommonTypeCache
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Material>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Model>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Node>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Object3D>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, OrthographicCamera>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, Pass>,
|
||||
CacheType<QtQuick3D, ModuleKind::QmlLibrary, PerspectiveCamera>,
|
||||
|
Reference in New Issue
Block a user