Skip to content

Commit

Permalink
QskSpinBox::text property moved to QskBoundedValueInput::valueText
Browse files Browse the repository at this point in the history
  • Loading branch information
uwerat committed Oct 23, 2024
1 parent feea806 commit 089f0c3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
12 changes: 12 additions & 0 deletions src/controls/QskBoundedValueInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "QskBoundedValueInput.h"
#include "QskFunctions.h"

#include <qlocale.h>

QskBoundedValueInput::QskBoundedValueInput( QQuickItem* parent )
: QskBoundedInput( parent )
{
Expand Down Expand Up @@ -71,4 +73,14 @@ void QskBoundedValueInput::setValueInternal( qreal value )
}
}

QString QskBoundedValueInput::valueText() const
{
return textFromValue( value() );
}

QString QskBoundedValueInput::textFromValue( qreal value ) const
{
return locale().toString( value );
}

#include "moc_QskBoundedValueInput.cpp"
11 changes: 8 additions & 3 deletions src/controls/QskBoundedValueInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class QSK_EXPORT QskBoundedValueInput : public QskBoundedInput
Q_PROPERTY( qreal valueAsRatio READ valueAsRatio
WRITE setValueAsRatio NOTIFY valueChanged )

Q_PROPERTY( QString valueText READ valueText NOTIFY valueChanged )

using Inherited = QskBoundedInput;

public:
Expand All @@ -30,20 +32,23 @@ class QSK_EXPORT QskBoundedValueInput : public QskBoundedInput
qreal valueAsRatio() const;
using QskBoundedInput::valueAsRatio;

QString valueText() const;
virtual QString textFromValue( qreal ) const;

public Q_SLOTS:
void setValue( qreal );
void setValueAsRatio( qreal );
void increment( qreal offset ) override;
void increment( qreal ) override;

Q_SIGNALS:
void valueChanged( qreal );

protected:
virtual qreal fixupValue( qreal value ) const;
virtual qreal fixupValue( qreal ) const;
void alignInput() override;

private:
void setValueInternal( qreal value );
void setValueInternal( qreal );
void adjustValue();

qreal m_value = 0.0;
Expand Down
8 changes: 0 additions & 8 deletions src/controls/QskSpinBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "QskFunctions.h"

#include <qbasictimer.h>
#include <qlocale.h>

#include <cfloat>

Expand Down Expand Up @@ -143,8 +142,6 @@ QskSpinBox::QskSpinBox( qreal min, qreal max, qreal stepSize, QQuickItem* parent

setAcceptedMouseButtons( Qt::LeftButton );
setFocusPolicy( Qt::StrongFocus );

connect( this, &QskSpinBox::valueChanged, this, &QskSpinBox::textChanged );
}

QskSpinBox::QskSpinBox( QQuickItem* parent )
Expand Down Expand Up @@ -204,11 +201,6 @@ int QskSpinBox::decimals() const
return m_data->decimals;
}

QString QskSpinBox::text() const
{
return textFromValue( value() );
}

QString QskSpinBox::textFromValue( qreal value ) const
{
return locale().toString( value, 'f', m_data->decimals );
Expand Down
5 changes: 1 addition & 4 deletions src/controls/QskSpinBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
Q_PROPERTY( int decimals READ decimals
WRITE setDecimals NOTIFY decimalsChanged )

Q_PROPERTY( QString text READ text NOTIFY textChanged )

public:
QSK_SUBCONTROLS( Panel, TextPanel, Text,
UpPanel, UpIndicator, DownPanel, DownIndicator )
Expand Down Expand Up @@ -56,8 +54,7 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
void setDecimals( int );
int decimals() const;

QString text() const;
virtual QString textFromValue( qreal ) const;
virtual QString textFromValue( qreal ) const override;

void increment( qreal ) override;

Expand Down
2 changes: 1 addition & 1 deletion src/controls/QskSpinBoxSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ QSGNode* QskSpinBoxSkinlet::updateSubNode(
case TextRole:
{
auto spinBox = static_cast< const QskSpinBox* >( skinnable );
return updateTextNode( spinBox, node, spinBox->text(), Q::Text );
return updateTextNode( spinBox, node, spinBox->valueText(), Q::Text );
}
}

Expand Down

0 comments on commit 089f0c3

Please sign in to comment.