Michaël Lemaire
b7e4be1030
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@373 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#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);
|
|
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
|
_control = _slider;
|
|
}
|
|
|
|
void InputInt::updatePreview()
|
|
{
|
|
((QLabel*)_preview)->setText(QString("%1").arg(*_value));
|
|
|
|
BaseInput::updatePreview();
|
|
}
|
|
|
|
void InputInt::applyValue()
|
|
{
|
|
*_value = (int)_slider->value();
|
|
|
|
BaseInput::applyValue();
|
|
}
|
|
|
|
void InputInt::revert()
|
|
{
|
|
if (*_value != _slider->value())
|
|
{
|
|
_slider->setValue(*_value);
|
|
}
|
|
|
|
BaseInput::revert();
|
|
}
|