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 QQUICKTEXTFIELD_P_H
38#define QQUICKTEXTFIELD_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 <QtGui/qpalette.h>
52#include <QtQuick/private/qquicktextinput_p.h>
53#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
54
55QT_BEGIN_NAMESPACE
56
57class QQuickText;
58class QQuickTextFieldPrivate;
59class QQuickMouseEvent;
60
61class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextField : public QQuickTextInput
62{
63 Q_OBJECT
64 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) // override
65 Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged3 FINAL)
66 Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged3 FINAL)
67 Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
68 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL)
69 Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
70 // 2.1 (Qt 5.8)
71 Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION 1)
72 Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1)
73 // 2.3 (Qt 5.10)
74 Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3)
75 // 2.5 (Qt 5.12)
76 Q_PROPERTY(QColor placeholderTextColor READ placeholderTextColor WRITE setPlaceholderTextColor NOTIFY placeholderTextColorChanged FINAL REVISION 5)
77 Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION 5)
78 Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION 5)
79 Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION 5)
80 Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION 5)
81 Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION 5)
82 Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION 5)
83 Q_CLASSINFO("DeferredPropertyNames", "background")
84
85public:
86 explicit QQuickTextField(QQuickItem *parent = nullptr);
87 ~QQuickTextField();
88
89 QFont font() const;
90 void setFont(const QFont &font);
91
92 QQuickItem *background() const;
93 void setBackground(QQuickItem *background);
94
95 QString placeholderText() const;
96 void setPlaceholderText(const QString &text);
97
98 Qt::FocusReason focusReason() const;
99 void setFocusReason(Qt::FocusReason reason);
100
101 // 2.1 (Qt 5.8)
102 bool isHovered() const;
103 void setHovered(bool hovered);
104
105 bool isHoverEnabled() const;
106 void setHoverEnabled(bool enabled);
107 void resetHoverEnabled();
108
109 // 2.3 (Qt 5.10)
110 QPalette palette() const;
111 void setPalette(const QPalette &palette);
112 void resetPalette();
113
114 // 2.5 (Qt 5.12)
115 QColor placeholderTextColor() const;
116 void setPlaceholderTextColor(const QColor &color);
117
118 qreal implicitBackgroundWidth() const;
119 qreal implicitBackgroundHeight() const;
120
121 qreal topInset() const;
122 void setTopInset(qreal inset);
123 void resetTopInset();
124
125 qreal leftInset() const;
126 void setLeftInset(qreal inset);
127 void resetLeftInset();
128
129 qreal rightInset() const;
130 void setRightInset(qreal inset);
131 void resetRightInset();
132
133 qreal bottomInset() const;
134 void setBottomInset(qreal inset);
135 void resetBottomInset();
136
137Q_SIGNALS:
138 void fontChanged();
139 void implicitWidthChanged3();
140 void implicitHeightChanged3();
141 void backgroundChanged();
142 void placeholderTextChanged();
143 void focusReasonChanged();
144 void pressAndHold(QQuickMouseEvent *event);
145 // 2.1 (Qt 5.8)
146 Q_REVISION(1) void pressed(QQuickMouseEvent *event);
147 Q_REVISION(1) void released(QQuickMouseEvent *event);
148 Q_REVISION(1) void hoveredChanged();
149 Q_REVISION(1) void hoverEnabledChanged();
150 // 2.3 (Qt 5.10)
151 Q_REVISION(3) void paletteChanged();
152 // 2.5 (Qt 5.12)
153 Q_REVISION(5) void placeholderTextColorChanged();
154 Q_REVISION(5) void implicitBackgroundWidthChanged();
155 Q_REVISION(5) void implicitBackgroundHeightChanged();
156 Q_REVISION(5) void topInsetChanged();
157 Q_REVISION(5) void leftInsetChanged();
158 Q_REVISION(5) void rightInsetChanged();
159 Q_REVISION(5) void bottomInsetChanged();
160
161protected:
162 friend struct QQuickPressHandler;
163
164 void classBegin() override;
165 void componentComplete() override;
166
167 void itemChange(ItemChange change, const ItemChangeData &value) override;
168 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
169 virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset);
170
171 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
172
173 void focusInEvent(QFocusEvent *event) override;
174 void focusOutEvent(QFocusEvent *event) override;
175#if QT_CONFIG(quicktemplates2_hover)
176 void hoverEnterEvent(QHoverEvent *event) override;
177 void hoverLeaveEvent(QHoverEvent *event) override;
178#endif
179 void mousePressEvent(QMouseEvent *event) override;
180 void mouseMoveEvent(QMouseEvent *event) override;
181 void mouseReleaseEvent(QMouseEvent *event) override;
182 void mouseDoubleClickEvent(QMouseEvent *event) override;
183 void timerEvent(QTimerEvent *event) override;
184
185private:
186 Q_DISABLE_COPY(QQuickTextField)
187 Q_DECLARE_PRIVATE(QQuickTextField)
188};
189
190QT_END_NAMESPACE
191
192QML_DECLARE_TYPE(QQuickTextField)
193
194#endif // QQUICKTEXTFIELD_P_H
195