1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKICONLABEL_P_H
38#define QQUICKICONLABEL_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtQuick/qquickitem.h>
52#include <QtQuickControls2/private/qtquickcontrols2global_p.h>
53#include <QtQuickTemplates2/private/qquickicon_p.h>
54
55QT_BEGIN_NAMESPACE
56
57class QQuickIconLabelPrivate;
58
59class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickIconLabel : public QQuickItem
60{
61 Q_OBJECT
62 Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon FINAL)
63 Q_PROPERTY(QString text READ text WRITE setText FINAL)
64 Q_PROPERTY(QFont font READ font WRITE setFont FINAL)
65 Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
66 Q_PROPERTY(Display display READ display WRITE setDisplay FINAL)
67 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing FINAL)
68 Q_PROPERTY(bool mirrored READ isMirrored WRITE setMirrored FINAL)
69 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment FINAL)
70 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding FINAL)
71 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding FINAL)
72 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding FINAL)
73 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding FINAL)
74
75public:
76 enum Display {
77 IconOnly,
78 TextOnly,
79 TextBesideIcon,
80 TextUnderIcon
81 };
82 Q_ENUM(Display)
83
84 explicit QQuickIconLabel(QQuickItem *parent = nullptr);
85 ~QQuickIconLabel();
86
87 QQuickIcon icon() const;
88 void setIcon(const QQuickIcon &icon);
89
90 QString text() const;
91 void setText(const QString &text);
92
93 QFont font() const;
94 void setFont(const QFont &font);
95
96 QColor color() const;
97 void setColor(const QColor &color);
98
99 Display display() const;
100 void setDisplay(Display display);
101
102 qreal spacing() const;
103 void setSpacing(qreal spacing);
104
105 bool isMirrored() const;
106 void setMirrored(bool mirrored);
107
108 Qt::Alignment alignment() const;
109 void setAlignment(Qt::Alignment alignment);
110
111 qreal topPadding() const;
112 void setTopPadding(qreal padding);
113 void resetTopPadding();
114
115 qreal leftPadding() const;
116 void setLeftPadding(qreal padding);
117 void resetLeftPadding();
118
119 qreal rightPadding() const;
120 void setRightPadding(qreal padding);
121 void resetRightPadding();
122
123 qreal bottomPadding() const;
124 void setBottomPadding(qreal padding);
125 void resetBottomPadding();
126
127protected:
128 void componentComplete() override;
129 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
130
131private:
132 Q_DISABLE_COPY(QQuickIconLabel)
133 Q_DECLARE_PRIVATE(QQuickIconLabel)
134};
135
136QT_END_NAMESPACE
137
138QML_DECLARE_TYPE(QQuickIconLabel)
139
140#endif // QQUICKICONLABEL_P_H
141

source code of qtquickcontrols2/src/quickcontrols2/qquickiconlabel_p.h