qskinny/src/controls/QskBoundedInput.h

80 lines
1.9 KiB
C
Raw Normal View History

2020-07-25 12:19:14 +00:00
/******************************************************************************
2024-01-17 13:31:45 +00:00
* QSkinny - Copyright (C) The authors
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
2020-07-25 12:19:14 +00:00
*****************************************************************************/
#ifndef QSK_BOUNDED_INPUT_H
#define QSK_BOUNDED_INPUT_H
2020-07-31 05:41:25 +00:00
#include "QskBoundedControl.h"
2020-07-25 12:19:14 +00:00
class QskIntervalF;
2020-07-31 05:41:25 +00:00
class QSK_EXPORT QskBoundedInput : public QskBoundedControl
2020-07-25 12:19:14 +00:00
{
Q_OBJECT
Q_PROPERTY( qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged )
Q_PROPERTY( uint pageSteps READ pageSteps WRITE setPageSteps NOTIFY pageStepsChanged )
2020-07-25 12:19:14 +00:00
Q_PROPERTY( bool snap READ snap WRITE setSnap NOTIFY snapChanged )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
2020-07-31 05:41:25 +00:00
using Inherited = QskBoundedControl;
2020-07-25 12:19:14 +00:00
public:
QSK_STATES( ReadOnly )
QskBoundedInput( QQuickItem* parent = nullptr );
~QskBoundedInput() override;
qreal stepSize() const;
qreal pageSize() const; // pageSteps() * stepSize()
uint pageSteps() const;
2020-07-25 12:19:14 +00:00
void setSnap( bool );
bool snap() const;
void setReadOnly( bool );
bool isReadOnly() const;
public Q_SLOTS:
void setStepSize( qreal );
void setPageSteps( uint );
2020-07-25 12:19:14 +00:00
void stepUp();
void stepDown();
void pageUp();
void pageDown();
virtual void increment( qreal offset ) = 0;
Q_SIGNALS:
void stepSizeChanged( qreal );
void pageStepsChanged( qreal );
2020-07-25 12:19:14 +00:00
void snapChanged( bool );
void readOnlyChanged( bool );
protected:
2021-02-09 11:25:41 +00:00
void keyPressEvent( QKeyEvent* ) override;
2020-07-25 12:19:14 +00:00
#ifndef QT_NO_WHEELEVENT
void wheelEvent( QWheelEvent* ) override;
#endif
void componentComplete() override;
2020-07-29 05:25:35 +00:00
virtual void alignInput();
2020-07-25 12:19:14 +00:00
2020-07-25 16:46:04 +00:00
qreal alignedValue( qreal ) const;
QskIntervalF alignedInterval( const QskIntervalF& ) const;
qreal incrementForKey( const QKeyEvent* ) const;
2020-07-25 12:19:14 +00:00
private:
class PrivateData;
std::unique_ptr< PrivateData > m_data;
2020-07-25 12:19:14 +00:00
};
#endif