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 QQUICKTEXTFIELD_P_H |
5 | #define QQUICKTEXTFIELD_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 <QtGui/qpalette.h> |
19 | #include <QtQuick/private/qquicktextinput_p.h> |
20 | #include <QtQuick/private/qquickevents_p_p.h> |
21 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQuickTextFieldPrivate; |
26 | |
27 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextField : public QQuickTextInput |
28 | { |
29 | Q_OBJECT |
30 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) // override |
31 | Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged3 FINAL) |
32 | Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged3 FINAL) |
33 | Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) |
34 | Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) |
35 | Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) |
36 | // 2.1 (Qt 5.8) |
37 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION(2, 1)) |
38 | Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION(2, 1)) |
39 | // 2.5 (Qt 5.12) |
40 | Q_PROPERTY(QColor placeholderTextColor READ placeholderTextColor WRITE setPlaceholderTextColor NOTIFY placeholderTextColorChanged FINAL REVISION(2, 5)) |
41 | Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION(2, 5)) |
42 | Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION(2, 5)) |
43 | Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION(2, 5)) |
44 | Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION(2, 5)) |
45 | Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION(2, 5)) |
46 | Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION(2, 5)) |
47 | Q_CLASSINFO("DeferredPropertyNames" , "background" ) |
48 | QML_NAMED_ELEMENT(TextField) |
49 | QML_ADDED_IN_VERSION(2, 0) |
50 | |
51 | public: |
52 | explicit QQuickTextField(QQuickItem *parent = nullptr); |
53 | ~QQuickTextField(); |
54 | |
55 | QFont font() const; |
56 | void setFont(const QFont &font); |
57 | |
58 | QQuickItem *background() const; |
59 | void setBackground(QQuickItem *background); |
60 | |
61 | QString placeholderText() const; |
62 | void setPlaceholderText(const QString &text); |
63 | |
64 | Qt::FocusReason focusReason() const; |
65 | void setFocusReason(Qt::FocusReason reason); |
66 | |
67 | // 2.1 (Qt 5.8) |
68 | bool isHovered() const; |
69 | void setHovered(bool hovered); |
70 | |
71 | bool isHoverEnabled() const; |
72 | void setHoverEnabled(bool enabled); |
73 | void resetHoverEnabled(); |
74 | |
75 | // 2.5 (Qt 5.12) |
76 | QColor placeholderTextColor() const; |
77 | void setPlaceholderTextColor(const QColor &color); |
78 | |
79 | qreal implicitBackgroundWidth() const; |
80 | qreal implicitBackgroundHeight() const; |
81 | |
82 | qreal topInset() const; |
83 | void setTopInset(qreal inset); |
84 | void resetTopInset(); |
85 | |
86 | qreal leftInset() const; |
87 | void setLeftInset(qreal inset); |
88 | void resetLeftInset(); |
89 | |
90 | qreal rightInset() const; |
91 | void setRightInset(qreal inset); |
92 | void resetRightInset(); |
93 | |
94 | qreal bottomInset() const; |
95 | void setBottomInset(qreal inset); |
96 | void resetBottomInset(); |
97 | |
98 | Q_SIGNALS: |
99 | void fontChanged(); |
100 | void implicitWidthChanged3(); |
101 | void implicitHeightChanged3(); |
102 | void backgroundChanged(); |
103 | void placeholderTextChanged(); |
104 | void focusReasonChanged(); |
105 | void pressAndHold(QQuickMouseEvent *event); |
106 | // 2.1 (Qt 5.8) |
107 | Q_REVISION(2, 1) void pressed(QQuickMouseEvent *event); |
108 | Q_REVISION(2, 1) void released(QQuickMouseEvent *event); |
109 | Q_REVISION(2, 1) void hoveredChanged(); |
110 | Q_REVISION(2, 1) void hoverEnabledChanged(); |
111 | // 2.5 (Qt 5.12) |
112 | Q_REVISION(2, 5) void placeholderTextColorChanged(); |
113 | Q_REVISION(2, 5) void implicitBackgroundWidthChanged(); |
114 | Q_REVISION(2, 5) void implicitBackgroundHeightChanged(); |
115 | Q_REVISION(2, 5) void topInsetChanged(); |
116 | Q_REVISION(2, 5) void leftInsetChanged(); |
117 | Q_REVISION(2, 5) void rightInsetChanged(); |
118 | Q_REVISION(2, 5) void bottomInsetChanged(); |
119 | |
120 | protected: |
121 | friend struct QQuickPressHandler; |
122 | |
123 | void classBegin() override; |
124 | void componentComplete() override; |
125 | |
126 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
127 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
128 | virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset); |
129 | |
130 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override; |
131 | |
132 | void focusInEvent(QFocusEvent *event) override; |
133 | void focusOutEvent(QFocusEvent *event) override; |
134 | #if QT_CONFIG(quicktemplates2_hover) |
135 | void hoverEnterEvent(QHoverEvent *event) override; |
136 | void hoverLeaveEvent(QHoverEvent *event) override; |
137 | #endif |
138 | void mousePressEvent(QMouseEvent *event) override; |
139 | void mouseMoveEvent(QMouseEvent *event) override; |
140 | void mouseReleaseEvent(QMouseEvent *event) override; |
141 | void mouseDoubleClickEvent(QMouseEvent *event) override; |
142 | void timerEvent(QTimerEvent *event) override; |
143 | |
144 | private: |
145 | Q_DISABLE_COPY(QQuickTextField) |
146 | Q_DECLARE_PRIVATE(QQuickTextField) |
147 | }; |
148 | |
149 | QT_END_NAMESPACE |
150 | |
151 | QML_DECLARE_TYPE(QQuickTextField) |
152 | |
153 | #endif // QQUICKTEXTFIELD_P_H |
154 | |