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 QQUICKICONLABEL_P_H
5#define QQUICKICONLABEL_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 <QtQuick/qquickitem.h>
19#include <QtQuickControls2Impl/private/qtquickcontrols2implglobal_p.h>
20#include <QtQuickTemplates2/private/qquickicon_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickIconLabelPrivate;
25
26class Q_QUICKCONTROLS2IMPL_PRIVATE_EXPORT QQuickIconLabel : public QQuickItem
27{
28 Q_OBJECT
29 Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon FINAL)
30 Q_PROPERTY(QString text READ text WRITE setText FINAL)
31 Q_PROPERTY(QFont font READ font WRITE setFont FINAL)
32 Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
33 Q_PROPERTY(Display display READ display WRITE setDisplay FINAL)
34 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing FINAL)
35 Q_PROPERTY(bool mirrored READ isMirrored WRITE setMirrored FINAL)
36 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment FINAL)
37 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding FINAL)
38 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding FINAL)
39 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding FINAL)
40 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding FINAL)
41 QML_NAMED_ELEMENT(IconLabel)
42 QML_ADDED_IN_VERSION(2, 3)
43
44public:
45 enum Display {
46 IconOnly,
47 TextOnly,
48 TextBesideIcon,
49 TextUnderIcon
50 };
51 Q_ENUM(Display)
52
53 explicit QQuickIconLabel(QQuickItem *parent = nullptr);
54 ~QQuickIconLabel();
55
56 QQuickIcon icon() const;
57 void setIcon(const QQuickIcon &icon);
58
59 QString text() const;
60 void setText(const QString &text);
61
62 QFont font() const;
63 void setFont(const QFont &font);
64
65 QColor color() const;
66 void setColor(const QColor &color);
67
68 Display display() const;
69 void setDisplay(Display display);
70
71 qreal spacing() const;
72 void setSpacing(qreal spacing);
73
74 bool isMirrored() const;
75 void setMirrored(bool mirrored);
76
77 Qt::Alignment alignment() const;
78 void setAlignment(Qt::Alignment alignment);
79
80 qreal topPadding() const;
81 void setTopPadding(qreal padding);
82 void resetTopPadding();
83
84 qreal leftPadding() const;
85 void setLeftPadding(qreal padding);
86 void resetLeftPadding();
87
88 qreal rightPadding() const;
89 void setRightPadding(qreal padding);
90 void resetRightPadding();
91
92 qreal bottomPadding() const;
93 void setBottomPadding(qreal padding);
94 void resetBottomPadding();
95
96protected:
97 void componentComplete() override;
98 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
99
100private:
101 Q_DISABLE_COPY(QQuickIconLabel)
102 Q_DECLARE_PRIVATE(QQuickIconLabel)
103};
104
105QT_END_NAMESPACE
106
107QML_DECLARE_TYPE(QQuickIconLabel)
108
109#endif // QQUICKICONLABEL_P_H
110

source code of qtdeclarative/src/quickcontrolsimpl/qquickiconlabel_p.h