diff --git a/qad/widgets/scroll_spin_box.cpp b/qad/widgets/scroll_spin_box.cpp index ca5e87f..e1ff155 100644 --- a/qad/widgets/scroll_spin_box.cpp +++ b/qad/widgets/scroll_spin_box.cpp @@ -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); +} diff --git a/qad/widgets/scroll_spin_box.h b/qad/widgets/scroll_spin_box.h index b87fa89..16f010c 100644 --- a/qad/widgets/scroll_spin_box.h +++ b/qad/widgets/scroll_spin_box.h @@ -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); };