DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickiconlabel_p.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DQUICKICONLABEL_P_H
6#define DQUICKICONLABEL_P_H
7
8#include "dquickdciicon_p.h"
9
10#include <dtkdeclarative_global.h>
11
12#include <QQuickItem>
13
14DQUICK_BEGIN_NAMESPACE
15
16class DQuickIconLabelPrivate;
17
18class DQuickIconLabel : public QQuickItem
19{
20 Q_OBJECT
21 Q_PROPERTY(DTK_QUICK_NAMESPACE::DQuickDciIcon icon READ icon WRITE setIcon FINAL)
22 Q_PROPERTY(QString text READ text WRITE setText FINAL)
23 Q_PROPERTY(QFont font READ font WRITE setFont FINAL)
24 Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
25 Q_PROPERTY(Display display READ display WRITE setDisplay FINAL)
26 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing FINAL)
27 Q_PROPERTY(bool mirrored READ isMirrored WRITE setMirrored FINAL)
28 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment FINAL)
29 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding FINAL)
30 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding FINAL)
31 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding FINAL)
32 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding FINAL)
33
34#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
35 QML_NAMED_ELEMENT(IconLabel)
36#endif
37public:
38 enum Display {
39 IconOnly,
40 TextOnly,
41 TextBesideIcon,
42 TextUnderIcon,
43 IconBesideText = 128 // Extended value, previous values are consistent with AbstractButton.
44 };
45 Q_ENUM(Display)
46
47 explicit DQuickIconLabel(QQuickItem *parent = nullptr);
48 ~DQuickIconLabel() override;
49
50 DQuickDciIcon icon() const;
51 void setIcon(const DQuickDciIcon &dciIcon);
52
53 QString text() const;
54 void setText(const QString &text);
55
56 QFont font() const;
57 void setFont(const QFont &font);
58
59 QColor color() const;
60 void setColor(const QColor &color);
61
62 Display display() const;
63 void setDisplay(Display display);
64
65 qreal spacing() const;
66 void setSpacing(qreal spacing);
67
68 bool isMirrored() const;
69 void setMirrored(bool mirrored);
70
71 Qt::Alignment alignment() const;
72 void setAlignment(Qt::Alignment alignment);
73
74 qreal topPadding() const;
75 void setTopPadding(qreal padding);
76 void resetTopPadding();
77
78 qreal leftPadding() const;
79 void setLeftPadding(qreal padding);
80 void resetLeftPadding();
81
82 qreal rightPadding() const;
83 void setRightPadding(qreal padding);
84 void resetRightPadding();
85
86 qreal bottomPadding() const;
87 void setBottomPadding(qreal padding);
88 void resetBottomPadding();
89
90protected:
91 void componentComplete() override;
92#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
93 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
94#else
95 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
96#endif
97
98private:
99 Q_DISABLE_COPY(DQuickIconLabel)
100 Q_DECLARE_PRIVATE(DQuickIconLabel)
101};
102
103DQUICK_END_NAMESPACE
104
105#endif // DQUICKICONLABEL_P_H
A dci icon type for qml.
Definition dquickdciicon_p.h:23
Definition dquickiconlabel_p.h:19