From 890ae646527bd8b3c931e9f3d3e0c81d644779b3 Mon Sep 17 00:00:00 2001 From: "Vogel, Rick" Date: Fri, 17 Feb 2023 14:57:33 +0100 Subject: [PATCH] using QskBoundedValueInput as base class --- src/controls/QskSpinBox.cpp | 26 -------------------------- src/controls/QskSpinBox.h | 12 +++--------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/controls/QskSpinBox.cpp b/src/controls/QskSpinBox.cpp index 7ba306e1..3eabea92 100644 --- a/src/controls/QskSpinBox.cpp +++ b/src/controls/QskSpinBox.cpp @@ -45,19 +45,6 @@ public: { } - void setValue(qreal value) - { - value = qBound(q->minimum(), value, q->maximum()); - if(!qFuzzyCompare(m_value, value)) - { - m_value = value; - Q_EMIT q->valueChanged(m_value); - q->update(); - } - } - - qreal value() const { return m_value; } - FocusIndeces defaultFocusIndex() const { const auto layout = q->alignmentHint(QskSpinBox::Layout); @@ -170,7 +157,6 @@ public: } private: - qreal m_value{0.0f}; QskSpinBox* const q; FocusIndeces m_focusIndex = FocusIndeces::None; }; @@ -187,8 +173,6 @@ QskSpinBox::QskSpinBox(QQuickItem* const parent) setFocusPolicy( Qt::StrongFocus ); connect( this, &S::focusIndexChanged, this, &S::focusIndicatorRectChanged ); - connect( this, &S::boundariesChanged, this, [this](const QskIntervalF& interval){ if(!interval.contains(value())) m_data->setValue(minimum()); }); - connect( this, &S::valueChanged, this, [this](){ polish(); }); } QskSpinBox::~QskSpinBox() = default; @@ -364,16 +348,6 @@ QRectF QskSpinBox::focusIndicatorRect() const return rect; } -void QskSpinBox::increment(qreal offset) -{ - m_data->setValue(m_data->value() + offset); -} - -qreal QskSpinBox::value() const -{ - return m_data->value(); -} - QskSpinBox::FocusIndeces QskSpinBox::focusIndex() const { return m_data->focusIndex(); diff --git a/src/controls/QskSpinBox.h b/src/controls/QskSpinBox.h index d59a8d7c..2d4e7efd 100644 --- a/src/controls/QskSpinBox.h +++ b/src/controls/QskSpinBox.h @@ -7,31 +7,25 @@ #include #include -#include +#include -class QSK_EXPORT QskSpinBox : public QskBoundedInput +class QSK_EXPORT QskSpinBox : public QskBoundedValueInput { Q_OBJECT - using Inherited = QskBoundedInput; + using Inherited = QskBoundedValueInput; public: enum FocusIndeces : int { Decrement = 0, Textbox = 1, Increment = 2, None = 3 }; Q_ENUM(FocusIndeces) - Q_PROPERTY(qreal value READ value NOTIFY valueChanged) Q_PROPERTY(FocusIndeces focusIndex READ focusIndex NOTIFY focusIndexChanged) QSK_SUBCONTROLS(IncrementPanel, DecrementPanel, IncrementText, DecrementText, TextPanel, Text, Layout) QSK_STATES( Pressed ) explicit QskSpinBox( QQuickItem* parent = nullptr ); ~QskSpinBox() override; - - void increment( qreal offset ) override; - qreal value() const; - FocusIndeces focusIndex() const; Q_SIGNALS: - void valueChanged(qreal value); void focusIndexChanged(int index); private: