diff --git a/examples/gallery/inputs/InputPage.cpp b/examples/gallery/inputs/InputPage.cpp index bb8b2685..4dce94e7 100644 --- a/examples/gallery/inputs/InputPage.cpp +++ b/examples/gallery/inputs/InputPage.cpp @@ -64,6 +64,7 @@ namespace { auto spinBox = new QskSpinBox( this ); + spinBox->setPageSize( 10 ); spinBox->setDecoration( QskSpinBox::NoDecoration ); spinBox->setValue( 50 ); } diff --git a/src/controls/QskSpinBox.cpp b/src/controls/QskSpinBox.cpp index 710a1664..3789b055 100644 --- a/src/controls/QskSpinBox.cpp +++ b/src/controls/QskSpinBox.cpp @@ -5,6 +5,7 @@ #include "QskSpinBox.h" #include "QskEvent.h" +#include "QskFunctions.h" #include #include @@ -244,6 +245,28 @@ QString QskSpinBox::textFromValue( qreal value ) const return locale().toString( value, 'f', m_data->decimals ); } +void QskSpinBox::increment( qreal offset ) +{ + if ( m_data->wrapping ) + { + const auto v = value(); + + if ( offset > 0.0 && qskFuzzyCompare( v, maximum() ) ) + { + setValue( minimum() ); + return; + } + + if ( offset < 0.0 && qskFuzzyCompare( v, minimum() ) ) + { + setValue( maximum() ); + return; + } + } + + Inherited::increment( offset ); +} + void QskSpinBox::mousePressEvent( QMouseEvent* event ) { if ( !isReadOnly() ) @@ -252,13 +275,15 @@ void QskSpinBox::mousePressEvent( QMouseEvent* event ) { if ( !m_data->repeatTimer.isActive() ) { - auto increment = ( event->modifiers() == Qt::ControlModifier ) - ? stepSize() : pageSize(); + auto offset = stepSize(); + if ( event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ) ) + offset *= pageSize(); if ( subcontrol == QskSpinBox::DownPanel ) - increment = -increment; + offset = -offset; - m_data->setAutoRepeat( this, increment ); + increment( offset ); + m_data->setAutoRepeat( this, offset ); } return; } diff --git a/src/controls/QskSpinBox.h b/src/controls/QskSpinBox.h index 84998180..3f09e337 100644 --- a/src/controls/QskSpinBox.h +++ b/src/controls/QskSpinBox.h @@ -78,6 +78,8 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput QString text() const; virtual QString textFromValue( qreal ) const; + void increment( qreal ) override; + Q_SIGNALS: void decorationChanged( Decoration ); void textAlignmentChanged( Qt::Alignment );