EvalSpinBox::singleStep property
This commit is contained in:
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
||||||
project(QAD)
|
project(QAD)
|
||||||
set(QAD_MAJOR 2)
|
set(QAD_MAJOR 2)
|
||||||
set(QAD_MINOR 15)
|
set(QAD_MINOR 16)
|
||||||
set(QAD_REVISION 0)
|
set(QAD_REVISION 0)
|
||||||
set(QAD_SUFFIX )
|
set(QAD_SUFFIX )
|
||||||
set(QAD_COMPANY SHS)
|
set(QAD_COMPANY SHS)
|
||||||
|
|||||||
@@ -19,11 +19,10 @@
|
|||||||
|
|
||||||
|
|
||||||
EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
|
EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
|
||||||
status = new QWidget(lineEdit());
|
status = new QWidget(lineEdit());
|
||||||
cw = new QWidget(lineEdit());
|
cw = new QWidget(lineEdit());
|
||||||
label = new QLabel(lineEdit());
|
label = new QLabel(lineEdit());
|
||||||
eval = new QPIEvaluator();
|
eval = new QPIEvaluator();
|
||||||
precision_ = -1;
|
|
||||||
clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
|
clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
|
||||||
icon_ok.load(":/icons/dialog-ok-apply.png");
|
icon_ok.load(":/icons/dialog-ok-apply.png");
|
||||||
icon_fail.load(":/icons/dialog-warning.png");
|
icon_fail.load(":/icons/dialog-warning.png");
|
||||||
@@ -35,8 +34,6 @@ EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
|
|||||||
cw->setCursor(Qt::ArrowCursor);
|
cw->setCursor(Qt::ArrowCursor);
|
||||||
cw->setToolTip(tr("Clear"));
|
cw->setToolTip(tr("Clear"));
|
||||||
cw->hide();
|
cw->hide();
|
||||||
cw_visible = false;
|
|
||||||
calc_visible = true;
|
|
||||||
cw->installEventFilter(this);
|
cw->installEventFilter(this);
|
||||||
status->installEventFilter(this);
|
status->installEventFilter(this);
|
||||||
connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
|
connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
|
||||||
@@ -212,7 +209,7 @@ void EvalSpinBox::setValue(double val) {
|
|||||||
|
|
||||||
|
|
||||||
void EvalSpinBox::stepBy(int steps) {
|
void EvalSpinBox::stepBy(int steps) {
|
||||||
stepByDouble(steps);
|
stepByDouble(steps * m_singleStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -291,15 +288,16 @@ void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
|
|||||||
|
|
||||||
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
||||||
if (event->modifiers().testFlag(Qt::ShiftModifier)) {
|
if (event->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||||
stepByDouble(
|
stepByDouble((
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
event->delta()
|
event->delta()
|
||||||
#else
|
#else
|
||||||
event->angleDelta().y()
|
event->angleDelta().y()
|
||||||
#endif
|
#endif
|
||||||
> 0
|
> 0
|
||||||
? 0.1
|
? 0.1
|
||||||
: -0.1);
|
: -0.1) *
|
||||||
|
m_singleStep);
|
||||||
} else {
|
} else {
|
||||||
QAbstractSpinBox::wheelEvent(event);
|
QAbstractSpinBox::wheelEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class QAD_WIDGETS_EXPORT EvalSpinBox: public QAbstractSpinBox {
|
|||||||
Q_PROPERTY(bool clearButtonVisible READ isClearButtonVisible WRITE setClearButtonVisible)
|
Q_PROPERTY(bool clearButtonVisible READ isClearButtonVisible WRITE setClearButtonVisible)
|
||||||
Q_PROPERTY(bool calculationVisible READ isCalculationVisible WRITE setCalculationVisible)
|
Q_PROPERTY(bool calculationVisible READ isCalculationVisible WRITE setCalculationVisible)
|
||||||
Q_PROPERTY(int precision READ precision WRITE setPrecision)
|
Q_PROPERTY(int precision READ precision WRITE setPrecision)
|
||||||
|
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EvalSpinBox(QWidget * parent = nullptr);
|
explicit EvalSpinBox(QWidget * parent = nullptr);
|
||||||
@@ -49,6 +50,7 @@ public:
|
|||||||
bool isCalculationVisible() const { return calc_visible; }
|
bool isCalculationVisible() const { return calc_visible; }
|
||||||
bool isCleared() const;
|
bool isCleared() const;
|
||||||
int precision() const { return precision_; }
|
int precision() const { return precision_; }
|
||||||
|
double singleStep() const { return m_singleStep; }
|
||||||
|
|
||||||
void stepBy(int steps) override;
|
void stepBy(int steps) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
@@ -61,6 +63,7 @@ public slots:
|
|||||||
void setClearButtonVisible(bool visible);
|
void setClearButtonVisible(bool visible);
|
||||||
void setCalculationVisible(bool visible);
|
void setCalculationVisible(bool visible);
|
||||||
void setPrecision(int precision) { precision_ = precision; }
|
void setPrecision(int precision) { precision_ = precision; }
|
||||||
|
void setSingleStep(double step) { m_singleStep = step; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString text() const { return QAbstractSpinBox::text(); }
|
QString text() const { return QAbstractSpinBox::text(); }
|
||||||
@@ -99,8 +102,9 @@ private:
|
|||||||
QImage icon;
|
QImage icon;
|
||||||
QImage clear_im;
|
QImage clear_im;
|
||||||
QString dt;
|
QString dt;
|
||||||
bool cw_visible, calc_visible;
|
bool cw_visible = false, calc_visible = true;
|
||||||
int precision_;
|
int precision_ = -1;
|
||||||
|
double m_singleStep = 1.;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EVALSPINBOX_H
|
#endif // EVALSPINBOX_H
|
||||||
|
|||||||
Reference in New Issue
Block a user