forked from qt-creator/qt-creator
QmlDesigner: Add StateGroups to Connections
Task-number: QDS-8027 Change-Id: I72ce5bfd2505269ad750ee5fbd5b13669891290f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -492,6 +492,22 @@ struct SlotEntry
|
|||||||
std::function<void(SignalHandlerProperty)> action;
|
std::function<void(SignalHandlerProperty)> action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QList<ModelNode> stateGroups(const ModelNode &node)
|
||||||
|
{
|
||||||
|
if (!node.view()->isAttached())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const auto groupMetaInfo = node.view()->model()->qtQuickStateGroupMetaInfo();
|
||||||
|
|
||||||
|
return node.view()->allModelNodesOfType(groupMetaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList stateGroupsNames(const ModelNode &node)
|
||||||
|
{
|
||||||
|
return Utils::transform(stateGroups(node),
|
||||||
|
[](const ModelNode &node) { return node.displayName(); });
|
||||||
|
}
|
||||||
|
|
||||||
QList<SlotEntry> getSlotsLists(const ModelNode &node)
|
QList<SlotEntry> getSlotsLists(const ModelNode &node)
|
||||||
{
|
{
|
||||||
if (!node.isValid())
|
if (!node.isValid())
|
||||||
@@ -528,6 +544,32 @@ QList<SlotEntry> getSlotsLists(const ModelNode &node)
|
|||||||
resultList.push_back(entry);
|
resultList.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto sg = stateGroups(node);
|
||||||
|
|
||||||
|
for (const auto &stateGroup : sg) {
|
||||||
|
QmlObjectNode stateGroupObjectNode(stateGroup);
|
||||||
|
const QString stateGroupCategory = QString("Change State Group") + " "
|
||||||
|
+ stateGroup.displayName();
|
||||||
|
|
||||||
|
const SlotEntry defaultGroupState = {stateGroupCategory,
|
||||||
|
(stateGroupCategory + " to " + "Default State"),
|
||||||
|
[stateGroup](SignalHandlerProperty signalHandler) {
|
||||||
|
signalHandler.setSource(
|
||||||
|
QString("%1.state = \"\"").arg(stateGroup.id()));
|
||||||
|
}};
|
||||||
|
resultList.push_back(defaultGroupState);
|
||||||
|
|
||||||
|
for (const auto &stateName : stateGroupObjectNode.states().names()) {
|
||||||
|
SlotEntry entry = {stateGroupCategory,
|
||||||
|
(stateGroupCategory + " to " + stateName),
|
||||||
|
[stateGroup, stateName](SignalHandlerProperty signalHandler) {
|
||||||
|
signalHandler.setSource(
|
||||||
|
QString("%1.state = \"%2\"").arg(stateGroup.id(), stateName));
|
||||||
|
}};
|
||||||
|
resultList.push_back(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user