Commit a10c9e99 authored by Jasper Hartog's avatar Jasper Hartog Committed by Boudewijn Rempt

Fix comparison of double spin box

When the value of a QDoubleSpinBox is changed it will be round down to the amount of decimals that are assigned to that spin box. The KisDoubleParseSpinBox would check the new unrounded value with the current rounded value, which resulted in an incorrect comparison.

(cherry picked from commit 8bc2965d)
parent 6ce046bd
......@@ -330,6 +330,7 @@ void KisFloatColorInput::update()
qreal value = 1.0;
m_minValue = m_displayRenderer->minVisibleFloatValue(m_channelInfo);
m_maxValue = m_displayRenderer->maxVisibleFloatValue(m_channelInfo);
m_dblNumInput->blockSignals(true);
m_colorSlider->blockSignals(true);
switch (m_channelInfo->channelValueType()) {
......@@ -362,11 +363,13 @@ void KisFloatColorInput::update()
m_dblNumInput->setDecimals(newPrecision);
m_dblNumInput->updateGeometry();
}
m_dblNumInput->setValue(value);
m_colorSlider->setColors(min, max);
const qreal floatRange = m_maxValue - m_minValue;
m_colorSlider->setValue((value - m_minValue) / floatRange * 255);
m_dblNumInput->blockSignals(false);
m_colorSlider->blockSignals(false);
}
......
......@@ -158,7 +158,8 @@ void KisDoubleParseSpinBox::stepBy(int steps)
void KisDoubleParseSpinBox::setValue(double value)
{
if(value == oldValue && hasFocus()){ //avoid to reset the button when it set the value of something that will recall this slot.
// Avoid to reset the button when it set the val of something that will recall this slot.
if(hasFocus() && QString::number( value, 'f', this->decimals()) == QString::number( oldValue, 'f', this->decimals())){
return;
}
......
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