#include "settingform.h"

SettingForm::SettingForm( QWidget *parent ) : QWidget( parent )
{
  QGridLayout *gLayout = new QGridLayout( this );

  QLCDNumber *lcd = new QLCDNumber( 2 );
  gLayout->addWidget( lcd, 0, 0 );
  slider = new QSlider( Qt::Horizontal );
  gLayout->addWidget( slider, 0, 1, 1, 2 );
  connect( slider, SIGNAL( valueChanged( int ) ), lcd, SLOT( display( int ) ) );
  connect( slider, SIGNAL( valueChanged( int ) ), this, SIGNAL( sliderValueChanged( int ) ) );
}

void SettingForm::setSlider( int sMin, int sMax, int startValue )
{
  slider->setRange( sMin, sMax );
  slider->setValue( startValue );
}

void SettingForm::setSliderRange(int sMin, int sMax)
{
  if( sMin > sMax ) setSliderRange( sMax, sMin );
  slider->setRange( sMin, sMax );
}

void SettingForm::setCurrentValue( int value )
{
  if( value > slider->maximum() || value < slider->minimum() )
    return;
  slider->setValue( value );
}

int SettingForm::sliderValue( void )
{
  return slider->value();
}
