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

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