QmlDesigner: Fix states editor none visual items

When using any none visual item as root (e.g. Window) which don't have
a state property the support for adding a state on the root item needs
to be deactivated otherwise QtDS is crashing. The new states editor was
missing that.
On the other hand the use of StatesGroup with none visual items is
supported.

Change-Id: I194913719a13099ce8ac7cde5f78083ef84dc37f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2022-11-25 15:44:32 +01:00
committed by Henning Gründl
parent ea55e01051
commit 62d86837e9
2 changed files with 7 additions and 2 deletions

View File

@@ -863,6 +863,7 @@ Rectangle {
Item {
id: addWrapper
visible: canAddNewStates
Canvas {
id: addCanvas

View File

@@ -105,6 +105,8 @@ void StatesEditorView::setActiveStatesGroupNode(const ModelNode &modelNode)
m_activeStatesGroupNode = modelNode;
resetModel();
checkForStatesAvailability();
emit m_statesEditorModel->activeStateGroupChanged();
emit m_statesEditorModel->activeStateGroupIndexChanged();
}
@@ -430,8 +432,10 @@ void StatesEditorView::resetStateGroups()
void StatesEditorView::checkForStatesAvailability()
{
if (m_statesEditorWidget) {
const bool isVisual = QmlVisualNode::isValidQmlVisualNode(activeStatesGroupNode());
m_statesEditorWidget->showAddNewStatesButton(isVisual);
const bool isVisual = activeStatesGroupNode().metaInfo().isBasedOn(
model()->qtQuickItemMetaInfo(), model()->qtQuick3DNodeMetaInfo());
const bool isRoot = activeStatesGroupNode().isRootNode();
m_statesEditorWidget->showAddNewStatesButton(isVisual || !isRoot);
}
}