From 2c32c9c9910cf1179153ad0dc154d09490337c83 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 8 Mar 2022 12:31:31 +0200 Subject: [PATCH] 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 Reviewed-by: Qt CI Bot --- .../qt5informationnodeinstanceserver.cpp | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index ae1c289b415..9656e0e5e89 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -431,6 +431,9 @@ void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DPart if (targetParticleSystem == m_targetParticleSystem) return; + // stop the previously selected from animating + resetParticleSystem(); + m_targetParticleSystem = targetParticleSystem; if (m_editView3DData.rootItem) { @@ -441,11 +444,9 @@ void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DPart if (!m_particleAnimationDriver) return; - m_particleAnimationDriver->reset(); - // stop the previously selected from animating + // Ensure clean slate for newly selected system resetParticleSystem(); - resetParticleSystem(); #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2) QObject::disconnect(m_particleAnimationConnection); m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () { @@ -1977,6 +1978,9 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm QVariantList selectedObjs; QObject *firstSceneRoot = nullptr; ServerNodeInstance firstInstance; +#ifdef QUICK3D_PARTICLES_MODULE + QList selectedParticleSystems; +#endif for (qint32 id : instanceIds) { if (hasInstanceForId(id)) { ServerNodeInstance instance = instanceForId(id); @@ -1990,17 +1994,12 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm object = instance.internalObject(); #ifdef QUICK3D_PARTICLES_MODULE - auto particlesystem = qobject_cast(instance.internalObject()); - if (particlesystem) { - handleParticleSystemSelected(particlesystem); - } else { - particlesystem = parentParticleSystem(instance.internalObject()); - if (particlesystem) { - if (particlesystem != m_targetParticleSystem) - handleParticleSystemSelected(particlesystem); - } else { - handleParticleSystemDeselected(); - } + if (selectedParticleSystems.size() <= 1) { + auto particleSystem = qobject_cast(instance.internalObject()); + if (!particleSystem) + particleSystem = parentParticleSystem(instance.internalObject()); + if (particleSystem && !selectedParticleSystems.contains(particleSystem)) + selectedParticleSystems.append(particleSystem); } #endif 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) { m_active3DScene = firstSceneRoot; m_active3DView = findView3DForInstance(firstInstance);