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):
|
|
|
|
BaseInput(form, label),
|
|
|
|
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
|
|
|
|
{
|
|
|
|
slider = new QSlider(form);
|
|
|
|
|
|
|
|
slider->setOrientation(Qt::Horizontal);
|
|
|
|
slider->setMinimumWidth(150);
|
|
|
|
slider->setMaximumWidth(400);
|
|
|
|
|
|
|
|
slider->setMinimum(min);
|
|
|
|
slider->setMaximum(max);
|
|
|
|
slider->setValue(*value);
|
|
|
|
|
|
|
|
slider->setTickInterval(large_step);
|
|
|
|
slider->setTickPosition(QSlider::TicksBelow);
|
|
|
|
|
|
|
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
|
|
|
|
|
|
|
_preview = new QLabel(form);
|
2012-06-05 20:22:12 +00:00
|
|
|
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
2012-01-06 16:09:03 +00:00
|
|
|
_control = slider;
|
|
|
|
}
|
|
|
|
|
2012-01-08 10:31:01 +00:00
|
|
|
void InputInt::updatePreview()
|
|
|
|
{
|
|
|
|
((QLabel*)_preview)->setText(QString("%1").arg(*value));
|
|
|
|
|
|
|
|
BaseInput::updatePreview();
|
|
|
|
}
|
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
void InputInt::applyValue()
|
|
|
|
{
|
|
|
|
*value = (int)slider->value();
|
|
|
|
|
|
|
|
BaseInput::applyValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputInt::revert()
|
|
|
|
{
|
|
|
|
slider->setValue(*value);
|
2012-01-08 10:31:01 +00:00
|
|
|
|
|
|
|
BaseInput::revert();
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|