QskSpinBox::text property moved to QskBoundedValueInput::valueText
This commit is contained in:
parent
feea806745
commit
089f0c3abe
@ -6,6 +6,8 @@
|
||||
#include "QskBoundedValueInput.h"
|
||||
#include "QskFunctions.h"
|
||||
|
||||
#include <qlocale.h>
|
||||
|
||||
QskBoundedValueInput::QskBoundedValueInput( QQuickItem* parent )
|
||||
: QskBoundedInput( parent )
|
||||
{
|
||||
@ -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"
|
||||
|
@ -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:
|
||||
@ -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;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "QskFunctions.h"
|
||||
|
||||
#include <qbasictimer.h>
|
||||
#include <qlocale.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
@ -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 )
|
||||
@ -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 );
|
||||
|
@ -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 )
|
||||
@ -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;
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user