Commit 6aeb2fab authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.PropertyEditor: Avoid side effects of ColorButton



The ColorButton did change the color as a side effects of rounding error.
With this patch the ColorButton does onyly change the color as a result
of user interaction.

Task-number: QTCREATORBUG-12202
Change-Id: I6504713a27fe7b562b8342229bd287af23156602
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent aff4424f
......@@ -49,6 +49,8 @@ Item {
invalidateColor();
}
signal clicked
onAlphaChanged: invalidateColor();
onSaturationChanged: invalidateColor();
......@@ -67,12 +69,17 @@ Item {
function invalidateColor() {
if (block)
return;
block = true
colorButton.color = Qt.hsla(hue, saturation, lightness, alpha);
hueSlider.value = hue
hueSlider2.value = hue
saturationSlider.value = saturation
lightnessSlider.value = lightness
alphaSlider.value = alpha
block = false
}
function rgbToHsl(color) {
......@@ -244,6 +251,8 @@ Item {
}
}
onPressed: positionChanged(mouse)
onClicked: colorButton.clicked()
}
Rectangle {
anchors.fill: parent
......@@ -266,6 +275,7 @@ Item {
if (colorButton.hue !== value)
colorButton.hue = value
}
onClicked: colorButton.clicked()
}
Column {
......@@ -292,8 +302,10 @@ Item {
minimumValue: 0
maximumValue: 1
onValueChanged: {
if (colorButton.hue !== value)
if (colorButton.hue !== value && !colorButton.block) {
colorButton.hue = value
colorButton.clicked()
}
}
}
}
......@@ -317,8 +329,10 @@ Item {
minimumValue: 0
maximumValue: 1
onValueChanged: {
if (colorButton.saturation !== value)
if (colorButton.saturation !== value && !colorButton.block) {
colorButton.saturation = value
colorButton.clicked()
}
}
}
}
......@@ -341,8 +355,10 @@ Item {
minimumValue: 0
maximumValue: 1
onValueChanged: {
if (colorButton.lightness !== value)
if (colorButton.lightness !== value && !colorButton.block) {
colorButton.lightness = value
colorButton.clicked()
}
}
}
}
......@@ -366,8 +382,10 @@ Item {
minimumValue: 0
maximumValue: 1
onValueChanged: {
if (colorButton.alpha !== value)
if (colorButton.alpha !== value && !colorButton.block) {
colorButton.alpha = value
colorButton.clicked()
}
}
}
}
......
......@@ -37,7 +37,7 @@ Column {
width: parent.width - 8
property alias color: colorButton.color
property color color
property bool supportGradient: false
......@@ -183,6 +183,7 @@ Column {
}
ColorButton {
color: colorEditor.color
enabled: buttonRow.checkedIndex !== 2
opacity: checkButton.checked ? 1 : 0
id: colorButton
......@@ -194,6 +195,7 @@ Column {
sliderMargins: Math.max(0, label.width - colorButton.width) + 4
onClicked: colorEditor.color = colorButton.color
}
SecondColumnLayout {
......
......@@ -51,6 +51,8 @@ Item {
property Component trackDelegate
property string handleSource: "images/slider_handle.png"
signal clicked
width: 20
height: 100
......@@ -132,6 +134,8 @@ Item {
value = colorSlider.integer ? Math.round(realValue) : realValue;
}
onReleased: colorSlider.clicked()
onPositionChanged: {
if (pressed) {
var handleY = Math.max(0, Math.min(mouseY, mouseArea.height))
......
Supports Markdown
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