QmlDesigner.propertyEditor: fix gradient editing

This fixes some glitches that were introduced by refactoring the code.
This commit is contained in:
Thomas Hartmann
2011-03-04 14:10:33 +01:00
parent 14b251eda0
commit 990d66a0fb
2 changed files with 10 additions and 8 deletions

View File

@@ -54,8 +54,6 @@ void GradientLine::setGradient(const QLinearGradient &gradient)
m_gradient = gradient;
m_useGradient = true;
readGradient();
emit gradientChanged();
}
static inline QColor invertColor(const QColor color)
@@ -106,6 +104,8 @@ void GradientLine::setActiveColor(const QColor &newColor)
m_colorList.removeAt(currentColorIndex());
m_colorList.insert(currentColorIndex(), m_activeColor);
updateGradient();
emit gradientChanged();
emit activeColorChanged();
update();
}
@@ -141,6 +141,7 @@ void GradientLine::keyPressEvent(QKeyEvent * event)
m_stops.removeAt(currentColorIndex());
m_colorList.removeAt(currentColorIndex());
updateGradient();
emit gradientChanged();
setCurrentIndex(0);
//delete item
}
@@ -271,6 +272,7 @@ void GradientLine::mouseReleaseEvent(QMouseEvent *event)
m_stops.removeAt(currentColorIndex());
m_colorList.removeAt(currentColorIndex());
updateGradient();
emit gradientChanged();
setCurrentIndex(0);
//delete item
}
@@ -293,6 +295,7 @@ void GradientLine::mouseReleaseEvent(QMouseEvent *event)
m_dragActive = false;
m_yOffset = 0;
updateGradient();
emit gradientChanged();
update();
setFocus(Qt::MouseFocusReason);
}
@@ -349,7 +352,6 @@ void GradientLine::updateGradient()
stops.append(QPair<qreal, QColor>(m_stops.at(i), m_colorList.at(i)));
}
m_gradient.setStops(stops);
emit gradientChanged();
} else {
if (!active())
return;

View File

@@ -94,8 +94,8 @@ void GradientLineQmlAdaptor::setupGradient()
foreach (const ModelNode &stopNode, stopList) {
QmlObjectNode stopObjectNode = stopNode;
if (stopObjectNode.isValid()) {
qreal position = stopNode.variantProperty("position").value().toReal();
QColor color = stopNode.variantProperty("color").value().value<QColor>();
qreal position = stopObjectNode.modelValue("position").toReal();
QColor color = stopObjectNode.modelValue("color").value<QColor>();
stops.append( QPair<qreal, QColor>(position, color));
}
}
@@ -119,8 +119,6 @@ void GradientLineQmlAdaptor::writeGradient()
if (!m_itemNode.modelNode().metaInfo().hasProperty(gradientName()))
return;
try {
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
ModelNode modelNode = m_itemNode.modelNode();
QString oldId;
@@ -132,6 +130,9 @@ void GradientLineQmlAdaptor::writeGradient()
}
ModelNode gradientNode = modelNode.view()->createModelNode("QtQuick.Gradient", 1, 0);
modelNode.nodeProperty(gradientName()).reparentHere(gradientNode);
RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
if (!oldId.isNull())
gradientNode.setId(oldId);
@@ -142,7 +143,6 @@ void GradientLineQmlAdaptor::writeGradient()
gradientStopNode.variantProperty("color") = normalizeColor(stops.at(i).second);
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
}
modelNode.nodeProperty(gradientName()).reparentHere(gradientNode);
} else { //state
if (!modelNode.hasProperty(gradientName())) {
qWarning(" GradientLine::updateGradient: no gradient in state");