1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef Q3DTHEME_H |
5 | #define Q3DTHEME_H |
6 | |
7 | #include <QtGraphs/qgraphsglobal.h> |
8 | #include <QtCore/QObject> |
9 | #include <QtGui/QLinearGradient> |
10 | #include <QtGui/QFont> |
11 | #include <QtGui/QColor> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class Q3DThemePrivate; |
16 | |
17 | class Q_GRAPHS_EXPORT Q3DTheme : public QObject |
18 | { |
19 | Q_OBJECT |
20 | Q_DECLARE_PRIVATE(Q3DTheme) |
21 | Q_PROPERTY(Q3DTheme::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged) |
22 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
23 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) |
24 | Q_PROPERTY(QColor labelBackgroundColor READ labelBackgroundColor WRITE setLabelBackgroundColor NOTIFY labelBackgroundColorChanged) |
25 | Q_PROPERTY(QColor labelTextColor READ labelTextColor WRITE setLabelTextColor NOTIFY labelTextColorChanged) |
26 | Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) |
27 | Q_PROPERTY(QColor multiHighlightColor READ multiHighlightColor WRITE setMultiHighlightColor NOTIFY multiHighlightColorChanged) |
28 | Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged) |
29 | Q_PROPERTY(QColor windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged) |
30 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
31 | Q_PROPERTY(QLinearGradient multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged) |
32 | Q_PROPERTY(QLinearGradient singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged) |
33 | Q_PROPERTY(QList<QColor> baseColors READ baseColors WRITE setBaseColors NOTIFY baseColorsChanged) |
34 | Q_PROPERTY(QList<QLinearGradient> baseGradients READ baseGradients WRITE setBaseGradients NOTIFY baseGradientsChanged) |
35 | Q_PROPERTY(Q3DTheme::Theme type READ type WRITE setType NOTIFY typeChanged) |
36 | Q_PROPERTY(bool backgroundEnabled READ isBackgroundEnabled WRITE setBackgroundEnabled NOTIFY backgroundEnabledChanged) |
37 | Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged) |
38 | Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged) |
39 | Q_PROPERTY(bool labelBorderEnabled READ isLabelBorderEnabled WRITE setLabelBorderEnabled NOTIFY labelBorderEnabledChanged) |
40 | Q_PROPERTY(bool labelsEnabled READ isLabelsEnabled WRITE setLabelsEnabled NOTIFY labelsEnabledChanged) |
41 | Q_PROPERTY(float ambientLightStrength READ ambientLightStrength WRITE setAmbientLightStrength NOTIFY ambientLightStrengthChanged) |
42 | Q_PROPERTY(float highlightLightStrength READ highlightLightStrength WRITE setHighlightLightStrength NOTIFY highlightLightStrengthChanged) |
43 | Q_PROPERTY(float lightStrength READ lightStrength WRITE setLightStrength NOTIFY lightStrengthChanged) |
44 | Q_PROPERTY(float shadowStrength READ shadowStrength WRITE setShadowStrength NOTIFY shadowStrengthChanged) |
45 | |
46 | public: |
47 | enum ColorStyle { |
48 | ColorStyleUniform = 0, |
49 | ColorStyleObjectGradient, |
50 | ColorStyleRangeGradient |
51 | }; |
52 | Q_ENUM(ColorStyle) |
53 | |
54 | enum Theme { |
55 | ThemeQt, |
56 | ThemePrimaryColors, |
57 | ThemeDigia, |
58 | ThemeStoneMoss, |
59 | ThemeArmyBlue, |
60 | ThemeRetro, |
61 | ThemeEbony, |
62 | ThemeIsabelle, |
63 | ThemeUserDefined |
64 | }; |
65 | Q_ENUM(Theme) |
66 | |
67 | public: |
68 | explicit Q3DTheme(QObject *parent = nullptr); |
69 | explicit Q3DTheme(Theme themeType, QObject *parent = nullptr); |
70 | virtual ~Q3DTheme(); |
71 | |
72 | void setType(Q3DTheme::Theme themeType); |
73 | Q3DTheme::Theme type() const; |
74 | |
75 | void setBaseColors(const QList<QColor> &colors); |
76 | QList<QColor> baseColors() const; |
77 | |
78 | void setBackgroundColor(const QColor &color); |
79 | QColor backgroundColor() const; |
80 | |
81 | void setWindowColor(const QColor &color); |
82 | QColor windowColor() const; |
83 | |
84 | void setLabelTextColor(const QColor &color); |
85 | QColor labelTextColor() const; |
86 | |
87 | void setLabelBackgroundColor(const QColor &color); |
88 | QColor labelBackgroundColor() const; |
89 | |
90 | void setGridLineColor(const QColor &color); |
91 | QColor gridLineColor() const; |
92 | |
93 | void setSingleHighlightColor(const QColor &color); |
94 | QColor singleHighlightColor() const; |
95 | |
96 | void setMultiHighlightColor(const QColor &color); |
97 | QColor multiHighlightColor() const; |
98 | |
99 | void setLightColor(const QColor &color); |
100 | QColor lightColor() const; |
101 | |
102 | void setBaseGradients(const QList<QLinearGradient> &gradients); |
103 | QList<QLinearGradient> baseGradients() const; |
104 | |
105 | void setSingleHighlightGradient(const QLinearGradient &gradient); |
106 | QLinearGradient singleHighlightGradient() const; |
107 | |
108 | void setMultiHighlightGradient(const QLinearGradient &gradient); |
109 | QLinearGradient multiHighlightGradient() const; |
110 | |
111 | void setLightStrength(float strength); |
112 | float lightStrength() const; |
113 | |
114 | void setAmbientLightStrength(float strength); |
115 | float ambientLightStrength() const; |
116 | |
117 | void setHighlightLightStrength(float strength); |
118 | float highlightLightStrength() const; |
119 | |
120 | void setLabelBorderEnabled(bool enabled); |
121 | bool isLabelBorderEnabled() const; |
122 | |
123 | void setFont(const QFont &font); |
124 | QFont font() const; |
125 | |
126 | void setBackgroundEnabled(bool enabled); |
127 | bool isBackgroundEnabled() const; |
128 | |
129 | void setGridEnabled(bool enabled); |
130 | bool isGridEnabled() const; |
131 | |
132 | void setLabelBackgroundEnabled(bool enabled); |
133 | bool isLabelBackgroundEnabled() const; |
134 | |
135 | void setColorStyle(Q3DTheme::ColorStyle style); |
136 | Q3DTheme::ColorStyle colorStyle() const; |
137 | |
138 | void setLabelsEnabled(bool enabled); |
139 | bool isLabelsEnabled() const; |
140 | |
141 | void setShadowStrength(float strength); |
142 | float shadowStrength() const; |
143 | |
144 | Q_SIGNALS: |
145 | void typeChanged(Q3DTheme::Theme themeType); |
146 | void baseColorsChanged(const QList<QColor> &colors); |
147 | void backgroundColorChanged(const QColor &color); |
148 | void windowColorChanged(const QColor &color); |
149 | void labelTextColorChanged(const QColor &color); |
150 | void labelBackgroundColorChanged(const QColor &color); |
151 | void gridLineColorChanged(const QColor &color); |
152 | void singleHighlightColorChanged(const QColor &color); |
153 | void multiHighlightColorChanged(const QColor &color); |
154 | void lightColorChanged(const QColor &color); |
155 | void baseGradientsChanged(const QList<QLinearGradient> &gradients); |
156 | void singleHighlightGradientChanged(const QLinearGradient &gradient); |
157 | void multiHighlightGradientChanged(const QLinearGradient &gradient); |
158 | void lightStrengthChanged(float strength); |
159 | void ambientLightStrengthChanged(float strength); |
160 | void highlightLightStrengthChanged(float strength); |
161 | void labelBorderEnabledChanged(bool enabled); |
162 | void fontChanged(const QFont &font); |
163 | void backgroundEnabledChanged(bool enabled); |
164 | void gridEnabledChanged(bool enabled); |
165 | void labelBackgroundEnabledChanged(bool enabled); |
166 | void colorStyleChanged(Q3DTheme::ColorStyle style); |
167 | void labelsEnabledChanged(bool enabled); |
168 | void shadowStrengthChanged(float strength); |
169 | |
170 | protected: |
171 | explicit Q3DTheme(Q3DThemePrivate *d, Theme themeType, QObject *parent = nullptr); |
172 | |
173 | QScopedPointer<Q3DThemePrivate> d_ptr; |
174 | |
175 | private: |
176 | Q_DISABLE_COPY(Q3DTheme) |
177 | |
178 | friend class ThemeManager; |
179 | friend class QQuickGraphsBars; |
180 | friend class Abstract3DController; |
181 | friend class QQuickGraphsItem; |
182 | friend class DeclarativeTheme3D; |
183 | }; |
184 | |
185 | QT_END_NAMESPACE |
186 | |
187 | #endif |
188 | |