Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickcontrol_p_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKCONTROL_P_P_H
6#define QQUICKCONTROL_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTemplates2/private/qquickcontrol_p.h>
20#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h>
21#include <QtQuickTemplates2/private/qquicktheme_p.h>
22
23#include <QtQuick/private/qquickitem_p.h>
24#include <QtQuick/private/qquickitemchangelistener_p.h>
25#include <QtQml/private/qlazilyallocated_p.h>
26
27#if QT_CONFIG(accessibility)
28#include <QtGui/qaccessible.h>
29#endif
30
31#include <QtCore/qloggingcategory.h>
32
34
35Q_DECLARE_LOGGING_CATEGORY(lcItemManagement)
36
37class QQuickAccessibleAttached;
38
39class Q_QUICKTEMPLATES2_EXPORT QQuickControlPrivate : public QQuickItemPrivate,
40 public QSafeQuickItemChangeListener<QQuickControlPrivate>
41#if QT_CONFIG(accessibility)
42 , public QAccessible::ActivationObserver
43#endif
44{
45public:
46 Q_DECLARE_PUBLIC(QQuickControl)
47
48 QQuickControlPrivate();
49 ~QQuickControlPrivate();
50
51 static QQuickControlPrivate *get(QQuickControl *control)
52 {
53 return control->d_func();
54 }
55
56 void init();
57
58#if QT_CONFIG(quicktemplates2_multitouch)
59 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
60#endif
61 virtual bool handlePress(const QPointF &point, ulong timestamp);
62 virtual bool handleMove(const QPointF &point, ulong timestamp);
63 virtual bool handleRelease(const QPointF &point, ulong timestamp);
64 virtual void handleUngrab();
65
66 void mirrorChange() override;
67
68 inline QMarginsF getPadding() const { return QMarginsF(getLeftPadding(), getTopPadding(), getRightPadding(), getBottomPadding()); }
69 inline qreal getTopPadding() const { return extra.isAllocated() && extra->hasTopPadding ? extra->topPadding : getVerticalPadding(); }
70 inline qreal getLeftPadding() const { return extra.isAllocated() && extra->hasLeftPadding ? extra->leftPadding : getHorizontalPadding(); }
71 inline qreal getRightPadding() const { return extra.isAllocated() && extra->hasRightPadding ? extra->rightPadding : getHorizontalPadding(); }
72 inline qreal getBottomPadding() const { return extra.isAllocated() && extra->hasBottomPadding ? extra->bottomPadding : getVerticalPadding(); }
73 inline qreal getHorizontalPadding() const { return hasHorizontalPadding ? horizontalPadding : padding; }
74 inline qreal getVerticalPadding() const { return hasVerticalPadding ? verticalPadding : padding; }
75
76 void setTopPadding(qreal value, bool reset = false);
77 void setLeftPadding(qreal value, bool reset = false);
78 void setRightPadding(qreal value, bool reset = false);
79 void setBottomPadding(qreal value, bool reset = false);
80 void setHorizontalPadding(qreal value, bool reset = false);
81 void setVerticalPadding(qreal value, bool reset = false);
82
83 inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); }
84 inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; }
85 inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; }
86 inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; }
87 inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; }
88
89 void setTopInset(qreal value, bool reset = false);
90 void setLeftInset(qreal value, bool reset = false);
91 void setRightInset(qreal value, bool reset = false);
92 void setBottomInset(qreal value, bool reset = false);
93
94 virtual void resizeBackground();
95 virtual void resizeContent();
96
97 virtual QQuickItem *getContentItem();
98 void setContentItem_helper(QQuickItem *item, bool notify = true);
99
100#if QT_CONFIG(accessibility)
101 void accessibilityActiveChanged(bool active) override;
102 QAccessible::Role accessibleRole() const override;
103 static QQuickAccessibleAttached *accessibleAttached(const QObject *object);
104#endif
105
106 virtual void resolveFont();
107 void inheritFont(const QFont &font);
108 void updateFont(const QFont &font);
109 static void updateFontRecur(QQuickItem *item, const QFont &font);
110 inline void setFont_helper(const QFont &font) {
111 if (resolvedFont.resolveMask() == font.resolveMask() && resolvedFont == font)
112 return;
113 updateFont(font);
114 }
115 static QFont parentFont(const QQuickItem *item);
116
117 void updateLocale(const QLocale &l, bool e);
118 static void updateLocaleRecur(QQuickItem *item, const QLocale &l);
119 static QLocale calcLocale(const QQuickItem *item);
120
121#if QT_CONFIG(quicktemplates2_hover)
122 void updateHoverEnabled(bool enabled, bool xplicit);
123 static void updateHoverEnabledRecur(QQuickItem *item, bool enabled);
124 static bool calcHoverEnabled(const QQuickItem *item);
125#endif
126
127 static void warnIfCustomizationNotSupported(QObject *control, QQuickItem *item, const QString &propertyName);
128
129 virtual void cancelContentItem();
130 virtual void executeContentItem(bool complete = false);
131
132 virtual void cancelBackground();
133 virtual void executeBackground(bool complete = false);
134
135 enum class UnhideVisibility {
136 Show,
137 Hide
138 };
139
140 static void hideOldItem(QQuickItem *item);
141 static void unhideOldItem(QQuickControl *control, QQuickItem *item,
142 UnhideVisibility visibility = UnhideVisibility::Show);
143
144 void updateBaselineOffset();
145
146 static const ChangeTypes ImplicitSizeChanges;
147
148 void addImplicitSizeListener(QQuickItem *item, ChangeTypes changes = ImplicitSizeChanges);
149 void removeImplicitSizeListener(QQuickItem *item, ChangeTypes changes = ImplicitSizeChanges);
150
151 static void addImplicitSizeListener(QQuickItem *item, QQuickItemChangeListener *listener, ChangeTypes changes = ImplicitSizeChanges);
152 static void removeImplicitSizeListener(QQuickItem *item, QQuickItemChangeListener *listener, ChangeTypes changes = ImplicitSizeChanges);
153
154 void itemImplicitWidthChanged(QQuickItem *item) override;
155 void itemImplicitHeightChanged(QQuickItem *item) override;
156 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
157 void itemDestroyed(QQuickItem *item) override;
158 void itemFocusChanged(QQuickItem *item, Qt::FocusReason reason) override;
159
160 bool setLastFocusChangeReason(Qt::FocusReason) override;
161
162 virtual qreal getContentWidth() const;
163 virtual qreal getContentHeight() const;
164
165 void updateImplicitContentWidth();
166 void updateImplicitContentHeight();
167 void updateImplicitContentSize();
168
169 QPalette defaultPalette() const override;
170
171 struct ExtraData {
172 bool hasTopPadding = false;
173 bool hasLeftPadding = false;
174 bool hasRightPadding = false;
175 bool hasBottomPadding = false;
176 bool hasBaselineOffset = false;
177 bool hasTopInset = false;
178 bool hasLeftInset = false;
179 bool hasRightInset = false;
180 bool hasBottomInset = false;
181 bool hasBackgroundWidth = false;
182 bool hasBackgroundHeight = false;
183 qreal topPadding = 0;
184 qreal leftPadding = 0;
185 qreal rightPadding = 0;
186 qreal bottomPadding = 0;
187 qreal topInset = 0;
188 qreal leftInset = 0;
189 qreal rightInset = 0;
190 qreal bottomInset = 0;
191 QFont requestedFont;
192 };
193 QLazilyAllocated<ExtraData> extra;
194
195 bool hasHorizontalPadding = false;
196 bool hasVerticalPadding = false;
197 bool hasLocale = false;
198 bool wheelEnabled = false;
199#if QT_CONFIG(quicktemplates2_hover)
200 bool hovered = false;
201 bool explicitHoverEnabled = false;
202#endif
203 bool resizingBackground = false;
204 int touchId = -1;
205 qreal padding = 0;
206 qreal horizontalPadding = 0;
207 qreal verticalPadding = 0;
208 qreal implicitContentWidth = 0;
209 qreal implicitContentHeight = 0;
210 qreal spacing = 0;
211 QLocale locale;
212 QFont resolvedFont;
213 QQuickDeferredPointer<QQuickItem> background;
214 QQuickDeferredPointer<QQuickItem> contentItem;
215};
216
217QT_END_NAMESPACE
218
219#endif // QQUICKCONTROL_P_P_H
bool isInteractiveControlType(const QQuickItem *item)
static void layoutItem(QQuickItem *item, qreal y, qreal width)
static const QQuickItemPrivate::ChangeTypes ItemChanges
Styled top-level window with support for a header and footer.
static QQuickItem * findActiveFocusControl(QQuickWindow *window)