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