QskBoundedInput::incrementForKeys added
This commit is contained in:
parent
7f24cbb95b
commit
06704511d2
|
@ -177,21 +177,42 @@ bool QskBoundedInput::isReadOnly() const
|
||||||
return hasSkinState( ReadOnly );
|
return hasSkinState( ReadOnly );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal QskBoundedInput::incrementForKey( const QKeyEvent* event ) const
|
||||||
|
{
|
||||||
|
switch( event->key() )
|
||||||
|
{
|
||||||
|
case Qt::Key_Up:
|
||||||
|
return m_stepSize;
|
||||||
|
|
||||||
|
case Qt::Key_Down:
|
||||||
|
return -m_stepSize;
|
||||||
|
|
||||||
|
case Qt::Key_PageUp:
|
||||||
|
return m_pageSize;
|
||||||
|
|
||||||
|
case Qt::Key_PageDown:
|
||||||
|
return -m_pageSize;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if ( qskIsStandardKeyInput( event, QKeySequence::MoveToNextChar ) )
|
||||||
|
return m_stepSize;
|
||||||
|
|
||||||
|
if ( qskIsStandardKeyInput( event, QKeySequence::MoveToPreviousChar ) )
|
||||||
|
return -m_stepSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
void QskBoundedInput::keyPressEvent( QKeyEvent* event )
|
void QskBoundedInput::keyPressEvent( QKeyEvent* event )
|
||||||
{
|
{
|
||||||
if ( !isReadOnly() )
|
if ( !isReadOnly() )
|
||||||
{
|
{
|
||||||
if ( event->key() == Qt::Key_Up ||
|
if ( const auto offset = incrementForKey( event ) )
|
||||||
qskIsStandardKeyInput( event, QKeySequence::MoveToNextChar ) )
|
|
||||||
{
|
{
|
||||||
increment( m_stepSize );
|
increment( offset );
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( event->key() == Qt::Key_Down ||
|
|
||||||
qskIsStandardKeyInput( event, QKeySequence::MoveToPreviousChar ) )
|
|
||||||
{
|
|
||||||
increment( -m_stepSize );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ class QSK_EXPORT QskBoundedInput : public QskBoundedControl
|
||||||
qreal alignedValue( qreal ) const;
|
qreal alignedValue( qreal ) const;
|
||||||
QskIntervalF alignedInterval( const QskIntervalF& ) const;
|
QskIntervalF alignedInterval( const QskIntervalF& ) const;
|
||||||
|
|
||||||
|
qreal incrementForKey( const QKeyEvent* ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_stepSize = 0.1;
|
qreal m_stepSize = 0.1;
|
||||||
int m_pageSize = 1;
|
int m_pageSize = 1;
|
||||||
|
|
|
@ -12,7 +12,9 @@ class QSK_EXPORT QskBoundedValueInput : public QskBoundedInput
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY( qreal value READ value WRITE setValue NOTIFY valueChanged )
|
Q_PROPERTY( qreal value READ value
|
||||||
|
WRITE setValue NOTIFY valueChanged )
|
||||||
|
|
||||||
Q_PROPERTY( qreal valueAsRatio READ valueAsRatio
|
Q_PROPERTY( qreal valueAsRatio READ valueAsRatio
|
||||||
WRITE setValueAsRatio NOTIFY valueChanged )
|
WRITE setValueAsRatio NOTIFY valueChanged )
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ class QSK_EXPORT QskSlider : public QskBoundedValueInput
|
||||||
Q_PROPERTY( Qt::Orientation orientation READ orientation
|
Q_PROPERTY( Qt::Orientation orientation READ orientation
|
||||||
WRITE setOrientation NOTIFY orientationChanged )
|
WRITE setOrientation NOTIFY orientationChanged )
|
||||||
|
|
||||||
Q_PROPERTY( bool tracking READ isTracking WRITE setTracking NOTIFY trackingChanged )
|
Q_PROPERTY( bool tracking READ isTracking
|
||||||
|
WRITE setTracking NOTIFY trackingChanged )
|
||||||
|
|
||||||
Q_PROPERTY( qreal handlePosition READ handlePosition )
|
Q_PROPERTY( qreal handlePosition READ handlePosition )
|
||||||
|
|
||||||
using Inherited = QskBoundedValueInput;
|
using Inherited = QskBoundedValueInput;
|
||||||
|
|
Loading…
Reference in New Issue