| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DPALETTE_H |
| 6 |
#define DPALETTE_H |
| 7 |
|
| 8 |
#include <dtkgui_global.h> |
| 9 |
|
| 10 |
#include <QDebug> |
| 11 |
#include <QPalette> |
| 12 |
|
| 13 |
DGUI_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DPalettePrivate; |
| 16 |
class DPalette : public QPalette |
| 17 |
{ |
| 18 |
Q_GADGET |
| 19 |
public: |
| 20 |
enum ColorType { |
| 21 |
NoType, |
| 22 |
ItemBackground, //列表项的背景色 |
| 23 |
TextTitle, //标题型文本的颜色 |
| 24 |
TextTips, //提示性文本的颜色 |
| 25 |
TextWarning, //警告类型的文本颜色 |
| 26 |
TextLively, //活跃式文本颜色(不受活动色影响) |
| 27 |
LightLively, //活跃式按钮(recommend button)背景色中的亮色(不受活跃色影响) |
| 28 |
DarkLively, //活跃式按钮(recommend button)背景色中的暗色,会从亮色渐变到暗色(不受活跃色影响) |
| 29 |
FrameBorder, //控件边框颜色 |
| 30 |
PlaceholderText, //占位类型的文本颜色,可用于输入框占位内容等提示性文字 |
| 31 |
FrameShadowBorder, //用于跟阴影叠加的边框颜色 |
| 32 |
ObviousBackground, //明显的背景色 |
| 33 |
NColorTypes |
| 34 |
}; |
| 35 |
Q_ENUM(ColorType) |
| 36 |
|
| 37 |
DPalette(); |
| 38 |
DPalette(const QPalette &palette); |
| 39 |
DPalette(const DPalette &palette); |
| 40 |
~DPalette(); |
| 41 |
|
| 42 |
DPalette &operator=(const DPalette &palette); |
| 43 |
|
| 44 |
inline const QColor &color(ColorGroup cg, ColorType ct) const |
| 45 |
{ return brush(cg, ct).color(); } |
| 46 |
const QBrush &brush(ColorGroup cg, ColorType ct) const; |
| 47 |
inline void setColor(ColorGroup cg, ColorType ct, const QColor &color) |
| 48 |
{ setBrush(cg, ct, color); } |
| 49 |
inline void setColor(ColorType ct, const QColor &color) |
| 50 |
{ setColor(All, ct, color); } |
| 51 |
inline void setBrush(ColorType ct, const QBrush &brush) |
| 52 |
{ setBrush(All, ct, brush); } |
| 53 |
void setBrush(ColorGroup cg, ColorType ct, const QBrush &brush); |
| 54 |
|
| 55 |
inline const QColor &color(ColorType ct) const { return color(Current, ct); } |
| 56 |
inline const QBrush &brush(ColorType ct) const { return brush(Current, ct); } |
| 57 |
inline const QBrush &itemBackground() const { return brush(ItemBackground); } |
| 58 |
inline const QBrush &textTitle() const { return brush(TextTitle); } |
| 59 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 60 |
D_DECL_DEPRECATED inline const QBrush &textTiele() const { return textTitle();} |
| 61 |
#endif |
| 62 |
inline const QBrush &textTips() const { return brush(TextTips); } |
| 63 |
inline const QBrush &textWarning() const { return brush(TextWarning); } |
| 64 |
inline const QBrush &textLively() const { return brush(TextLively); } |
| 65 |
inline const QBrush &lightLively() const { return brush(LightLively); } |
| 66 |
inline const QBrush &darkLively() const { return brush(DarkLively); } |
| 67 |
inline const QBrush &frameBorder() const { return brush(FrameBorder); } |
| 68 |
inline const QBrush &placeholderText() const { return brush(PlaceholderText); } |
| 69 |
inline const QBrush &frameShadowBorder() const { return brush(FrameShadowBorder); } |
| 70 |
|
| 71 |
using QPalette::color; |
| 72 |
using QPalette::brush; |
| 73 |
using QPalette::setBrush; |
| 74 |
using QPalette::setColor; |
| 75 |
|
| 76 |
protected: |
| 77 |
QScopedPointer<DPalettePrivate> d; |
| 78 |
|
| 79 |
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const DPalette &p); |
| 80 |
}; |
| 81 |
|
| 82 |
DGUI_END_NAMESPACE |
| 83 |
|
| 84 |
QT_BEGIN_NAMESPACE |
| 85 |
/***************************************************************************** |
| 86 |
DPalette stream functions |
| 87 |
*****************************************************************************/ |
| 88 |
#ifndef QT_NO_DATASTREAM |
| 89 |
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const DTK_GUI_NAMESPACE::DPalette &p); |
| 90 |
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, DTK_GUI_NAMESPACE::DPalette &p); |
| 91 |
#endif // QT_NO_DATASTREAM |
| 92 |
|
| 93 |
#ifndef QT_NO_DEBUG_STREAM |
| 94 |
Q_GUI_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DPalette &); |
| 95 |
#endif |
| 96 |
|
| 97 |
QT_END_NAMESPACE |
| 98 |
|
| 99 |
#endif // DPALETTE_H |