QmlMaterial 0.1.0
Loading...
Searching...
No Matches
label.hpp
1#pragma once
2
3#include <QtQuick/private/qquicktext_p.h>
4#include "qml_material/util/text_control_background.hpp"
5#include "qml_material/util/control_environment.hpp"
6
7namespace qml_material
8{
9
11class QML_MATERIAL_API Label : public QQuickText, public ControlEnvironment {
12 Q_OBJECT
13 QML_NAMED_ELEMENT(LabelBase)
14 Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL)
15 Q_PROPERTY(
16 QQuickItem* background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
17 Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY
18 implicitBackgroundWidthChanged FINAL)
19 Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY
20 implicitBackgroundHeightChanged FINAL)
21 Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY
22 topInsetChanged FINAL)
23 Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY
24 leftInsetChanged FINAL)
25 Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY
26 rightInsetChanged FINAL)
27 Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY
28 bottomInsetChanged FINAL)
29
30public:
31 explicit Label(QQuickItem* parent = nullptr);
32 ~Label() override;
33 QFont font() const;
34 void setFont(const QFont&);
35 void resetFont();
36 QFont effectiveFont() const override { return m_effective_font; }
37 void inheritFont(const QFont&) override;
38 QQuickItem* background() const { return m_background.item(); }
39 void setBackground(QQuickItem*);
40 qreal implicitBackgroundWidth() const;
41 qreal implicitBackgroundHeight() const;
42 qreal topInset() const { return m_background.inset(Qt::TopEdge); }
43 void setTopInset(qreal);
44 void resetTopInset();
45 Q_SIGNAL void topInsetChanged();
46 qreal leftInset() const { return m_background.inset(Qt::LeftEdge); }
47 void setLeftInset(qreal);
48 void resetLeftInset();
49 Q_SIGNAL void leftInsetChanged();
50 qreal rightInset() const { return m_background.inset(Qt::RightEdge); }
51 void setRightInset(qreal);
52 void resetRightInset();
53 Q_SIGNAL void rightInsetChanged();
54 qreal bottomInset() const { return m_background.inset(Qt::BottomEdge); }
55 void setBottomInset(qreal);
56 void resetBottomInset();
57 Q_SIGNAL void bottomInsetChanged();
58
59 Q_SIGNAL void fontChanged();
60 Q_SIGNAL void backgroundChanged();
61 Q_SIGNAL void implicitBackgroundWidthChanged();
62 Q_SIGNAL void implicitBackgroundHeightChanged();
63
64protected:
65 void componentComplete() override;
66 void itemChange(ItemChange, const ItemChangeData&) override;
67 void geometryChange(const QRectF&, const QRectF&) override;
68
69private:
70 void resolveFont();
71 QFont m_requested_font;
72 QFont m_effective_font;
73 TextControlBackground m_background;
74};
75
76} // namespace qml_material