QmlDesigner: Refresh items if state is changed

We have to paint each item after a state change. This seems
to be a regression caused by the swtich to Qt 6.

Task-number: QDS-5462
Change-Id: I10a1e0e03c7e887c0998864f397fcbe429364ec7
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2021-11-11 13:50:56 +01:00
parent 5cc183e0f7
commit 9d90715752

View File

@@ -25,10 +25,11 @@
#include "qmlstatenodeinstance.h" #include "qmlstatenodeinstance.h"
#include <qmlprivategate.h>
#include "qmlpropertychangesnodeinstance.h" #include "qmlpropertychangesnodeinstance.h"
#include <qmlprivategate.h>
#include <designersupportdelegate.h>
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
@@ -53,12 +54,28 @@ QmlStateNodeInstance::Pointer
return instance; return instance;
} }
void setAllNodesDirtyRecursive(QQuickItem *parentItem)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_UNUSED(parentItem)
#else
if (!parentItem)
return;
const QList<QQuickItem *> children = parentItem->childItems();
for (QQuickItem *childItem : children)
setAllNodesDirtyRecursive(childItem);
DesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
#endif
}
void QmlStateNodeInstance::activateState() void QmlStateNodeInstance::activateState()
{ {
if (!QmlPrivateGate::States::isStateActive(object(), context()) if (!QmlPrivateGate::States::isStateActive(object(), context())
&& nodeInstanceServer()->hasInstanceForObject(object())) { && nodeInstanceServer()->hasInstanceForObject(object())) {
nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object())); nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object()));
QmlPrivateGate::States::activateState(object(), context()); QmlPrivateGate::States::activateState(object(), context());
setAllNodesDirtyRecursive(nodeInstanceServer()->rootItem());
} }
} }