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