DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dplatformthemeproxy.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DPLATFORMTHEMEPROXY_H
6#define DPLATFORMTHEMEPROXY_H
7
8#include <DObject>
9#include <DPlatformTheme>
10
11#include <dtkdeclarative_global.h>
12
13DGUI_USE_NAMESPACE
14
15DQUICK_BEGIN_NAMESPACE
16
17class DPlatformThemeProxyPrivate;
18class DPlatformThemeProxy : public QObject, public DTK_CORE_NAMESPACE::DObject
19{
20 Q_OBJECT
21
22 Q_PROPERTY(int cursorBlinkTime READ cursorBlinkTime WRITE setCursorBlinkTime NOTIFY cursorBlinkTimeChanged)
23 Q_PROPERTY(int cursorBlinkTimeout READ cursorBlinkTimeout WRITE setCursorBlinkTimeout NOTIFY cursorBlinkTimeoutChanged)
24 Q_PROPERTY(bool cursorBlink READ cursorBlink WRITE setCursorBlink NOTIFY cursorBlinkChanged)
25 Q_PROPERTY(int doubleClickDistance READ doubleClickDistance WRITE setDoubleClickDistance NOTIFY doubleClickDistanceChanged)
26 Q_PROPERTY(int doubleClickTime READ doubleClickTime WRITE setDoubleClickTime NOTIFY doubleClickTimeChanged)
27 Q_PROPERTY(int dndDragThreshold READ dndDragThreshold WRITE setDndDragThreshold NOTIFY dndDragThresholdChanged)
28 Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
29 Q_PROPERTY(QByteArray themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
30 Q_PROPERTY(QByteArray iconThemeName READ iconThemeName WRITE setIconThemeName NOTIFY iconThemeNameChanged)
31 Q_PROPERTY(QByteArray soundThemeName READ soundThemeName WRITE setSoundThemeName NOTIFY soundThemeNameChanged)
32 // Font
33 Q_PROPERTY(QByteArray fontName READ fontName WRITE setFontName NOTIFY fontNameChanged)
34 Q_PROPERTY(QByteArray monoFontName READ monoFontName WRITE setMonoFontName NOTIFY monoFontNameChanged)
35 Q_PROPERTY(qreal fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY fontPointSizeChanged)
36 Q_PROPERTY(QByteArray gtkFontName READ gtkFontName WRITE setGtkFontName NOTIFY gtkFontNameChanged)
37
38 Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged)
39#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
40 // QPalette
41 Q_PROPERTY(QColor window READ window WRITE setWindow NOTIFY windowChanged)
42 Q_PROPERTY(QColor windowText READ windowText WRITE setWindowText NOTIFY windowTextChanged)
43 Q_PROPERTY(QColor base READ base WRITE setBase NOTIFY baseChanged)
44 Q_PROPERTY(QColor alternateBase READ alternateBase WRITE setAlternateBase NOTIFY alternateBaseChanged)
45 Q_PROPERTY(QColor toolTipBase READ toolTipBase WRITE setToolTipBase NOTIFY toolTipBaseChanged)
46 Q_PROPERTY(QColor toolTipText READ toolTipText WRITE setToolTipText NOTIFY toolTipTextChanged)
47 Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged)
48 Q_PROPERTY(QColor button READ button WRITE setButton NOTIFY buttonChanged)
49 Q_PROPERTY(QColor buttonText READ buttonText WRITE setButtonText NOTIFY buttonTextChanged)
50 Q_PROPERTY(QColor brightText READ brightText WRITE setBrightText NOTIFY brightTextChanged)
51 Q_PROPERTY(QColor light READ light WRITE setLight NOTIFY lightChanged)
52 Q_PROPERTY(QColor midlight READ midlight WRITE setMidlight NOTIFY midlightChanged)
53 Q_PROPERTY(QColor dark READ dark WRITE setDark NOTIFY darkChanged)
54 Q_PROPERTY(QColor mid READ mid WRITE setMid NOTIFY midChanged)
55 Q_PROPERTY(QColor shadow READ shadow WRITE setShadow NOTIFY shadowChanged)
56 Q_PROPERTY(QColor highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
57 Q_PROPERTY(QColor highlightedText READ highlightedText WRITE setHighlightedText NOTIFY highlightedTextChanged)
58 Q_PROPERTY(QColor link READ link WRITE setLink NOTIFY linkChanged)
59 Q_PROPERTY(QColor linkVisited READ linkVisited WRITE setLinkVisited NOTIFY linkVisitedChanged)
60 // DPalette
61 Q_PROPERTY(QColor itemBackground READ itemBackground WRITE setItemBackground NOTIFY itemBackgroundChanged)
62 Q_PROPERTY(QColor textTitle READ textTitle WRITE setTextTitle NOTIFY textTitleChanged)
63 Q_PROPERTY(QColor textTips READ textTips WRITE setTextTips NOTIFY textTipsChanged)
64 Q_PROPERTY(QColor textWarning READ textWarning WRITE setTextWarning NOTIFY textWarningChanged)
65 Q_PROPERTY(QColor textLively READ textLively WRITE setTextLively NOTIFY textLivelyChanged)
66 Q_PROPERTY(QColor lightLively READ lightLively WRITE setLightLively NOTIFY lightLivelyChanged)
67 Q_PROPERTY(QColor darkLively READ darkLively WRITE setDarkLively NOTIFY darkLivelyChanged)
68 Q_PROPERTY(QColor frameBorder READ frameBorder WRITE setFrameBorder NOTIFY frameBorderChanged)
69#endif
70 Q_PROPERTY(int scrollBarPolicy READ scrollBarPolicy NOTIFY scrollBarPolicyChanged)
71
72public:
73 explicit DPlatformThemeProxy(DPlatformTheme *proxy, QObject *parent = nullptr);
74 ~DPlatformThemeProxy() override;
75
76 int cursorBlinkTime() const;
77 int cursorBlinkTimeout() const;
78 bool cursorBlink() const;
79 int doubleClickDistance() const;
80 int doubleClickTime() const;
81 int dndDragThreshold() const;
82 int windowRadius() const;
83 Q_INVOKABLE int windowRadius(int defaultValue) const;
84 QByteArray themeName() const;
85 QByteArray iconThemeName() const;
86 QByteArray soundThemeName() const;
87
88 QByteArray fontName() const;
89 QByteArray monoFontName() const;
90 qreal fontPointSize() const;
91 QByteArray gtkFontName() const;
92
93 QColor activeColor() const;
94
95 bool isValidPalette() const;
96
97#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
98 QColor window() const;
99 QColor windowText() const;
100 QColor base() const;
101 QColor alternateBase() const;
102 QColor toolTipBase() const;
103 QColor toolTipText() const;
104 QColor text() const;
105 QColor button() const;
106 QColor buttonText() const;
107 QColor brightText() const;
108 QColor light() const;
109 QColor midlight() const;
110 QColor dark() const;
111 QColor mid() const;
112 QColor shadow() const;
113 QColor highlight() const;
114 QColor highlightedText() const;
115 QColor link() const;
116 QColor linkVisited() const;
117 QColor itemBackground() const;
118 QColor textTitle() const;
119 QColor textTips() const;
120 QColor textWarning() const;
121 QColor textLively() const;
122 QColor lightLively() const;
123 QColor darkLively() const;
124 QColor frameBorder() const;
125#endif
126 int scrollBarPolicy() const;
127
128 Q_INVOKABLE int dotsPerInch(const QString &screenName = QString()) const;
129
130public Q_SLOTS:
131 void setCursorBlinkTime(int cursorBlinkTime);
132 void setCursorBlinkTimeout(int cursorBlinkTimeout);
133 void setCursorBlink(bool cursorBlink);
134 void setDoubleClickDistance(int doubleClickDistance);
135 void setDoubleClickTime(int doubleClickTime);
136 void setDndDragThreshold(int dndDragThreshold);
137 void setThemeName(const QByteArray &themeName);
138 void setIconThemeName(const QByteArray &iconThemeName);
139 void setSoundThemeName(const QByteArray &soundThemeName);
140 void setFontName(const QByteArray &fontName);
141 void setMonoFontName(const QByteArray &monoFontName);
142 void setFontPointSize(qreal fontPointSize);
143 void setGtkFontName(const QByteArray &fontName);
144 void setActiveColor(const QColor activeColor);
145#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
146 void setWindow(const QColor &window);
147 void setWindowText(const QColor &windowText);
148 void setBase(const QColor &base);
149 void setAlternateBase(const QColor &alternateBase);
150 void setToolTipBase(const QColor &toolTipBase);
151 void setToolTipText(const QColor &toolTipText);
152 void setText(const QColor &text);
153 void setButton(const QColor &button);
154 void setButtonText(const QColor &buttonText);
155 void setBrightText(const QColor &brightText);
156 void setLight(const QColor &light);
157 void setMidlight(const QColor &midlight);
158 void setDark(const QColor &dark);
159 void setMid(const QColor &mid);
160 void setShadow(const QColor &shadow);
161 void setHighlight(const QColor &highlight);
162 void setHighlightedText(const QColor &highlightedText);
163 void setLink(const QColor &link);
164 void setLinkVisited(const QColor &linkVisited);
165 void setItemBackground(const QColor &itemBackground);
166 void setTextTitle(const QColor &textTitle);
167 void setTextTips(const QColor &textTips);
168 void setTextWarning(const QColor &textWarning);
169 void setTextLively(const QColor &textLively);
170 void setLightLively(const QColor &lightLively);
171 void setDarkLively(const QColor &darkLively);
172 void setFrameBorder(const QColor &frameBorder);
173#endif
174
175 Q_INVOKABLE void setDotsPerInch(const QString &screenName, int dpi);
176 void setWindowRadius(int windowRadius);
177
178Q_SIGNALS:
179 void cursorBlinkTimeChanged(int cursorBlinkTime);
180 void cursorBlinkTimeoutChanged(int cursorBlinkTimeout);
181 void cursorBlinkChanged(bool cursorBlink);
182 void doubleClickDistanceChanged(int doubleClickDistance);
183 void doubleClickTimeChanged(int doubleClickTime);
184 void dndDragThresholdChanged(int dndDragThreshold);
185 void themeNameChanged(QByteArray themeName);
186 void iconThemeNameChanged(QByteArray iconThemeName);
187 void soundThemeNameChanged(QByteArray soundThemeName);
188 void fontNameChanged(QByteArray fontName);
189 void monoFontNameChanged(QByteArray monoFontName);
190 void fontPointSizeChanged(qreal fontPointSize);
191 void gtkFontNameChanged(QByteArray fontName);
192 void activeColorChanged(QColor activeColor);
193 void paletteChanged(DTK_GUI_NAMESPACE::DPalette palette);
194#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
195 void windowChanged(QColor window);
196 void windowTextChanged(QColor windowText);
197 void baseChanged(QColor base);
198 void alternateBaseChanged(QColor alternateBase);
199 void toolTipBaseChanged(QColor toolTipBase);
200 void toolTipTextChanged(QColor toolTipText);
201 void textChanged(QColor text);
202 void buttonChanged(QColor button);
203 void buttonTextChanged(QColor buttonText);
204 void brightTextChanged(QColor brightText);
205 void lightChanged(QColor light);
206 void midlightChanged(QColor midlight);
207 void darkChanged(QColor dark);
208 void midChanged(QColor mid);
209 void shadowChanged(QColor shadow);
210 void highlightChanged(QColor highlight);
211 void highlightedTextChanged(QColor highlightedText);
212 void linkChanged(QColor link);
213 void linkVisitedChanged(QColor linkVisited);
214 void itemBackgroundChanged(QColor itemBackground);
215 void textTitleChanged(QColor textTitle);
216 void textTipsChanged(QColor textTips);
217 void textWarningChanged(QColor textWarning);
218 void textLivelyChanged(QColor textLively);
219 void lightLivelyChanged(QColor lightLively);
220 void darkLivelyChanged(QColor darkLively);
221 void frameBorderChanged(QColor frameBorder);
222#endif
223 void dotsPerInchChanged(const QString &screen, int dpi);
224 void windowRadiusChanged(int r);
225 void scrollBarPolicyChanged();
226
227private:
228 D_DECLARE_PRIVATE(DPlatformThemeProxy)
229};
230
231DQUICK_END_NAMESPACE
232
233#endif // DPLATFORMTHEMEPROXY_H
一个代理类,用于导出dtkgui的DPlatformTheme类的功能到QML使用,功能和接口基本和DPlatformTheme一致
Definition dplatformthemeproxy.h:19