1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKSPINBOX_P_H
38#define QQUICKSPINBOX_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtQuickTemplates2/private/qquickcontrol_p.h>
52#include <QtQml/qjsvalue.h>
53
54QT_BEGIN_NAMESPACE
55
56class QValidator;
57class QQuickSpinButton;
58class QQuickSpinButtonPrivate;
59class QQuickSpinBoxPrivate;
60
61class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSpinBox : public QQuickControl
62{
63 Q_OBJECT
64 Q_PROPERTY(int from READ from WRITE setFrom NOTIFY fromChanged FINAL)
65 Q_PROPERTY(int to READ to WRITE setTo NOTIFY toChanged FINAL)
66 Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged FINAL)
67 Q_PROPERTY(int stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
68 Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL)
69 Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL)
70 Q_PROPERTY(QJSValue textFromValue READ textFromValue WRITE setTextFromValue NOTIFY textFromValueChanged FINAL)
71 Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText NOTIFY valueFromTextChanged FINAL)
72 Q_PROPERTY(QQuickSpinButton *up READ up CONSTANT FINAL)
73 Q_PROPERTY(QQuickSpinButton *down READ down CONSTANT FINAL)
74 // 2.2 (Qt 5.9)
75 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION 2)
76 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION 2)
77 // 2.3 (Qt 5.10)
78 Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL REVISION 3)
79 // 2.4 (Qt 5.11)
80 Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged FINAL REVISION 4)
81
82public:
83 explicit QQuickSpinBox(QQuickItem *parent = nullptr);
84 ~QQuickSpinBox();
85
86 int from() const;
87 void setFrom(int from);
88
89 int to() const;
90 void setTo(int to);
91
92 int value() const;
93 void setValue(int value);
94
95 int stepSize() const;
96 void setStepSize(int step);
97
98 bool isEditable() const;
99 void setEditable(bool editable);
100
101 QValidator *validator() const;
102 void setValidator(QValidator *validator);
103
104 QJSValue textFromValue() const;
105 void setTextFromValue(const QJSValue &callback);
106
107 QJSValue valueFromText() const;
108 void setValueFromText(const QJSValue &callback);
109
110 QQuickSpinButton *up() const;
111 QQuickSpinButton *down() const;
112
113 // 2.2 (Qt 5.9)
114 Qt::InputMethodHints inputMethodHints() const;
115 void setInputMethodHints(Qt::InputMethodHints hints);
116
117 bool isInputMethodComposing() const;
118
119 // 2.3 (Qt 5.10)
120 bool wrap() const;
121 void setWrap(bool wrap);
122
123 // 2.4 (Qt 5.11)
124 QString displayText() const;
125
126public Q_SLOTS:
127 void increase();
128 void decrease();
129
130Q_SIGNALS:
131 void fromChanged();
132 void toChanged();
133 void valueChanged();
134 void stepSizeChanged();
135 void editableChanged();
136 void validatorChanged();
137 void textFromValueChanged();
138 void valueFromTextChanged();
139 // 2.2 (Qt 5.9)
140 Q_REVISION(2) void valueModified();
141 Q_REVISION(2) void inputMethodHintsChanged();
142 Q_REVISION(2) void inputMethodComposingChanged();
143 // 2.3 (Qt 5.10)
144 Q_REVISION(3) void wrapChanged();
145 // 2.4 (Qt 5.11)
146 Q_REVISION(4) void displayTextChanged();
147
148protected:
149 void focusInEvent(QFocusEvent *event) override;
150 void hoverEnterEvent(QHoverEvent *event) override;
151 void hoverMoveEvent(QHoverEvent *event) override;
152 void hoverLeaveEvent(QHoverEvent *event) override;
153 void keyPressEvent(QKeyEvent *event) override;
154 void keyReleaseEvent(QKeyEvent *event) override;
155 void timerEvent(QTimerEvent *event) override;
156#if QT_CONFIG(wheelevent)
157 void wheelEvent(QWheelEvent *event) override;
158#endif
159
160 void classBegin() override;
161 void componentComplete() override;
162 void itemChange(ItemChange change, const ItemChangeData &value) override;
163 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
164 void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
165
166 QFont defaultFont() const override;
167 QPalette defaultPalette() const override;
168
169#if QT_CONFIG(accessibility)
170 QAccessible::Role accessibleRole() const override;
171 void accessibilityActiveChanged(bool active) override;
172#endif
173
174private:
175 Q_DISABLE_COPY(QQuickSpinBox)
176 Q_DECLARE_PRIVATE(QQuickSpinBox)
177};
178
179class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSpinButton : public QObject
180{
181 Q_OBJECT
182 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
183 Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
184 // 2.1 (Qt 5.8)
185 Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1)
186 // 2.5 (Qt 5.12)
187 Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION 5)
188 Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION 5)
189 Q_CLASSINFO("DeferredPropertyNames", "indicator")
190
191public:
192 explicit QQuickSpinButton(QQuickSpinBox *parent);
193
194 bool isPressed() const;
195 void setPressed(bool pressed);
196
197 QQuickItem *indicator() const;
198 void setIndicator(QQuickItem *indicator);
199
200 // 2.1 (Qt 5.8)
201 bool isHovered() const;
202 void setHovered(bool hovered);
203
204 // 2.5 (Qt 5.12)
205 qreal implicitIndicatorWidth() const;
206 qreal implicitIndicatorHeight() const;
207
208Q_SIGNALS:
209 void pressedChanged();
210 void indicatorChanged();
211 // 2.1 (Qt 5.8)
212 Q_REVISION(1) void hoveredChanged();
213 // 2.5 (Qt 5.12)
214 Q_REVISION(5) void implicitIndicatorWidthChanged();
215 Q_REVISION(5) void implicitIndicatorHeightChanged();
216
217private:
218 Q_DISABLE_COPY(QQuickSpinButton)
219 Q_DECLARE_PRIVATE(QQuickSpinButton)
220};
221
222QT_END_NAMESPACE
223
224QML_DECLARE_TYPE(QQuickSpinBox)
225
226#endif // QQUICKSPINBOX_P_H
227

source code of qtquickcontrols2/src/quicktemplates2/qquickspinbox_p.h