DtkGui 5.5.23
DTK Gui module
dfontmanager.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DFONTSIZEMANAGER_H
6#define DFONTSIZEMANAGER_H
7#include <DObject>
8
9#include <dtkgui_global.h>
10
11#include <QFont>
12
13DGUI_BEGIN_NAMESPACE
14
15class DFontManagerPrivate;
16class DFontManager : public QObject
17 , public DTK_CORE_NAMESPACE::DObject
18{
19 Q_OBJECT
20
21 Q_PROPERTY(QFont t1 READ t1 NOTIFY fontChanged)
22 Q_PROPERTY(QFont t2 READ t2 NOTIFY fontChanged)
23 Q_PROPERTY(QFont t3 READ t3 NOTIFY fontChanged)
24 Q_PROPERTY(QFont t4 READ t4 NOTIFY fontChanged)
25 Q_PROPERTY(QFont t5 READ t5 NOTIFY fontChanged)
26 Q_PROPERTY(QFont t6 READ t6 NOTIFY fontChanged)
27 Q_PROPERTY(QFont t7 READ t7 NOTIFY fontChanged)
28 Q_PROPERTY(QFont t8 READ t8 NOTIFY fontChanged)
29 Q_PROPERTY(QFont t9 READ t9 NOTIFY fontChanged)
30 Q_PROPERTY(QFont t10 READ t10 NOTIFY fontChanged)
31
32 Q_PROPERTY(QFont baseFont READ baseFont WRITE setBaseFont RESET resetBaseFont NOTIFY fontChanged)
33
34public:
35 enum SizeType {
36 T1,
37 T2,
38 T3,
39 T4,
40 T5,
41 T6,
42 T7,
43 T8,
44 T9,
45 T10,
46 NSizeTypes
47 };
48 Q_ENUM(SizeType)
49
50 DFontManager(QObject *parent = nullptr);
51 ~DFontManager() override;
52
53 Q_INVOKABLE int fontPixelSize(SizeType type) const;
54 Q_INVOKABLE void setFontPixelSize(SizeType type, int size);
55
56 Q_INVOKABLE static int fontPixelSize(const QFont &font);
57
58 Q_INVOKABLE static QFont get(int pixelSize, const QFont &base);
59 inline const QFont get(SizeType type, const QFont &base) const
60 {
61 return get(fontPixelSize(type), base);
62 }
63 inline const QFont get(SizeType type) const
64 {
65 return get(type, baseFont());
66 }
67
68 QFont baseFont() const;
69 void setBaseFont(const QFont &font);
70 void resetBaseFont();
71
72 inline const QFont t1() const
73 {
74 return get(T1);
75 }
76 inline const QFont t2() const
77 {
78 return get(T2);
79 }
80 inline const QFont t3() const
81 {
82 return get(T3);
83 }
84 inline const QFont t4() const
85 {
86 return get(T4);
87 }
88 inline const QFont t5() const
89 {
90 return get(T5);
91 }
92 inline const QFont t6() const
93 {
94 return get(T6);
95 }
96 inline const QFont t7() const
97 {
98 return get(T7);
99 }
100 inline const QFont t8() const
101 {
102 return get(T8);
103 }
104 inline const QFont t9() const
105 {
106 return get(T9);
107 }
108 inline const QFont t10() const
109 {
110 return get(T10);
111 }
112
113Q_SIGNALS:
114 void fontChanged();
115
116private:
117 D_DECLARE_PRIVATE(DFontManager)
118};
119
120DGUI_END_NAMESPACE
121
122#endif // DFONTSIZEMANAGER_H
字体大小设置的一个类,系统默认只设置T6.
Definition: dfontmanager.h:18