summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-04 14:10:33 +0100
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2011-03-04 14:10:33 +0100
commit990d66a0fb248067bfa0c3ed8a37c6dc2846112f (patch)
tree0f161fe7ff1c8cb7d2331f64a0e4b5293b844f9b
parent14b251eda064ff23d87065cd32b5a76c7aa5fb92 (diff)
downloadqt-creator-990d66a0fb248067bfa0c3ed8a37c6dc2846112f.tar.gz
QmlDesigner.propertyEditor: fix gradient editing
This fixes some glitches that were introduced by refactoring the code.
-rw-r--r--src/libs/qmleditorwidgets/gradientline.cpp8
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp10
2 files changed, 10 insertions, 8 deletions
diff --git a/src/libs/qmleditorwidgets/gradientline.cpp b/src/libs/qmleditorwidgets/gradientline.cpp
index 2992ab951b..7dd238f03b 100644
--- a/src/libs/qmleditorwidgets/gradientline.cpp
+++ b/src/libs/qmleditorwidgets/gradientline.cpp
@@ -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;
diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp
index b6c3ad0f32..b92dfcec98 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp
@@ -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");