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_H
5#define QQUICKLABEL_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 <QtGui/qpalette.h>
19#include <QtQuick/private/qquicktext_p.h>
20#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickLabelPrivate;
25
26class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickLabel : public QQuickText
27{
28 Q_OBJECT
29 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) // override
30 Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
31 // 2.5 (Qt 5.12)
32 Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION(2, 5))
33 Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION(2, 5))
34 Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION(2, 5))
35 Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION(2, 5))
36 Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION(2, 5))
37 Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION(2, 5))
38 Q_CLASSINFO("DeferredPropertyNames", "background")
39 QML_NAMED_ELEMENT(Label)
40 QML_ADDED_IN_VERSION(2, 0)
41
42public:
43 explicit QQuickLabel(QQuickItem *parent = nullptr);
44 ~QQuickLabel();
45
46 QFont font() const;
47 void setFont(const QFont &font);
48
49 QQuickItem *background() const;
50 void setBackground(QQuickItem *background);
51
52 // 2.5 (Qt 5.12)
53 qreal implicitBackgroundWidth() const;
54 qreal implicitBackgroundHeight() const;
55
56 qreal topInset() const;
57 void setTopInset(qreal inset);
58 void resetTopInset();
59
60 qreal leftInset() const;
61 void setLeftInset(qreal inset);
62 void resetLeftInset();
63
64 qreal rightInset() const;
65 void setRightInset(qreal inset);
66 void resetRightInset();
67
68 qreal bottomInset() const;
69 void setBottomInset(qreal inset);
70 void resetBottomInset();
71
72Q_SIGNALS:
73 void fontChanged();
74 void backgroundChanged();
75 // 2.5 (Qt 5.12)
76 Q_REVISION(2, 5) void implicitBackgroundWidthChanged();
77 Q_REVISION(2, 5) void implicitBackgroundHeightChanged();
78 Q_REVISION(2, 5) void topInsetChanged();
79 Q_REVISION(2, 5) void leftInsetChanged();
80 Q_REVISION(2, 5) void rightInsetChanged();
81 Q_REVISION(2, 5) void bottomInsetChanged();
82
83protected:
84 void classBegin() override;
85 void componentComplete() override;
86
87 void itemChange(ItemChange change, const ItemChangeData &value) override;
88 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
89 virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset);
90
91private:
92 Q_DISABLE_COPY(QQuickLabel)
93 Q_DECLARE_PRIVATE(QQuickLabel)
94};
95
96QT_END_NAMESPACE
97
98QML_DECLARE_TYPE(QQuickLabel)
99
100#endif // QQUICKLABEL_P_H
101

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