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
31QT_BEGIN_NAMESPACE
32
33class QQuickTextFieldPrivate : public QQuickTextInputPrivate, public QQuickItemChangeListener
34#if QT_CONFIG(accessibility)
35 , public QAccessible::ActivationObserver
36#endif
37{
38public:
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 bool setLastFocusChangeReason(Qt::FocusReason reason) override;
98
99#if QT_CONFIG(quicktemplates2_hover)
100 bool hovered = false;
101 bool explicitHoverEnabled = false;
102#endif
103
104 struct ExtraData {
105 bool hasTopInset = false;
106 bool hasLeftInset = false;
107 bool hasRightInset = false;
108 bool hasBottomInset = false;
109 bool hasBackgroundWidth = false;
110 bool hasBackgroundHeight = false;
111 qreal topInset = 0;
112 qreal leftInset = 0;
113 qreal rightInset = 0;
114 qreal bottomInset = 0;
115 QFont requestedFont;
116 };
117 QLazilyAllocated<ExtraData> extra;
118
119 bool resizingBackground = false;
120 QQuickDeferredPointer<QQuickItem> background;
121 QString placeholder;
122 QColor placeholderColor;
123 QQuickPressHandler pressHandler;
124};
125
126QT_END_NAMESPACE
127
128#endif // QQUICKTEXTFIELD_P_P_H
129

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtdeclarative/src/quicktemplates/qquicktextfield_p_p.h