QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBoundedInput.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_BOUNDED_INPUT_H
7#define QSK_BOUNDED_INPUT_H
8
9#include "QskBoundedControl.h"
10
11class QskIntervalF;
12
13class QSK_EXPORT QskBoundedInput : public QskBoundedControl
14{
15 Q_OBJECT
16
17 Q_PROPERTY( qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged )
18 Q_PROPERTY( uint pageSteps READ pageSteps WRITE setPageSteps NOTIFY pageStepsChanged )
19
20 Q_PROPERTY( bool snap READ snap WRITE setSnap NOTIFY snapChanged )
21 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
22
24
25 public:
26 QSK_STATES( ReadOnly )
27
28 QskBoundedInput( QQuickItem* parent = nullptr );
29 ~QskBoundedInput() override;
30
31 qreal stepSize() const;
32 qreal pageSize() const; // pageSteps() * stepSize()
33 uint pageSteps() const;
34
35 void setSnap( bool );
36 bool snap() const;
37
38 void setReadOnly( bool );
39 bool isReadOnly() const;
40
41 public Q_SLOTS:
42 void setStepSize( qreal );
43 void setPageSteps( uint );
44
45 void stepUp();
46 void stepDown();
47 void pageUp();
48 void pageDown();
49
50 virtual void increment( qreal offset ) = 0;
51
52 Q_SIGNALS:
53 void stepSizeChanged( qreal );
54 void pageStepsChanged( qreal );
55 void snapChanged( bool );
56
57 void readOnlyChanged( bool );
58
59 protected:
60 void keyPressEvent( QKeyEvent* ) override;
61
62#ifndef QT_NO_WHEELEVENT
63 void wheelEvent( QWheelEvent* ) override;
64#endif
65
66 void componentComplete() override;
67 virtual void alignInput();
68
69 qreal alignedValue( qreal ) const;
70 QskIntervalF alignedInterval( const QskIntervalF& ) const;
71
72 qreal incrementForKey( const QKeyEvent* ) const;
73
74 private:
75 class PrivateData;
76 std::unique_ptr< PrivateData > m_data;
77};
78
79#endif