Commit 27afbe49 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.PropertyEditor: Select new created gradient stop

Task-number: QTCREATORBUG-12507
Change-Id: I2d2bc4d478e53b5b5a0faeeda68cd95d7c85377e
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 77ba7eb8
......@@ -122,8 +122,11 @@ Item {
onClicked: {
var currentPosition = mouseX / colorLine.effectiveWidth
gradientModel.addStop(currentPosition, currentColor)
colorLine.select(gradientModel.count - 1)
var newIndex = gradientModel.addStop(currentPosition, currentColor)
if (newIndex > 0)
colorLine.select(newIndex)
colorLine.invalidate()
}
Item {
......
......@@ -94,13 +94,13 @@ QVariant GradientModel::data(const QModelIndex &index, int role) const
return QVariant();
}
void GradientModel::addStop(qreal position, const QColor &color)
int GradientModel::addStop(qreal position, const QColor &color)
{
if (m_lock)
return;
return -1;
if (!m_itemNode.isValid() || gradientPropertyName().isEmpty())
return;
return -1;
if (m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
//QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
......@@ -125,7 +125,11 @@ void GradientModel::addStop(qreal position, const QColor &color)
gradientNode.nodeListProperty("stops").slide(stopNodes.count() - 1, properPos);
setupModel();
return properPos;
}
return -1;
}
void GradientModel::addGradient()
......
......@@ -53,7 +53,7 @@ public:
QHash<int, QByteArray> roleNames() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Q_INVOKABLE void addStop(qreal position, const QColor &color);
Q_INVOKABLE int addStop(qreal position, const QColor &color);
Q_INVOKABLE void addGradient();
Q_INVOKABLE void setColor(int index, const QColor &color);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment