2012-01-06 16:09:03 +00:00
|
|
|
#include "inputint.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step):
|
2012-07-04 09:50:06 +00:00
|
|
|
BaseInput(form, label)
|
2012-01-06 16:09:03 +00:00
|
|
|
{
|
2012-07-04 09:50:06 +00:00
|
|
|
_value = value;
|
|
|
|
_min = min;
|
|
|
|
_max = max;
|
|
|
|
_small_step = small_step;
|
|
|
|
_large_step = large_step;
|
|
|
|
|
|
|
|
_slider = new QSlider(form);
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-07-04 09:50:06 +00:00
|
|
|
_slider->setOrientation(Qt::Horizontal);
|
|
|
|
_slider->setMinimumWidth(150);
|
|
|
|
_slider->setMaximumWidth(400);
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-07-04 09:50:06 +00:00
|
|
|
_slider->setMinimum(min);
|
|
|
|
_slider->setMaximum(max);
|
|
|
|
_slider->setValue(*value);
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-07-04 09:50:06 +00:00
|
|
|
_slider->setTickInterval(large_step);
|
|
|
|
_slider->setTickPosition(QSlider::TicksBelow);
|
2012-01-06 16:09:03 +00:00
|
|
|
|
2012-07-04 09:50:06 +00:00
|
|
|
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
2012-01-06 16:09:03 +00:00
|
|
|
|
|
|
|
_preview = new QLabel(form);
|
2012-06-05 20:22:12 +00:00
|
|
|
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
2012-07-04 09:50:06 +00:00
|
|
|
_control = _slider;
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|
|
|
|
|
2012-01-08 10:31:01 +00:00
|
|
|
void InputInt::updatePreview()
|
|
|
|
{
|
2012-07-04 09:50:06 +00:00
|
|
|
((QLabel*)_preview)->setText(QString("%1").arg(*_value));
|
2012-01-08 10:31:01 +00:00
|
|
|
|
|
|
|
BaseInput::updatePreview();
|
|
|
|
}
|
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
void InputInt::applyValue()
|
|
|
|
{
|
2012-07-04 09:50:06 +00:00
|
|
|
*_value = (int)_slider->value();
|
2012-01-06 16:09:03 +00:00
|
|
|
|
|
|
|
BaseInput::applyValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputInt::revert()
|
|
|
|
{
|
2012-07-04 09:50:06 +00:00
|
|
|
if (*_value != _slider->value())
|
|
|
|
{
|
|
|
|
_slider->setValue(*_value);
|
|
|
|
}
|
2012-01-08 10:31:01 +00:00
|
|
|
|
2012-06-23 21:47:12 +00:00
|
|
|
BaseInput::revert();
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|