DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dstyleoption.h
1// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSTYLEOPTION_H
6#define DSTYLEOPTION_H
7
8#include <dtkwidget_global.h>
9#include <DPalette>
10
11#include <DDciIcon>
12#include <QStyleOption>
13
14QT_BEGIN_NAMESPACE
15class QGuiApplication;
16QT_END_NAMESPACE
17
18
19
20DTK_BEGIN_NAMESPACE
21
22DGUI_USE_NAMESPACE
23
24enum ItemDataRole {
25 MarginsRole = Qt::UserRole + 1,
26 LeftActionListRole,
27 TopActionListRole,
28 RightActionListRole,
29 BottomActionListRole,
30 TextActionListRole,
31 ViewItemFontLevelRole,
32 ViewItemBackgroundRole,
33 ViewItemForegroundRole,
34 ViewItemShowToolTipRole,
35 UserRole = Qt::UserRole << 2
36};
37
38DTK_END_NAMESPACE
39
40DWIDGET_BEGIN_NAMESPACE
41
43{
44public:
45 enum OptionType {
46 SO_HighlightButton = QStyleOption::SO_CustomBase + 1,
47 SO_CustomBase = QStyleOption::SO_CustomBase << 2
48 };
49
50 virtual void init(QWidget *widget);
51 virtual void init(const QWidget *widget);
52 virtual ~DStyleOption() {}
53
54 DPalette dpalette;
55};
56
57class DStyleOptionButton : public QStyleOptionButton, public DStyleOption
58{
59public:
60 explicit DStyleOptionButton();
62 DStyleOptionButton &operator=(const DStyleOptionButton &other);
63 enum ButtonFeature {
64 SuggestButton = (CommandLinkButton << 1),
65 WarningButton = (SuggestButton << 1),
66 FloatingButton = (WarningButton << 1),
67 TitleBarButton = (FloatingButton << 1),
68 CircleButton = (TitleBarButton << 1),
69 HasDciIcon = (CircleButton << 1)
70 };
71
72 void init(const QWidget *widget) override;
73 DDciIcon dciIcon;
74};
75
77{
78public:
79 enum ButtonPosition {
80 Invalid,
81 Beginning,
82 Middle,
83 End,
84 OnlyOne
85 };
86
87 Qt::Orientation orientation;
88 ButtonPosition position;
89};
90
92{
93public:
94 enum LineEditFeature {
95 None = 0x0,
96 Alert = 0x1,
97 IconButton = 0x2
98 };
99 Q_DECLARE_FLAGS(LineEditFeatures, LineEditFeature)
100
101 void init(const QWidget *widget) override;
102
103 LineEditFeatures features = None;
104 QRect iconButtonRect;
105};
106
107class DStyleOptionBackgroundGroup : public QStyleOption, public DStyleOption
108{
109public:
110 enum ItemBackgroundPosition {
111 Invalid,
112 Beginning,
113 Middle,
114 End,
115 OnlyOne
116 };
117
118 using DStyleOption::DStyleOption;
119 using QStyleOption::QStyleOption;
120 void init(const QWidget *widget) override;
121
122 Qt::Orientations directions;
123 ItemBackgroundPosition position;
124};
125
126class DStyleOptionIcon : public QStyleOption, public DStyleOption
127{
128public:
129 QIcon icon;
130};
131
133
135{
136public:
137 enum IconType { SI_QIcon, SI_DciIcon };
138
139 IconType iconType;
140 QSize iconSize;
141 Qt::Alignment iconAlignment;
142
143 DDciIcon dciIcon;
144 DDciIcon::Theme dciTheme;
145 DDciIcon::Mode dciMode;
146};
147
148class DStyleOptionViewItem : public QStyleOptionViewItem, public DStyleOption
149{
150public:
151 enum ViewItemFeature {
152
153 };
154};
155
156class DStyleOptionFloatingWidget : public QStyleOption, public DStyleOption
157{
158public:
159 using DStyleOption::init;
160 bool noBackground;
161 int frameRadius = -1;
162};
163
166{
167public:
168 enum SizeType {
169 T1,
170 T2,
171 T3,
172 T4,
173 T5,
174 T6,
175 T7,
176 T8,
177 T9,
178 T10,
179 T11,
180 NSizeTypes
181 };
182
183 static DFontSizeManager *instance();
184 void bind(QWidget *widget, SizeType type);
185 void bind(QWidget *widget, SizeType type, int weight);
186 void unbind(QWidget *widget);
187
188 quint16 fontPixelSize(SizeType type) const;
189 void setFontPixelSize(SizeType type, quint16 size);
190 void setFontGenericPixelSize(quint16 size);
191 const QFont get(SizeType type, const QFont &base = QFont()) const;
192 const QFont get(SizeType type, int weight, const QFont &base = QFont()) const;
193
194 inline const QFont t1(const QFont &base = QFont()) const
195 { return get(T1, base); }
196 inline const QFont t2(const QFont &base = QFont()) const
197 { return get(T2, base); }
198 inline const QFont t3(const QFont &base = QFont()) const
199 { return get(T3, base); }
200 inline const QFont t4(const QFont &base = QFont()) const
201 { return get(T4, base); }
202 inline const QFont t5(const QFont &base = QFont()) const
203 { return get(T5, base); }
204 inline const QFont t6(const QFont &base = QFont()) const
205 { return get(T6, base); }
206 inline const QFont t7(const QFont &base = QFont()) const
207 { return get(T7, base); }
208 inline const QFont t8(const QFont &base = QFont()) const
209 { return get(T8, base); }
210 inline const QFont t9(const QFont &base = QFont()) const
211 { return get(T9, base); }
212 inline const QFont t10(const QFont &base = QFont()) const
213 { return get(T10, base); }
214 inline const QFont t11(const QFont &base = QFont()) const
215 { return get(T11, base); }
216
217 static int fontPixelSize(const QFont &font);
218
219private:
221
222 QScopedPointer<DFontSizeManagerPrivate> d;
223};
224
225DWIDGET_END_NAMESPACE
226
227#endif // DSTYLEOPTION_H
Definition dstyleoption.cpp:177
字体大小设置的一个类,系统默认只设置T6.
Definition dstyleoption.h:166
Definition dstyleoption.h:108
Definition dstyleoption.h:77
Dtk 样式统一的按钮样式配置.
Definition dstyleoption.h:58
Definition dstyleoption.h:157
Definition dstyleoption.h:135
Definition dstyleoption.h:127
Dtk::Widget::DLineEdit使用的样式配置.
Definition dstyleoption.h:92
Definition dstyleoption.h:149
dcxb插件通过DStyleOption来控制控件的样式.
Definition dstyleoption.h:43