QskSpinBox bugs fixed, QskSpinBox::wrapping mode implemented
This commit is contained in:
parent
28432446e6
commit
55d6aa6d5e
@ -64,6 +64,7 @@ namespace
|
||||
|
||||
{
|
||||
auto spinBox = new QskSpinBox( this );
|
||||
spinBox->setPageSize( 10 );
|
||||
spinBox->setDecoration( QskSpinBox::NoDecoration );
|
||||
spinBox->setValue( 50 );
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "QskSpinBox.h"
|
||||
#include "QskEvent.h"
|
||||
#include "QskFunctions.h"
|
||||
|
||||
#include <qbasictimer.h>
|
||||
#include <qlocale.h>
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user