forked from qt-creator/qt-creator
QmlDesigner: Allow invalid property value for QVariant type properties
Invalid QVariant is a valid value for properties of type QVariant, so propagate the value change from puppet to creator in that case. Also change the property editor to notify controls of value change in case of invalid value set, and clear LineEdit when invalid value is set. Fixes: QDS-5304 Change-Id: I02c7daaf3cde06317690a32e7ac8a82da754bd58 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1221,7 +1221,15 @@ ValuesChangedCommand NodeInstanceServer::createValuesChangedCommand(const QVecto
|
|||||||
|
|
||||||
if (instance.isValid()) {
|
if (instance.isValid()) {
|
||||||
QVariant propertyValue = instance.property(propertyName);
|
QVariant propertyValue = instance.property(propertyName);
|
||||||
if (QMetaType::isRegistered(propertyValue.userType()) && supportedVariantType(propertyValue.type())) {
|
bool isValid = QMetaType::isRegistered(propertyValue.userType())
|
||||||
|
&& supportedVariantType(propertyValue.type());
|
||||||
|
if (!isValid && propertyValue.userType() == 0) {
|
||||||
|
// If the property is QVariant type, invalid variant can be a valid value
|
||||||
|
const QMetaObject *mo = instance.internalObject()->metaObject();
|
||||||
|
const int idx = mo->indexOfProperty(propertyName);
|
||||||
|
isValid = idx >= 0 && mo->property(idx).userType() == QMetaType::QVariant;
|
||||||
|
}
|
||||||
|
if (isValid) {
|
||||||
valueVector.append(PropertyValueContainer(instance.instanceId(), propertyName,
|
valueVector.append(PropertyValueContainer(instance.instanceId(), propertyName,
|
||||||
propertyValue, PropertyName()));
|
propertyValue, PropertyName()));
|
||||||
}
|
}
|
||||||
|
@@ -76,13 +76,13 @@ StudioControls.TextField {
|
|||||||
id: colorLogic
|
id: colorLogic
|
||||||
backendValue: lineEdit.backendValue
|
backendValue: lineEdit.backendValue
|
||||||
onValueFromBackendChanged: {
|
onValueFromBackendChanged: {
|
||||||
if (colorLogic.valueFromBackend === undefined)
|
if (colorLogic.valueFromBackend === undefined) {
|
||||||
return
|
lineEdit.text = ""
|
||||||
|
|
||||||
if (writeValueManually) {
|
|
||||||
lineEdit.text = convertColorToString(colorLogic.valueFromBackend)
|
|
||||||
} else {
|
} else {
|
||||||
lineEdit.text = colorLogic.valueFromBackend
|
if (writeValueManually)
|
||||||
|
lineEdit.text = convertColorToString(colorLogic.valueFromBackend)
|
||||||
|
else
|
||||||
|
lineEdit.text = colorLogic.valueFromBackend
|
||||||
}
|
}
|
||||||
__dirty = false
|
__dirty = false
|
||||||
}
|
}
|
||||||
|
@@ -167,7 +167,7 @@ void PropertyEditorValue::setValue(const QVariant &value)
|
|||||||
fixAmbigousColorNames(modelNode(), name(), &m_value);
|
fixAmbigousColorNames(modelNode(), name(), &m_value);
|
||||||
fixUrl(modelNode(), name(), &m_value);
|
fixUrl(modelNode(), name(), &m_value);
|
||||||
|
|
||||||
if (m_value.isValid() && !colorsEqual)
|
if (!colorsEqual)
|
||||||
emit valueChangedQml();
|
emit valueChangedQml();
|
||||||
|
|
||||||
emit isExplicitChanged();
|
emit isExplicitChanged();
|
||||||
|
Reference in New Issue
Block a user