QmlDesigner: Deactivate particle system when locked

Particle systems are now deactivated in 3D edit view unless nodes from
exactly one system are selected. Selected nodes that are not part of
any particle system are ignored for this determination. This now also
includes deactivating previously active system when an empty
selection is received from creator side (happens e.g. when selected
system is locked).

Fixes: QDS-6405
Change-Id: I5b1636640594e51db5d6e725684075727536b1a5
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Miikka Heikkinen
2022-03-08 12:31:31 +02:00
parent 4ba957f9d8
commit 2c32c9c991

View File

@@ -431,6 +431,9 @@ void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DPart
if (targetParticleSystem == m_targetParticleSystem) if (targetParticleSystem == m_targetParticleSystem)
return; return;
// stop the previously selected from animating
resetParticleSystem();
m_targetParticleSystem = targetParticleSystem; m_targetParticleSystem = targetParticleSystem;
if (m_editView3DData.rootItem) { if (m_editView3DData.rootItem) {
@@ -441,11 +444,9 @@ void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DPart
if (!m_particleAnimationDriver) if (!m_particleAnimationDriver)
return; return;
m_particleAnimationDriver->reset(); // Ensure clean slate for newly selected system
// stop the previously selected from animating
resetParticleSystem(); resetParticleSystem();
resetParticleSystem();
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2) #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2)
QObject::disconnect(m_particleAnimationConnection); QObject::disconnect(m_particleAnimationConnection);
m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () { m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () {
@@ -1977,6 +1978,9 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
QVariantList selectedObjs; QVariantList selectedObjs;
QObject *firstSceneRoot = nullptr; QObject *firstSceneRoot = nullptr;
ServerNodeInstance firstInstance; ServerNodeInstance firstInstance;
#ifdef QUICK3D_PARTICLES_MODULE
QList<QQuick3DParticleSystem *> selectedParticleSystems;
#endif
for (qint32 id : instanceIds) { for (qint32 id : instanceIds) {
if (hasInstanceForId(id)) { if (hasInstanceForId(id)) {
ServerNodeInstance instance = instanceForId(id); ServerNodeInstance instance = instanceForId(id);
@@ -1990,17 +1994,12 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
object = instance.internalObject(); object = instance.internalObject();
#ifdef QUICK3D_PARTICLES_MODULE #ifdef QUICK3D_PARTICLES_MODULE
auto particlesystem = qobject_cast<QQuick3DParticleSystem *>(instance.internalObject()); if (selectedParticleSystems.size() <= 1) {
if (particlesystem) { auto particleSystem = qobject_cast<QQuick3DParticleSystem *>(instance.internalObject());
handleParticleSystemSelected(particlesystem); if (!particleSystem)
} else { particleSystem = parentParticleSystem(instance.internalObject());
particlesystem = parentParticleSystem(instance.internalObject()); if (particleSystem && !selectedParticleSystems.contains(particleSystem))
if (particlesystem) { selectedParticleSystems.append(particleSystem);
if (particlesystem != m_targetParticleSystem)
handleParticleSystemSelected(particlesystem);
} else {
handleParticleSystemDeselected();
}
} }
#endif #endif
auto isSelectableAsRoot = [&]() -> bool { auto isSelectableAsRoot = [&]() -> bool {
@@ -2033,6 +2032,14 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
} }
} }
#ifdef QUICK3D_PARTICLES_MODULE
// We only support exactly one active particle systems at a time
if (selectedParticleSystems.size() == 1)
handleParticleSystemSelected(selectedParticleSystems[0]);
else
handleParticleSystemDeselected();
#endif
if (firstSceneRoot && m_active3DScene != firstSceneRoot) { if (firstSceneRoot && m_active3DScene != firstSceneRoot) {
m_active3DScene = firstSceneRoot; m_active3DScene = firstSceneRoot;
m_active3DView = findView3DForInstance(firstInstance); m_active3DView = findView3DForInstance(firstInstance);