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_P_H |
5 | #define QQUICKTEXTFIELD_P_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 <QtQml/private/qlazilyallocated_p.h> |
19 | #include <QtQuick/private/qquicktextinput_p_p.h> |
20 | #include <QtQuick/private/qquickitemchangelistener_p.h> |
21 | #include <QtQuickTemplates2/private/qquickpresshandler_p_p.h> |
22 | #include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> |
23 | #include <QtQuickTemplates2/private/qquicktheme_p.h> |
24 | |
25 | #include <QtQuickTemplates2/private/qquicktextfield_p.h> |
26 | |
27 | #if QT_CONFIG(accessibility) |
28 | #include <QtGui/qaccessible.h> |
29 | #endif |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | class QQuickTextFieldPrivate : public QQuickTextInputPrivate, public QQuickItemChangeListener |
34 | #if QT_CONFIG(accessibility) |
35 | , public QAccessible::ActivationObserver |
36 | #endif |
37 | { |
38 | public: |
39 | Q_DECLARE_PUBLIC(QQuickTextField) |
40 | |
41 | QQuickTextFieldPrivate(); |
42 | ~QQuickTextFieldPrivate(); |
43 | |
44 | static QQuickTextFieldPrivate *get(QQuickTextField *item) { |
45 | return static_cast<QQuickTextFieldPrivate *>(QObjectPrivate::get(o: item)); } |
46 | |
47 | inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); } |
48 | inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; } |
49 | inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; } |
50 | inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; } |
51 | inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; } |
52 | |
53 | void setTopInset(qreal value, bool reset = false); |
54 | void setLeftInset(qreal value, bool reset = false); |
55 | void setRightInset(qreal value, bool reset = false); |
56 | void setBottomInset(qreal value, bool reset = false); |
57 | |
58 | void resizeBackground(); |
59 | |
60 | void resolveFont(); |
61 | void inheritFont(const QFont &font); |
62 | void updateFont(const QFont &font); |
63 | inline void setFont_helper(const QFont &font) { |
64 | if (sourceFont.resolveMask() == font.resolveMask() && sourceFont == font) |
65 | return; |
66 | updateFont(font); |
67 | } |
68 | |
69 | #if QT_CONFIG(quicktemplates2_hover) |
70 | void updateHoverEnabled(bool h, bool e); |
71 | #endif |
72 | |
73 | qreal getImplicitWidth() const override; |
74 | qreal getImplicitHeight() const override; |
75 | |
76 | void implicitWidthChanged() override; |
77 | void implicitHeightChanged() override; |
78 | |
79 | void readOnlyChanged(bool isReadOnly); |
80 | void echoModeChanged(QQuickTextField::EchoMode echoMode); |
81 | |
82 | #if QT_CONFIG(accessibility) |
83 | void accessibilityActiveChanged(bool active) override; |
84 | QAccessible::Role accessibleRole() const override; |
85 | #endif |
86 | |
87 | void cancelBackground(); |
88 | void executeBackground(bool complete = false); |
89 | |
90 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; |
91 | void itemImplicitWidthChanged(QQuickItem *item) override; |
92 | void itemImplicitHeightChanged(QQuickItem *item) override; |
93 | void itemDestroyed(QQuickItem *item) override; |
94 | |
95 | QPalette defaultPalette() const override; |
96 | |
97 | #if QT_CONFIG(quicktemplates2_hover) |
98 | bool hovered = false; |
99 | bool explicitHoverEnabled = false; |
100 | #endif |
101 | |
102 | struct { |
103 | bool = false; |
104 | bool = false; |
105 | bool = false; |
106 | bool = false; |
107 | bool = false; |
108 | bool = false; |
109 | qreal = 0; |
110 | qreal = 0; |
111 | qreal = 0; |
112 | qreal = 0; |
113 | QFont ; |
114 | }; |
115 | QLazilyAllocated<ExtraData> ; |
116 | |
117 | bool resizingBackground = false; |
118 | QQuickDeferredPointer<QQuickItem> background; |
119 | QString placeholder; |
120 | QColor placeholderColor; |
121 | Qt::FocusReason focusReason = Qt::OtherFocusReason; |
122 | QQuickPressHandler pressHandler; |
123 | }; |
124 | |
125 | QT_END_NAMESPACE |
126 | |
127 | #endif // QQUICKTEXTFIELD_P_P_H |
128 | |