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 QQUICKCONTROL_P_H
5#define QQUICKCONTROL_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 <QtCore/qlocale.h>
19#include <QtGui/qpalette.h>
20#if QT_CONFIG(accessibility)
21#include <QtGui/qaccessible_base.h>
22#endif
23#include <QtQuick/qquickitem.h>
24#include <QtQuick/private/qquickpalette_p.h>
25#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class QQuickControlPrivate;
30
31class Q_QUICKTEMPLATES2_EXPORT QQuickControl : public QQuickItem
32{
33 Q_OBJECT
34 Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL)
35 Q_PROPERTY(qreal availableWidth READ availableWidth NOTIFY availableWidthChanged FINAL)
36 Q_PROPERTY(qreal availableHeight READ availableHeight NOTIFY availableHeightChanged FINAL)
37 Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL)
38 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged FINAL)
39 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL)
40 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL)
41 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL)
42 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL)
43 Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL)
44 Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL)
45 QT6_ONLY(Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged FINAL))
46 Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
47 Q_PROPERTY(bool visualFocus READ hasVisualFocus NOTIFY visualFocusChanged FINAL)
48 Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL)
49 Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL)
50 Q_PROPERTY(bool wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL)
51 Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
52 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL)
53 Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset RESET resetBaselineOffset NOTIFY baselineOffsetChanged FINAL)
54 // 2.5 (Qt 5.12)
55 Q_PROPERTY(qreal horizontalPadding READ horizontalPadding WRITE setHorizontalPadding RESET resetHorizontalPadding NOTIFY horizontalPaddingChanged FINAL REVISION(2, 5))
56 Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding RESET resetVerticalPadding NOTIFY verticalPaddingChanged FINAL REVISION(2, 5))
57 Q_PROPERTY(qreal implicitContentWidth READ implicitContentWidth NOTIFY implicitContentWidthChanged FINAL REVISION(2, 5))
58 Q_PROPERTY(qreal implicitContentHeight READ implicitContentHeight NOTIFY implicitContentHeightChanged FINAL REVISION(2, 5))
59 Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION(2, 5))
60 Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION(2, 5))
61 Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION(2, 5))
62 Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION(2, 5))
63 Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION(2, 5))
64 Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION(2, 5))
65 Q_CLASSINFO("DeferredPropertyNames", "background,contentItem")
66 QML_NAMED_ELEMENT(Control)
67 QML_ADDED_IN_VERSION(2, 0)
68
69public:
70 explicit QQuickControl(QQuickItem *parent = nullptr);
71 ~QQuickControl();
72
73 QFont font() const;
74 void setFont(const QFont &font);
75 void resetFont();
76
77 qreal availableWidth() const;
78 qreal availableHeight() const;
79
80 qreal padding() const;
81 void setPadding(qreal padding);
82 void resetPadding();
83
84 qreal topPadding() const;
85 void setTopPadding(qreal padding);
86 void resetTopPadding();
87
88 qreal leftPadding() const;
89 void setLeftPadding(qreal padding);
90 void resetLeftPadding();
91
92 qreal rightPadding() const;
93 void setRightPadding(qreal padding);
94 void resetRightPadding();
95
96 qreal bottomPadding() const;
97 void setBottomPadding(qreal padding);
98 void resetBottomPadding();
99
100 qreal spacing() const;
101 void setSpacing(qreal spacing);
102 void resetSpacing();
103
104 QLocale locale() const;
105 void setLocale(const QLocale &locale);
106 void resetLocale();
107
108 bool isMirrored() const;
109
110 Qt::FocusReason focusReason() const;
111 void setFocusReason(Qt::FocusReason reason);
112
113 bool hasVisualFocus() const;
114
115 bool isHovered() const;
116 void setHovered(bool hovered);
117
118 bool isHoverEnabled() const;
119 void setHoverEnabled(bool enabled);
120 void resetHoverEnabled();
121
122 bool isWheelEnabled() const;
123 void setWheelEnabled(bool enabled);
124
125 QQuickItem *background() const;
126 void setBackground(QQuickItem *background);
127
128 QQuickItem *contentItem() const;
129 void setContentItem(QQuickItem *item);
130
131 qreal baselineOffset() const;
132 void setBaselineOffset(qreal offset);
133 void resetBaselineOffset();
134
135 // 2.5 (Qt 5.12)
136 qreal horizontalPadding() const;
137 void setHorizontalPadding(qreal padding);
138 void resetHorizontalPadding();
139
140 qreal verticalPadding() const;
141 void setVerticalPadding(qreal padding);
142 void resetVerticalPadding();
143
144 qreal implicitContentWidth() const;
145 qreal implicitContentHeight() const;
146
147 qreal implicitBackgroundWidth() const;
148 qreal implicitBackgroundHeight() const;
149
150 qreal topInset() const;
151 void setTopInset(qreal inset);
152 void resetTopInset();
153
154 qreal leftInset() const;
155 void setLeftInset(qreal inset);
156 void resetLeftInset();
157
158 qreal rightInset() const;
159 void setRightInset(qreal inset);
160 void resetRightInset();
161
162 qreal bottomInset() const;
163 void setBottomInset(qreal inset);
164 void resetBottomInset();
165
166Q_SIGNALS:
167 void fontChanged();
168 void availableWidthChanged();
169 void availableHeightChanged();
170 void paddingChanged();
171 void topPaddingChanged();
172 void leftPaddingChanged();
173 void rightPaddingChanged();
174 void bottomPaddingChanged();
175 void spacingChanged();
176 void localeChanged();
177 void focusReasonChanged();
178 void mirroredChanged();
179 void visualFocusChanged();
180 void hoveredChanged();
181 void hoverEnabledChanged();
182 void wheelEnabledChanged();
183 void backgroundChanged();
184 void contentItemChanged();
185 void baselineOffsetChanged();
186 // 2.5 (Qt 5.12)
187 Q_REVISION(2, 5) void horizontalPaddingChanged();
188 Q_REVISION(2, 5) void verticalPaddingChanged();
189 Q_REVISION(2, 5) void implicitContentWidthChanged();
190 Q_REVISION(2, 5) void implicitContentHeightChanged();
191 Q_REVISION(2, 5) void implicitBackgroundWidthChanged();
192 Q_REVISION(2, 5) void implicitBackgroundHeightChanged();
193 Q_REVISION(2, 5) void topInsetChanged();
194 Q_REVISION(2, 5) void leftInsetChanged();
195 Q_REVISION(2, 5) void rightInsetChanged();
196 Q_REVISION(2, 5) void bottomInsetChanged();
197
198protected:
199 virtual QFont defaultFont() const;
200
201 QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent);
202
203 void classBegin() override;
204 void componentComplete() override;
205
206 void itemChange(ItemChange change, const ItemChangeData &value) override;
207
208 void focusInEvent(QFocusEvent *event) override;
209 void focusOutEvent(QFocusEvent *event) override;
210#if QT_CONFIG(quicktemplates2_hover)
211 void hoverEnterEvent(QHoverEvent *event) override;
212 void hoverMoveEvent(QHoverEvent *event) override;
213 void hoverLeaveEvent(QHoverEvent *event) override;
214#endif
215 void mousePressEvent(QMouseEvent *event) override;
216 void mouseMoveEvent(QMouseEvent *event) override;
217 void mouseReleaseEvent(QMouseEvent *event) override;
218 void mouseUngrabEvent() override;
219#if QT_CONFIG(quicktemplates2_multitouch)
220 void touchEvent(QTouchEvent *event) override;
221 void touchUngrabEvent() override;
222#endif
223#if QT_CONFIG(wheelevent)
224 void wheelEvent(QWheelEvent *event) override;
225#endif
226
227 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
228
229 virtual void fontChange(const QFont &newFont, const QFont &oldFont);
230#if QT_CONFIG(quicktemplates2_hover)
231 virtual void hoverChange();
232#endif
233 virtual void mirrorChange();
234 virtual void spacingChange(qreal newSpacing, qreal oldSpacing);
235 virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding);
236 virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem);
237 virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale);
238 virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset);
239 virtual void enabledChange();
240
241#if QT_CONFIG(accessibility)
242 virtual QAccessible::Role accessibleRole() const;
243 virtual void accessibilityActiveChanged(bool active);
244#endif
245
246 // helper functions which avoid to check QT_CONFIG(accessibility)
247 QString accessibleName() const;
248 void maybeSetAccessibleName(const QString &name);
249
250 QVariant accessibleProperty(const char *propertyName);
251 bool setAccessibleProperty(const char *propertyName, const QVariant &value);
252
253private:
254 Q_DISABLE_COPY(QQuickControl)
255 Q_DECLARE_PRIVATE(QQuickControl)
256};
257
258QT_END_NAMESPACE
259
260#endif // QQUICKCONTROL_P_H
261

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