Commit 7d585966 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] - hopefully fixed a bug causing accidentaly called slider update to...

[FIX] - hopefully fixed a bug causing accidentaly called slider update to modify the property which is not allowed here.
parent 66396a02
......@@ -66,44 +66,32 @@ WPropertyDoubleWidget::~WPropertyDoubleWidget()
void WPropertyDoubleWidget::update()
{
// get the min constraint
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// NO, it doesn't work on Mac OS X: You won't be able to any digits in it!, So I reset it to default which should work on other platforms too
QString valStr = QString::number( m_doubleProperty->get() );
m_edit.setText( valStr );
// get the min constraint
WPVDouble::PropertyConstraintMin minC = m_doubleProperty->getMin();
m_min = 0;
if ( minC.get() )
WPVDouble::PropertyConstraintMax maxC = m_doubleProperty->getMax();
bool minMaxConstrained = minC && maxC;
if ( minMaxConstrained )
{
m_slider.setHidden( false );
// setup the slider
m_slider.setMinimum( 0 );
m_slider.setMaximum( 100 );
m_min = minC->getMin();
}
else
{
m_slider.setHidden( true );
}
m_max = maxC->getMax();
// get the max constraint
WPVDouble::PropertyConstraintMax maxC = m_doubleProperty->getMax();
m_max = 100;
if ( maxC.get() )
{
m_slider.setHidden( false );
m_max = maxC->getMax();
m_slider.setValue( toPercent( m_doubleProperty->get() ) );
}
else
{
m_slider.setHidden( true );
}
// setup the slider
m_slider.setMinimum( 0 );
m_slider.setMaximum( 100 );
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// NO, it doesn't work on Mac OS X: You won't be able to any digits in it!, So I reset it to default which should work on other platforms too
QString valStr = QString::number( m_doubleProperty->get() );
m_edit.setText( valStr );
m_slider.setValue( toPercent( m_doubleProperty->get() ) );
// do not forget to update the label
m_asText.setText( valStr );
}
......@@ -120,11 +108,14 @@ double WPropertyDoubleWidget::fromPercent( int perc )
void WPropertyDoubleWidget::sliderChanged( int value )
{
// set to the property
invalidate( !m_doubleProperty->set( fromPercent( value ) ) ); // NOTE: set automatically checks the validity of the value
if ( !m_slider.isHidden() )
{
// set to the property
invalidate( !m_doubleProperty->set( fromPercent( value ) ) ); // NOTE: set automatically checks the validity of the value
// set the value in the line edit
m_edit.setText( QString::number( m_doubleProperty->get() ) );
// set the value in the line edit
m_edit.setText( QString::number( m_doubleProperty->get() ) );
}
}
void WPropertyDoubleWidget::editChanged()
......
......@@ -67,56 +67,44 @@ WPropertyIntWidget::~WPropertyIntWidget()
void WPropertyIntWidget::update()
{
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// Same as in WPropertyDouble.cpp: This does not work as expected on Mac OS X => reset to default
// set the initial values
QString valStr = QString::number( m_intProperty->get() );
m_edit.setText( valStr );
// get the min constraint
WPVInt::PropertyConstraintMin minC = m_intProperty->getMin();
int min = 0;
if ( minC.get() )
{
m_slider.setHidden( false );
min = minC->getMin();
}
else
{
m_slider.setHidden( true );
}
// get the max constraint
WPVInt::PropertyConstraintMax maxC = m_intProperty->getMax();
int max = 100;
if ( maxC.get() )
bool minMaxConstrained = minC && maxC;
if ( minMaxConstrained )
{
m_slider.setHidden( false );
max = maxC->getMax();
m_slider.setMinimum( minC->getMin() );
m_slider.setMaximum( maxC->getMax() );
m_slider.setValue( m_intProperty->get() );
}
else
{
m_slider.setHidden( true );
}
// setup the slider
m_slider.setMinimum( min );
m_slider.setMaximum( max );
// // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// Same as in WPropertyDouble.cpp: This does not work as expected on Mac OS X => reset to default
// set the initial values
QString valStr = QString::number( m_intProperty->get() );
m_edit.setText( valStr );
m_slider.setValue( m_intProperty->get() );
// do not forget to update the label
m_asText.setText( valStr );
}
void WPropertyIntWidget::sliderChanged( int value )
{
// set the value in the line edit
m_edit.setText( QString::number( value ) );
if ( !m_slider.isHidden() )
{
// set the value in the line edit
m_edit.setText( QString::number( value ) );
// set to the property
invalidate( !m_intProperty->set( value ) ); // NOTE: set automatically checks the validity of the value
// set to the property
invalidate( !m_intProperty->set( value ) ); // NOTE: set automatically checks the validity of the value
}
}
void WPropertyIntWidget::editChanged()
......
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