| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DPLATFORMTHEME_H |
| 6 |
#define DPLATFORMTHEME_H |
| 7 |
|
| 8 |
#include <DNativeSettings> |
| 9 |
#include <DPalette> |
| 10 |
|
| 11 |
#include <QObject> |
| 12 |
|
| 13 |
DGUI_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DPlatformThemePrivate; |
| 16 |
// TODO: class DPlatformTheme will be removed in the future |
| 17 |
class DPlatformTheme : public DNativeSettings |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
D_DECLARE_PRIVATE(DPlatformTheme) |
| 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 |
Q_PROPERTY(QColor darkActiveColor READ darkActiveColor WRITE setDarkActiveColor NOTIFY darkActiveColorChanged) |
| 40 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 41 |
// QPalette |
| 42 |
Q_PROPERTY(QColor window READ window WRITE setWindow NOTIFY windowChanged) |
| 43 |
Q_PROPERTY(QColor windowText READ windowText WRITE setWindowText NOTIFY windowTextChanged) |
| 44 |
Q_PROPERTY(QColor base READ base WRITE setBase NOTIFY baseChanged) |
| 45 |
Q_PROPERTY(QColor alternateBase READ alternateBase WRITE setAlternateBase NOTIFY alternateBaseChanged) |
| 46 |
Q_PROPERTY(QColor toolTipBase READ toolTipBase WRITE setToolTipBase NOTIFY toolTipBaseChanged) |
| 47 |
Q_PROPERTY(QColor toolTipText READ toolTipText WRITE setToolTipText NOTIFY toolTipTextChanged) |
| 48 |
Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged) |
| 49 |
Q_PROPERTY(QColor button READ button WRITE setButton NOTIFY buttonChanged) |
| 50 |
Q_PROPERTY(QColor buttonText READ buttonText WRITE setButtonText NOTIFY buttonTextChanged) |
| 51 |
Q_PROPERTY(QColor brightText READ brightText WRITE setBrightText NOTIFY brightTextChanged) |
| 52 |
Q_PROPERTY(QColor light READ light WRITE setLight NOTIFY lightChanged) |
| 53 |
Q_PROPERTY(QColor midlight READ midlight WRITE setMidlight NOTIFY midlightChanged) |
| 54 |
Q_PROPERTY(QColor dark READ dark WRITE setDark NOTIFY darkChanged) |
| 55 |
Q_PROPERTY(QColor mid READ mid WRITE setMid NOTIFY midChanged) |
| 56 |
Q_PROPERTY(QColor shadow READ shadow WRITE setShadow NOTIFY shadowChanged) |
| 57 |
Q_PROPERTY(QColor highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) |
| 58 |
Q_PROPERTY(QColor highlightedText READ highlightedText WRITE setHighlightedText NOTIFY highlightedTextChanged) |
| 59 |
Q_PROPERTY(QColor link READ link WRITE setLink NOTIFY linkChanged) |
| 60 |
Q_PROPERTY(QColor linkVisited READ linkVisited WRITE setLinkVisited NOTIFY linkVisitedChanged) |
| 61 |
// DPalette |
| 62 |
Q_PROPERTY(QColor itemBackground READ itemBackground WRITE setItemBackground NOTIFY itemBackgroundChanged) |
| 63 |
Q_PROPERTY(QColor textTitle READ textTitle WRITE setTextTitle NOTIFY textTitleChanged) |
| 64 |
Q_PROPERTY(QColor textTips READ textTips WRITE setTextTips NOTIFY textTipsChanged) |
| 65 |
Q_PROPERTY(QColor textWarning READ textWarning WRITE setTextWarning NOTIFY textWarningChanged) |
| 66 |
Q_PROPERTY(QColor textLively READ textLively WRITE setTextLively NOTIFY textLivelyChanged) |
| 67 |
Q_PROPERTY(QColor lightLively READ lightLively WRITE setLightLively NOTIFY lightLivelyChanged) |
| 68 |
Q_PROPERTY(QColor darkLively READ darkLively WRITE setDarkLively NOTIFY darkLivelyChanged) |
| 69 |
Q_PROPERTY(QColor frameBorder READ frameBorder WRITE setFrameBorder NOTIFY frameBorderChanged) |
| 70 |
#endif |
| 71 |
// DSizeMode |
| 72 |
Q_PROPERTY(int sizeMode READ sizeMode NOTIFY sizeModeChanged) |
| 73 |
Q_PROPERTY(int scrollBarPolicy READ scrollBarPolicy NOTIFY scrollBarPolicyChanged) |
| 74 |
|
| 75 |
public: |
| 76 |
explicit DPlatformTheme(quint32 window, QObject *parent = nullptr); |
| 77 |
DPlatformTheme(quint32 window, DPlatformTheme *parent); |
| 78 |
~DPlatformTheme(); |
| 79 |
|
| 80 |
bool isValid() const; |
| 81 |
DPlatformTheme *parentTheme() const; |
| 82 |
void setFallbackProperty(bool fallback); |
| 83 |
|
| 84 |
DPalette palette() const; |
| 85 |
DPalette fetchPalette(const DPalette &base, bool *ok = nullptr) const; |
| 86 |
void setPalette(const DPalette &palette); |
| 87 |
|
| 88 |
int cursorBlinkTime() const; |
| 89 |
int cursorBlinkTimeout() const; |
| 90 |
bool cursorBlink() const; |
| 91 |
int doubleClickDistance() const; |
| 92 |
int doubleClickTime() const; |
| 93 |
int dndDragThreshold() const; |
| 94 |
int windowRadius() const; |
| 95 |
int windowRadius(int defaultValue) const; |
| 96 |
QByteArray themeName() const; |
| 97 |
QByteArray iconThemeName() const; |
| 98 |
QByteArray soundThemeName() const; |
| 99 |
|
| 100 |
QByteArray fontName() const; |
| 101 |
QByteArray monoFontName() const; |
| 102 |
qreal fontPointSize() const; |
| 103 |
QByteArray gtkFontName() const; |
| 104 |
|
| 105 |
QColor activeColor() const; |
| 106 |
QColor darkActiveColor() const; |
| 107 |
|
| 108 |
bool isValidPalette() const; |
| 109 |
|
| 110 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 111 |
QColor window() const; |
| 112 |
QColor windowText() const; |
| 113 |
QColor base() const; |
| 114 |
QColor alternateBase() const; |
| 115 |
QColor toolTipBase() const; |
| 116 |
QColor toolTipText() const; |
| 117 |
QColor text() const; |
| 118 |
QColor button() const; |
| 119 |
QColor buttonText() const; |
| 120 |
QColor brightText() const; |
| 121 |
QColor light() const; |
| 122 |
QColor midlight() const; |
| 123 |
QColor dark() const; |
| 124 |
QColor mid() const; |
| 125 |
QColor shadow() const; |
| 126 |
QColor highlight() const; |
| 127 |
QColor highlightedText() const; |
| 128 |
QColor link() const; |
| 129 |
QColor linkVisited() const; |
| 130 |
QColor itemBackground() const; |
| 131 |
QColor textTitle() const; |
| 132 |
QColor textTips() const; |
| 133 |
QColor textWarning() const; |
| 134 |
QColor textLively() const; |
| 135 |
QColor lightLively() const; |
| 136 |
QColor darkLively() const; |
| 137 |
QColor frameBorder() const; |
| 138 |
#endif |
| 139 |
|
| 140 |
int sizeMode() const; |
| 141 |
int scrollBarPolicy() const; |
| 142 |
|
| 143 |
public Q_SLOTS: |
| 144 |
void setCursorBlinkTime(int cursorBlinkTime); |
| 145 |
void setCursorBlinkTimeout(int cursorBlinkTimeout); |
| 146 |
void setCursorBlink(bool cursorBlink); |
| 147 |
void setDoubleClickDistance(int doubleClickDistance); |
| 148 |
void setDoubleClickTime(int doubleClickTime); |
| 149 |
void setDndDragThreshold(int dndDragThreshold); |
| 150 |
void setThemeName(const QByteArray &themeName); |
| 151 |
void setIconThemeName(const QByteArray &iconThemeName); |
| 152 |
void setSoundThemeName(const QByteArray &soundThemeName); |
| 153 |
void setFontName(const QByteArray &fontName); |
| 154 |
void setMonoFontName(const QByteArray &monoFontName); |
| 155 |
void setFontPointSize(qreal fontPointSize); |
| 156 |
void setGtkFontName(const QByteArray &fontName); |
| 157 |
void setActiveColor(const QColor activeColor); |
| 158 |
void setDarkActiveColor(const QColor &activeColor); |
| 159 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 160 |
void setWindow(const QColor &window); |
| 161 |
void setWindowText(const QColor &windowText); |
| 162 |
void setBase(const QColor &base); |
| 163 |
void setAlternateBase(const QColor &alternateBase); |
| 164 |
void setToolTipBase(const QColor &toolTipBase); |
| 165 |
void setToolTipText(const QColor &toolTipText); |
| 166 |
void setText(const QColor &text); |
| 167 |
void setButton(const QColor &button); |
| 168 |
void setButtonText(const QColor &buttonText); |
| 169 |
void setBrightText(const QColor &brightText); |
| 170 |
void setLight(const QColor &light); |
| 171 |
void setMidlight(const QColor &midlight); |
| 172 |
void setDark(const QColor &dark); |
| 173 |
void setMid(const QColor &mid); |
| 174 |
void setShadow(const QColor &shadow); |
| 175 |
void setHighlight(const QColor &highlight); |
| 176 |
void setHighlightedText(const QColor &highlightedText); |
| 177 |
void setLink(const QColor &link); |
| 178 |
void setLinkVisited(const QColor &linkVisited); |
| 179 |
void setItemBackground(const QColor &itemBackground); |
| 180 |
void setTextTitle(const QColor &textTitle); |
| 181 |
void setTextTips(const QColor &textTips); |
| 182 |
void setTextWarning(const QColor &textWarning); |
| 183 |
void setTextLively(const QColor &textLively); |
| 184 |
void setLightLively(const QColor &lightLively); |
| 185 |
void setDarkLively(const QColor &darkLively); |
| 186 |
void setFrameBorder(const QColor &frameBorder); |
| 187 |
#endif |
| 188 |
|
| 189 |
int dotsPerInch(const QString &screenName = QString()) const; |
| 190 |
void setDotsPerInch(const QString &screenName, int dpi); |
| 191 |
void setWindowRadius(int windowRadius); |
| 192 |
|
| 193 |
Q_SIGNALS: |
| 194 |
void cursorBlinkTimeChanged(int cursorBlinkTime); |
| 195 |
void cursorBlinkTimeoutChanged(int cursorBlinkTimeout); |
| 196 |
void cursorBlinkChanged(bool cursorBlink); |
| 197 |
void doubleClickDistanceChanged(int doubleClickDistance); |
| 198 |
void doubleClickTimeChanged(int doubleClickTime); |
| 199 |
void dndDragThresholdChanged(int dndDragThreshold); |
| 200 |
void themeNameChanged(QByteArray themeName); |
| 201 |
void iconThemeNameChanged(QByteArray iconThemeName); |
| 202 |
void soundThemeNameChanged(QByteArray soundThemeName); |
| 203 |
void fontNameChanged(QByteArray fontName); |
| 204 |
void monoFontNameChanged(QByteArray monoFontName); |
| 205 |
void fontPointSizeChanged(qreal fontPointSize); |
| 206 |
void gtkFontNameChanged(QByteArray fontName); |
| 207 |
void activeColorChanged(QColor activeColor); |
| 208 |
void darkActiveColorChanged(QColor activeColor); |
| 209 |
void paletteChanged(DPalette palette); |
| 210 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 211 |
void windowChanged(QColor window); |
| 212 |
void windowTextChanged(QColor windowText); |
| 213 |
void baseChanged(QColor base); |
| 214 |
void alternateBaseChanged(QColor alternateBase); |
| 215 |
void toolTipBaseChanged(QColor toolTipBase); |
| 216 |
void toolTipTextChanged(QColor toolTipText); |
| 217 |
void textChanged(QColor text); |
| 218 |
void buttonChanged(QColor button); |
| 219 |
void buttonTextChanged(QColor buttonText); |
| 220 |
void brightTextChanged(QColor brightText); |
| 221 |
void lightChanged(QColor light); |
| 222 |
void midlightChanged(QColor midlight); |
| 223 |
void darkChanged(QColor dark); |
| 224 |
void midChanged(QColor mid); |
| 225 |
void shadowChanged(QColor shadow); |
| 226 |
void highlightChanged(QColor highlight); |
| 227 |
void highlightedTextChanged(QColor highlightedText); |
| 228 |
void linkChanged(QColor link); |
| 229 |
void linkVisitedChanged(QColor linkVisited); |
| 230 |
void itemBackgroundChanged(QColor itemBackground); |
| 231 |
void textTitleChanged(QColor textTitle); |
| 232 |
void textTipsChanged(QColor textTips); |
| 233 |
void textWarningChanged(QColor textWarning); |
| 234 |
void textLivelyChanged(QColor textLively); |
| 235 |
void lightLivelyChanged(QColor lightLively); |
| 236 |
void darkLivelyChanged(QColor darkLively); |
| 237 |
void frameBorderChanged(QColor frameBorder); |
| 238 |
#endif |
| 239 |
void dotsPerInchChanged(const QString &screen, int dpi); |
| 240 |
void windowRadiusChanged(int r); |
| 241 |
void sizeModeChanged(int sizeMode); |
| 242 |
void scrollBarPolicyChanged(int scrollBarPolicy); |
| 243 |
|
| 244 |
private: |
| 245 |
friend class DPlatformThemePrivate; |
| 246 |
}; |
| 247 |
|
| 248 |
DGUI_END_NAMESPACE |
| 249 |
|
| 250 |
#endif // DPLATFORMTHEME_H |