Debian Codegraph @

kysdk-qtwidgets/src/themeController.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #ifndef THEMECONTROLLER_H
24 #define THEMECONTROLLER_H
25
26 #include <QGSettings/QGSettings>
27 #include <QPushButton>
28
29 static const QByteArray FITTHEMEWINDOW = "org.ukui.style";
30
31 /**
32 * @brief 监听主题控制
33 * @since 1.0.0
34 */
35
36 enum ThemeFlag {
37 LightTheme,
38 DarkTheme
39 };
40
41 enum IconFlag {
42 DefaultStyle,
43 ClassicStyle
44 };
45
46 enum WidgetThemeFlag {
47 DefaultTheme, // 寻光
48 ClassicTheme, // 启典
49 FashionTheme, // 和印
50 DawnLightTheme // 破晓
51 };
52
53 class ThemeController
54 {
55
56 public:
57 static QPixmap drawSymbolicColoredPixmap(const QPixmap &source);
58 static QPixmap drawColoredPixmap(const QPixmap &source, const QColor &sampleColor);
59 static QColor getCurrentIconColor();
60 static QColor mixColor(const QColor &c1, const QColor &c2, qreal bias = 0.5);
61 static WidgetThemeFlag widgetTheme();
62 static ThemeFlag themeMode();
63 static IconFlag iconTheme();
64 static int systemFontSize();
65 static QPixmap drawFashionBackground(const QRect &rect, int sub_width, int sub_height, int radius, int flag); // flag ? rightBottom : leftBottom;
66 static bool isPixmapPureColor(const QPixmap &pixmap);
67 static QIcon overlayIcons(const QIcon &icon1, const QIcon &icon2, int iconWidth, int iconHeight, int offsetX = 0, int offsetY = 0);
68 static QPixmap overlayPixmaps(const QPixmap &pixmap1, const QPixmap &pixmap2, int offsetX = 0, int offsetY = 0);
69 static QColor lanhuHSLToQtHsl(int h, int s, int l, int a = 255);
70 static QColor adjustH(const QColor c, int range);
71 static QColor adjustS(const QColor c, int range);
72 static QColor adjustL(const QColor c, int range);
73 static QColor adjustA(const QColor c, int range);
74 static QColor highlightClick(bool isDark, QPalette p);
75 static QColor highlightHover(bool isDark, QPalette p);
76 static QColor buttonDarkClick(bool isDark, QPalette p);
77 // static void normalButtonColor(bool isDark, QPalette p, QPen &defaultPen, QBrush &defaultBrush, QPen &hoverPen, QBrush &hoverBrush,
78 // QPen &clickPen, QBrush &clickBrush, QPen &disablePen, QBrush &disableBrush);
79 static bool systemLang();
80
81 static QColor getPaletteColorFromDT(QString dtString, QPalette::ColorGroup group = QPalette::Normal);
82 static QColor getCustomColorFromDT(QString dtString);
83 static QString getFontStylesFromDT(QString dtString);
84 static int getRadiusFromDT(QString dtString);
85 static int getLineOrMarginFromDT(QString dtString);
86
87 static void getGradientFromDT(QString key, QColor &startColor, QColor &endColor);
88
89 ThemeController();
90 ~ThemeController();
91
92 virtual void changeTheme()
93 {
94 }
95 virtual void changeIconStyle()
96 {
97 }
98 void initThemeStyle();
99
100 QGSettings *m_gsetting;
101 // unused
102 ThemeFlag m_themeFlag;
103 IconFlag m_iconFlag;
104 };
105
106 #endif // THEMECONTROLLER_H