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 QQUICKLABEL_P_P_H
5#define QQUICKLABEL_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/qquicktext_p_p.h>
20#include <QtQuick/private/qquickitemchangelistener_p.h>
21#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h>
22#include <QtQuickTemplates2/private/qquicktheme_p.h>
23
24#if QT_CONFIG(accessibility)
25#include <QtGui/qaccessible.h>
26#endif
27
28QT_BEGIN_NAMESPACE
29
30class Q_AUTOTEST_EXPORT QQuickLabelPrivate : public QQuickTextPrivate,
31 public QSafeQuickItemChangeListener<QQuickLabelPrivate>
32#if QT_CONFIG(accessibility)
33 , public QAccessible::ActivationObserver
34#endif
35{
36public:
37 Q_DECLARE_PUBLIC(QQuickLabel)
38
39 QQuickLabelPrivate();
40 ~QQuickLabelPrivate();
41
42 static QQuickLabelPrivate *get(QQuickLabel *item)
43 {
44 return static_cast<QQuickLabelPrivate *>(QObjectPrivate::get(o: item));
45 }
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 void textChanged(const QString &text);
70
71#if QT_CONFIG(accessibility)
72 void accessibilityActiveChanged(bool active) override;
73 QAccessible::Role accessibleRole() const override;
74 void maybeSetAccessibleName(const QString &name);
75#endif
76
77 void cancelBackground();
78 void executeBackground(bool complete = false);
79
80 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
81 void itemImplicitWidthChanged(QQuickItem *item) override;
82 void itemImplicitHeightChanged(QQuickItem *item) override;
83 void itemDestroyed(QQuickItem *item) override;
84
85 QPalette defaultPalette() const override;
86
87 struct ExtraData {
88 bool hasTopInset = false;
89 bool hasLeftInset = false;
90 bool hasRightInset = false;
91 bool hasBottomInset = false;
92 bool hasBackgroundWidth = false;
93 bool hasBackgroundHeight = false;
94 qreal topInset = 0;
95 qreal leftInset = 0;
96 qreal rightInset = 0;
97 qreal bottomInset = 0;
98 QFont requestedFont;
99 };
100 QLazilyAllocated<ExtraData> extra;
101
102 bool resizingBackground = false;
103 QPalette resolvedPalette;
104 QQuickDeferredPointer<QQuickItem> background;
105};
106
107QT_END_NAMESPACE
108
109#endif // QQUICKLABEL_P_P_H
110

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