| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKSPINBOX_P_H |
| 5 | #define QQUICKSPINBOX_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
| 19 | #include <QtQml/qjsvalue.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QValidator; |
| 24 | class QQuickSpinBoxPrivate; |
| 25 | class QQuickIndicatorButton; |
| 26 | |
| 27 | class Q_QUICKTEMPLATES2_EXPORT QQuickSpinBox : public QQuickControl |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | Q_PROPERTY(int from READ from WRITE setFrom NOTIFY fromChanged FINAL) |
| 31 | Q_PROPERTY(int to READ to WRITE setTo NOTIFY toChanged FINAL) |
| 32 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged FINAL) |
| 33 | Q_PROPERTY(int stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) |
| 34 | Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL) |
| 35 | Q_PROPERTY(bool live READ isLive WRITE setLive NOTIFY liveChanged FINAL REVISION(6, 6)) |
| 36 | |
| 37 | #if QT_CONFIG(validator) |
| 38 | Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL) |
| 39 | #endif |
| 40 | Q_PROPERTY(QJSValue textFromValue READ textFromValue WRITE setTextFromValue NOTIFY textFromValueChanged FINAL) |
| 41 | Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText NOTIFY valueFromTextChanged FINAL) |
| 42 | Q_PROPERTY(QQuickIndicatorButton *up READ up CONSTANT FINAL) |
| 43 | Q_PROPERTY(QQuickIndicatorButton *down READ down CONSTANT FINAL) |
| 44 | // 2.2 (Qt 5.9) |
| 45 | Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION(2, 2)) |
| 46 | Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION(2, 2)) |
| 47 | // 2.3 (Qt 5.10) |
| 48 | Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL REVISION(2, 3)) |
| 49 | // 2.4 (Qt 5.11) |
| 50 | Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged FINAL REVISION(2, 4)) |
| 51 | QML_NAMED_ELEMENT(SpinBox) |
| 52 | QML_ADDED_IN_VERSION(2, 0) |
| 53 | |
| 54 | public: |
| 55 | explicit QQuickSpinBox(QQuickItem *parent = nullptr); |
| 56 | ~QQuickSpinBox(); |
| 57 | |
| 58 | int from() const; |
| 59 | void setFrom(int from); |
| 60 | |
| 61 | int to() const; |
| 62 | void setTo(int to); |
| 63 | |
| 64 | int value() const; |
| 65 | void setValue(int value); |
| 66 | |
| 67 | int stepSize() const; |
| 68 | void setStepSize(int step); |
| 69 | |
| 70 | bool isEditable() const; |
| 71 | void setEditable(bool editable); |
| 72 | |
| 73 | bool isLive() const; |
| 74 | void setLive(bool live); |
| 75 | |
| 76 | #if QT_CONFIG(validator) |
| 77 | QValidator *validator() const; |
| 78 | void setValidator(QValidator *validator); |
| 79 | #endif |
| 80 | |
| 81 | QJSValue textFromValue() const; |
| 82 | void setTextFromValue(const QJSValue &callback); |
| 83 | |
| 84 | QJSValue valueFromText() const; |
| 85 | void setValueFromText(const QJSValue &callback); |
| 86 | |
| 87 | QQuickIndicatorButton *up() const; |
| 88 | QQuickIndicatorButton *down() const; |
| 89 | |
| 90 | // 2.2 (Qt 5.9) |
| 91 | Qt::InputMethodHints inputMethodHints() const; |
| 92 | void setInputMethodHints(Qt::InputMethodHints hints); |
| 93 | |
| 94 | bool isInputMethodComposing() const; |
| 95 | |
| 96 | // 2.3 (Qt 5.10) |
| 97 | bool wrap() const; |
| 98 | void setWrap(bool wrap); |
| 99 | |
| 100 | // 2.4 (Qt 5.11) |
| 101 | QString displayText() const; |
| 102 | |
| 103 | public Q_SLOTS: |
| 104 | void increase(); |
| 105 | void decrease(); |
| 106 | |
| 107 | Q_SIGNALS: |
| 108 | void fromChanged(); |
| 109 | void toChanged(); |
| 110 | void valueChanged(); |
| 111 | void stepSizeChanged(); |
| 112 | void editableChanged(); |
| 113 | Q_REVISION(6, 6) void liveChanged(); |
| 114 | #if QT_CONFIG(validator) |
| 115 | void validatorChanged(); |
| 116 | #endif |
| 117 | void textFromValueChanged(); |
| 118 | void valueFromTextChanged(); |
| 119 | // 2.2 (Qt 5.9) |
| 120 | Q_REVISION(2, 2) void valueModified(); |
| 121 | Q_REVISION(2, 2) void inputMethodHintsChanged(); |
| 122 | Q_REVISION(2, 2) void inputMethodComposingChanged(); |
| 123 | // 2.3 (Qt 5.10) |
| 124 | Q_REVISION(2, 3) void wrapChanged(); |
| 125 | // 2.4 (Qt 5.11) |
| 126 | Q_REVISION(2, 4) void displayTextChanged(); |
| 127 | |
| 128 | protected: |
| 129 | void focusInEvent(QFocusEvent *event) override; |
| 130 | void hoverEnterEvent(QHoverEvent *event) override; |
| 131 | void hoverMoveEvent(QHoverEvent *event) override; |
| 132 | void hoverLeaveEvent(QHoverEvent *event) override; |
| 133 | void keyPressEvent(QKeyEvent *event) override; |
| 134 | void keyReleaseEvent(QKeyEvent *event) override; |
| 135 | void timerEvent(QTimerEvent *event) override; |
| 136 | #if QT_CONFIG(wheelevent) |
| 137 | void wheelEvent(QWheelEvent *event) override; |
| 138 | #endif |
| 139 | |
| 140 | void classBegin() override; |
| 141 | void componentComplete() override; |
| 142 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
| 143 | void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; |
| 144 | void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override; |
| 145 | |
| 146 | QFont defaultFont() const override; |
| 147 | |
| 148 | #if QT_CONFIG(accessibility) |
| 149 | QAccessible::Role accessibleRole() const override; |
| 150 | void accessibilityActiveChanged(bool active) override; |
| 151 | #endif |
| 152 | |
| 153 | private: |
| 154 | Q_DISABLE_COPY(QQuickSpinBox) |
| 155 | Q_DECLARE_PRIVATE(QQuickSpinBox) |
| 156 | }; |
| 157 | |
| 158 | QT_END_NAMESPACE |
| 159 | |
| 160 | #endif // QQUICKSPINBOX_P_H |
| 161 | |