Commit 2dd9a0cc authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.PropertyEditor: Fix selection in gradient editing

Since property change signals can be emitted in any order we have to rely
on selection changed signals to guarantee a valid state.

I use the isInValidState which is only true after all properties have been
setup correctly after a selection change for this.

I added the signal selectionChanged for this.

Task-number: QTCREATORBUG-12642
Task-number: QTCREATORBUG-12506
Change-Id: Idf3bbe8236ece541ca267efb1bd68e0737c99716
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent e4189136
......@@ -62,6 +62,7 @@ Column {
id: colorEditorTimer
repeat: false
interval: 100
running: false
onTriggered: {
if (backendendValue !== undefined)
backendendValue.value = colorEditor.color
......@@ -69,21 +70,22 @@ Column {
}
onColorChanged: {
if (!gradientLine.isCompleted)
if (!gradientLine.isInValidState)
return;
if (supportGradient && gradientLine.hasGradient) {
gradientLine.currentColor = color
textField.text = convertColorToString(color)
gradientLine.currentColor = color
}
if (buttonRow.checkedIndex !== 1)
if (buttonRow.checkedIndex !== 1) {
//Delay setting the color to keep ui responsive
colorEditorTimer.restart()
}
}
GradientLine {
property bool isCompleted: false
property bool isInValidState: false
visible: buttonRow.checkedIndex === 1
id: gradientLine
......@@ -108,20 +110,25 @@ Column {
buttonRow.checkedIndex = buttonRow.initalChecked
}
Connections {
target: modelNodeBackend
onSelectionToBeChanged: {
colorEditorTimer.stop()
gradientLine.isInValidState = false
}
}
Connections {
target: modelNodeBackend
onSelectionChanged: {
if (supportGradient && gradientLine.hasGradient) {
colorEditor.color = gradientLine.currentColor
} else {
colorEditor.color = colorEditor.value
gradientLine.currentColor = color
}
gradientLine.isInValidState = true
}
}
Component.onCompleted: {
isCompleted= true
}
}
SectionLayout {
......
......@@ -443,6 +443,11 @@ void PropertyEditorQmlBackend::emitSelectionToBeChanged()
m_backendModelNode.emitSelectionToBeChanged();
}
void PropertyEditorQmlBackend::emitSelectionChanged()
{
m_backendModelNode.emitSelectionChanged();
}
QUrl PropertyEditorQmlBackend::getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className)
{
if (modelNode.isValid()) {
......
......@@ -75,6 +75,7 @@ public:
static bool checkIfUrlExists(const QUrl &url);
void emitSelectionToBeChanged();
void emitSelectionChanged();
private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
......
......@@ -347,6 +347,9 @@ void PropertyEditorView::resetView()
setupQmlBackend();
if (m_qmlBackEndForCurrentType)
m_qmlBackEndForCurrentType->emitSelectionChanged();
m_locked = false;
if (m_timerId)
......
......@@ -55,6 +55,11 @@ void QmlModelNodeProxy::emitSelectionToBeChanged()
emit selectionToBeChanged();
}
void QmlModelNodeProxy::emitSelectionChanged()
{
selectionChanged();
}
QmlItemNode QmlModelNodeProxy::qmlItemNode() const
{
return m_qmlItemNode;
......
......@@ -50,6 +50,7 @@ public:
static void registerDeclarativeType();
void emitSelectionToBeChanged();
void emitSelectionChanged();
QmlItemNode qmlItemNode() const;
......@@ -58,6 +59,7 @@ public:
signals:
void modelNodeChanged();
void selectionToBeChanged();
void selectionChanged();
public slots:
......
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