Debian Codegraph @

include/util/ddciiconpalette.h

raw
1 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4
5 #ifndef DDCIICONPALETTE_H
6 #define DDCIICONPALETTE_H
7
8 #include <dtkgui_global.h>
9 #include <qobjectdefs.h>
10
11 #include <QColor>
12 #include <QVector>
13
14 QT_BEGIN_NAMESPACE
15 class QPalette;
16 QT_END_NAMESPACE
17
18 DGUI_BEGIN_NAMESPACE
19
20 class DDciIconPalette
21 {
22 Q_GADGET
23 Q_PROPERTY(QColor foreground READ foreground WRITE setForeground FINAL)
24 Q_PROPERTY(QColor background READ background WRITE setBackground FINAL)
25 Q_PROPERTY(QColor highlight READ highlight WRITE setHighlight FINAL)
26 Q_PROPERTY(QColor highlightForeground READ highlightForeground WRITE setHighlightForeground FINAL)
27
28 public:
29 enum PaletteRole {
30 NoPalette = -1,
31 Foreground = 0,
32 Background = 1,
33 HighlightForeground = 2,
34 Highlight = 3,
35 PaletteCount
36 };
37
38 DDciIconPalette(QColor foreground = QColor::Invalid, QColor background = QColor::Invalid,
39 QColor highlight = QColor::Invalid, QColor highlightForeground = QColor::Invalid);
40 bool operator==(const DDciIconPalette &other) const;
41 bool operator!=(const DDciIconPalette &other) const;
42
43 QColor foreground() const;
44 void setForeground(const QColor &foreground);
45
46 QColor background() const;
47 void setBackground(const QColor &background);
48
49 QColor highlightForeground() const;
50 void setHighlightForeground(const QColor &highlightForeground);
51
52 QColor highlight() const;
53 void setHighlight(const QColor &highlight);
54
55 static QString convertToString(const DDciIconPalette &palette);
56 static DDciIconPalette convertFromString(const QString &data);
57 static DDciIconPalette fromQPalette(const QPalette &pa);
58 private:
59 QVector<QColor> colors;
60 };
61
62 DGUI_END_NAMESPACE
63
64 QT_BEGIN_NAMESPACE
65 #ifndef QT_NO_DEBUG_STREAM
66 Q_GUI_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DDciIconPalette &);
67 #endif
68 QT_END_NAMESPACE
69 #endif // DDCIICONPALETTE_H