forked from qt-creator/qt-creator
QmlDesigner.propertyEditor: bugfix for assert
Since the linedit in the property editor has an input mask, propery names like "red" are not handled correctly. Change-Id: I43ec2f7e42de7f57d78c97b6865ea36c4e11b3fb Solution: We normalize "red" to "#ff0000" in the property editor. Task-number: QTCREATORBUG-5479 Reviewed-on: http://codereview.qt.nokia.com/1749 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Marco Bubke <marco.bubke@nokia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -96,6 +96,22 @@ static bool cleverColorCompare(QVariant value1, QVariant value2)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* "red" is the same color as "#ff0000"
|
||||||
|
To simplify editing we convert all explicit color names in the hash format */
|
||||||
|
static void fixAmbigousColorNames(const QmlDesigner::ModelNode &modelNode, const QString &name, QVariant *value)
|
||||||
|
{
|
||||||
|
if (modelNode.isValid() && modelNode.metaInfo().isValid()
|
||||||
|
&& (modelNode.metaInfo().propertyTypeName(name) == "QColor"
|
||||||
|
|| modelNode.metaInfo().propertyTypeName(name) == "color")) {
|
||||||
|
if ((value->type() == QVariant::Color)) {
|
||||||
|
*value = QColor(value->value<QColor>().name());
|
||||||
|
} else {
|
||||||
|
*value = QColor(value->toString()).name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PropertyEditorValue::setValueWithEmit(const QVariant &value)
|
void PropertyEditorValue::setValueWithEmit(const QVariant &value)
|
||||||
{
|
{
|
||||||
if (m_value != value || isBound()) {
|
if (m_value != value || isBound()) {
|
||||||
@@ -125,6 +141,8 @@ void PropertyEditorValue::setValue(const QVariant &value)
|
|||||||
|
|
||||||
m_value = value;
|
m_value = value;
|
||||||
|
|
||||||
|
fixAmbigousColorNames(modelNode(), name(), &m_value);
|
||||||
|
|
||||||
if (m_value.isValid())
|
if (m_value.isValid())
|
||||||
emit valueChangedQml();
|
emit valueChangedQml();
|
||||||
emit isBoundChanged();
|
emit isBoundChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user