git-svn-id: svn://db.shs.com.ru/libs@648 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -32,6 +32,7 @@ ScrollSpinBox::ScrollSpinBox(QWidget * parent): QWidget(parent) {
|
||||
ui->setupUi(this);
|
||||
ui->spin->setPrecision(3);
|
||||
ui->handle->installEventFilter(this);
|
||||
connect(ui->spin, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
|
||||
last_value = 0.;
|
||||
sensivity_ = 0.2;
|
||||
scroll_scale = sensivity_ / 10;
|
||||
@@ -44,6 +45,11 @@ EvalSpinBox * ScrollSpinBox::spin() {
|
||||
}
|
||||
|
||||
|
||||
double ScrollSpinBox::value() const {
|
||||
return ui->spin->value();
|
||||
}
|
||||
|
||||
|
||||
void ScrollSpinBox::changeEvent(QEvent * e) {
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
@@ -91,7 +97,8 @@ void ScrollSpinBox::mousePress(QMouseEvent * e) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
down_pos = e->pos();
|
||||
last_text = ui->spin->expression();
|
||||
last_value = ui->spin->value();
|
||||
last_value = qAbs(ui->spin->value());
|
||||
if (last_value == 0.) last_value = 1.;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +114,12 @@ void ScrollSpinBox::mouseMove(QMouseEvent * e) {
|
||||
double dv = (down_pos.y() - e->pos().y()) * scroll_scale;
|
||||
if (dv != 0.) {
|
||||
QCursor::setPos(ui->handle->mapToGlobal(down_pos));
|
||||
ui->spin->setValue(ui->spin->value() + qAbs(last_value) * dv);
|
||||
ui->spin->setValue(ui->spin->value() + last_value * dv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScrollSpinBox::setValue(double v) {
|
||||
ui->spin->setValue(v);
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ class ScrollSpinBox: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double sensivity READ sensivity WRITE setSensivity)
|
||||
Q_PROPERTY(double value READ value WRITE setValue)
|
||||
public:
|
||||
explicit ScrollSpinBox(QWidget * parent = 0);
|
||||
|
||||
EvalSpinBox * spin();
|
||||
double value() const;
|
||||
double sensivity() const {return sensivity_;}
|
||||
|
||||
protected:
|
||||
@@ -52,6 +54,10 @@ protected:
|
||||
|
||||
public slots:
|
||||
void setSensivity(double s) {sensivity_ = s;}
|
||||
void setValue(double v);
|
||||
|
||||
signals:
|
||||
void valueChanged(double);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user