EvalSpinBox::singleStep property

This commit is contained in:
2023-04-18 14:06:21 +03:00
parent 0497a52704
commit 2f630435bb
3 changed files with 19 additions and 17 deletions

View File

@@ -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)

View File

@@ -23,7 +23,6 @@ EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
cw = new QWidget(lineEdit());
label = new QLabel(lineEdit());
eval = new QPIEvaluator();
precision_ = -1;
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,7 +288,7 @@ 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()
#else
@@ -299,7 +296,8 @@ void EvalSpinBox::wheelEvent(QWheelEvent * event) {
#endif
> 0
? 0.1
: -0.1);
: -0.1) *
m_singleStep);
} else {
QAbstractSpinBox::wheelEvent(event);
}

View File

@@ -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