QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBoundedValueInput.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_BOUNDED_VALUE_INPUT_H
7#define QSK_BOUNDED_VALUE_INPUT_H
8
9#include "QskBoundedInput.h"
10
11class QSK_EXPORT QskBoundedValueInput : public QskBoundedInput
12{
13 Q_OBJECT
14
15 Q_PROPERTY( qreal value READ value
16 WRITE setValue NOTIFY valueChanged USER true )
17
18 Q_PROPERTY( qreal valueAsRatio READ valueAsRatio
19 WRITE setValueAsRatio NOTIFY valueChanged )
20
21 Q_PROPERTY( QString valueText READ valueText NOTIFY valueChanged )
22
23 Q_PROPERTY( int decimals READ decimals
24 WRITE setDecimals NOTIFY decimalsChanged )
25
27
28 public:
29 QskBoundedValueInput( QQuickItem* parent = nullptr );
30 ~QskBoundedValueInput() override;
31
32 qreal value() const;
33
34 // [0.0, 1.0]
35 qreal valueAsRatio() const;
36 using QskBoundedInput::valueAsRatio;
37
38 QString valueText() const;
39 virtual QString textFromValue( qreal ) const;
40
41 void setDecimals( int );
42 int decimals() const;
43
44 public Q_SLOTS:
45 void setValue( qreal );
46 void setValueAsRatio( qreal );
47 void increment( qreal ) override;
48
49 Q_SIGNALS:
50 void valueChanged( qreal );
51 void decimalsChanged( int );
52
53 protected:
54 virtual qreal fixupValue( qreal ) const;
55 void alignInput() override;
56
57 private:
58 void setValueInternal( qreal );
59
60 class PrivateData;
61 std::unique_ptr< PrivateData > m_data;
62};
63
64#endif