Merge branch 'master' into features/slider
This commit is contained in:
commit
e3b87338c0
|
@ -97,7 +97,7 @@ InputPage::InputPage( QQuickItem* parent )
|
|||
struct
|
||||
{
|
||||
Slider* continous;
|
||||
Slider* descrete;
|
||||
Slider* discrete;
|
||||
} sliders[2];
|
||||
|
||||
for ( int i = 0; i < 2; i++ )
|
||||
|
@ -105,7 +105,7 @@ InputPage::InputPage( QQuickItem* parent )
|
|||
const auto orientation = static_cast< Qt::Orientation >( i + 1 );
|
||||
|
||||
sliders[i].continous = new Slider( orientation, Slider::Continous );
|
||||
sliders[i].descrete = new Slider( orientation, Slider::Discrete );
|
||||
sliders[i].discrete = new Slider( orientation, Slider::Discrete );
|
||||
}
|
||||
|
||||
auto spinBox = new QskSpinBox( 0.0, 100.0, 1.0 );
|
||||
|
@ -119,14 +119,14 @@ InputPage::InputPage( QQuickItem* parent )
|
|||
vBox->setExtraSpacingAt( Qt::RightEdge | Qt::BottomEdge );
|
||||
|
||||
vBox->addItem( sliders[0].continous );
|
||||
vBox->addItem( sliders[0].descrete );
|
||||
vBox->addItem( sliders[0].discrete );
|
||||
vBox->addItem( inputBox );
|
||||
vBox->addItem( spinBox );
|
||||
|
||||
auto mainBox = new QskLinearBox( Qt::Horizontal, this );
|
||||
mainBox->setSpacing( 30 );
|
||||
mainBox->addItem( sliders[1].continous );
|
||||
mainBox->addItem( sliders[1].descrete );
|
||||
mainBox->addItem( sliders[1].discrete );
|
||||
mainBox->addItem( vBox );
|
||||
|
||||
auto inputs = findChildren< QskBoundedValueInput* >();
|
||||
|
@ -136,6 +136,8 @@ InputPage::InputPage( QQuickItem* parent )
|
|||
connect( input, &QskBoundedValueInput::valueChanged,
|
||||
this, &InputPage::syncValues );
|
||||
}
|
||||
|
||||
spinBox->setValue( 30.0 );
|
||||
}
|
||||
|
||||
void InputPage::syncValues( qreal value )
|
||||
|
|
|
@ -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…
Reference in New Issue