forked from qt-creator/qt-creator
QmlDesigner: Properly parse variant type
If a property actually is a variant we have to properly parse the string and convert it to the correct type. Booleans and numbers were not probably converted. This did not create many issues, since the conversion happened later, but it broke copy and paste and merging. In Qt 5 this conversion seemed to happen mostly automatically. Boolean literals have to be handled explcitly, since e.g. "10" is technically true and can be interpreted as boolean. Task-numbner: QDS-5944 Change-Id: I35c7cae7041667c7eac81e36a285a394263b35a4 Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -242,9 +242,21 @@ QVariant read(int variantType, const QString &str)
|
|||||||
bool conversionOk = true;
|
bool conversionOk = true;
|
||||||
switch (variantType) {
|
switch (variantType) {
|
||||||
case QMetaType::QVariant: {
|
case QMetaType::QVariant: {
|
||||||
|
|
||||||
|
if (str == "true")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (str == "false")
|
||||||
|
return false;
|
||||||
|
|
||||||
auto tmp = QVariant(str);
|
auto tmp = QVariant(str);
|
||||||
value = QVariant(tmp);
|
|
||||||
conversionOk = tmp.isValid();
|
conversionOk = tmp.isValid();
|
||||||
|
value = QVariant(tmp);
|
||||||
|
|
||||||
|
if (tmp.canConvert(QMetaType::Double))
|
||||||
|
value.convert(QMetaType::Double);
|
||||||
|
else if (tmp.canConvert(QMetaType::QColor))
|
||||||
|
value.convert(QMetaType::QColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMetaType::QPoint:
|
case QMetaType::QPoint:
|
||||||
|
Reference in New Issue
Block a user