DtkGui 5.5.23
DTK Gui module
dguiapplicationhelper.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DGUIAPPLICATIONHELPER_H
6#define DGUIAPPLICATIONHELPER_H
7
8#include <dtkgui_global.h>
9#include <DPalette>
10#include <DObject>
11
12#include <QGuiApplication>
13#include <QObject>
14
15DGUI_BEGIN_NAMESPACE
16
17class DPlatformTheme;
18class DFontManager;
19class DGuiApplicationHelperPrivate;
20class DGuiApplicationHelper : public QObject, public DCORE_NAMESPACE::DObject
21{
22 Q_OBJECT
23 D_DECLARE_PRIVATE(DGuiApplicationHelper)
24
25 Q_PROPERTY(ColorType themeType READ themeType NOTIFY themeTypeChanged)
26 Q_PROPERTY(ColorType paletteType READ paletteType WRITE setPaletteType NOTIFY paletteTypeChanged)
27 Q_PROPERTY(bool hasUserManual READ hasUserManual)
28
29public:
30 enum ColorType {
31 UnknownType,
32 LightType,
33 DarkType
34 };
35 Q_ENUM(ColorType)
36
37 enum SingleScope {
38 UserScope,
39 GroupScope,
40 WorldScope
41 };
42 Q_ENUM(SingleScope)
43
44 enum Attribute {
45 UseInactiveColorGroup = 1 << 0,
46 ColorCompositing = 1 << 1,
47
48 /* readonly flag */
49 ReadOnlyLimit = 1 << 22,
50 IsDeepinPlatformTheme = ReadOnlyLimit << 0,
51 IsDXcbPlatform = ReadOnlyLimit << 1,
52 IsXWindowPlatform = ReadOnlyLimit << 2,
53 IsTableEnvironment = ReadOnlyLimit << 3,
54 IsDeepinEnvironment = ReadOnlyLimit << 4,
55 IsSpecialEffectsEnvironment = ReadOnlyLimit << 5
56 };
57 Q_ENUM(Attribute)
58 Q_DECLARE_FLAGS(Attributes, Attribute)
59
60 typedef DGuiApplicationHelper *(*HelperCreator)();
61 D_DECL_DEPRECATED static void registerInstanceCreator(HelperCreator creator);
62 static DGuiApplicationHelper *instance();
64
65 static QColor adjustColor(const QColor &base, qint8 hueFloat, qint8 saturationFloat, qint8 lightnessFloat,
66 qint8 redFloat, qint8 greenFloat, qint8 blueFloat, qint8 alphaFloat);
67 static QImage adjustColor(const QImage &base, qint8 hueFloat, qint8 saturationFloat, qint8 lightnessFloat,
68 qint8 redFloat, qint8 greenFloat, qint8 blueFloat, qint8 alphaFloat);
69 static QColor blendColor(const QColor &substrate, const QColor &superstratum);
70 static DPalette standardPalette(ColorType type);
71 static void generatePaletteColor(DPalette &base, QPalette::ColorRole role, ColorType type);
72 static void generatePaletteColor(DPalette &base, DPalette::ColorType role, ColorType type);
73 static void generatePalette(DPalette &base, ColorType type = UnknownType);
74 static DPalette fetchPalette(const DPlatformTheme *theme);
75 Q_DECL_DEPRECATED_X("Use UseInactiveColorGroup enum with setAttribute.") static void setUseInactiveColorGroup(bool on);
76 Q_DECL_DEPRECATED_X("Use ColorCompositing enum with setAttribute.") static void setColorCompositingEnabled(bool on);
77 static bool isXWindowPlatform();
78 static bool isTabletEnvironment();
79 static bool isSpecialEffectsEnvironment();
80 static void setAttribute(Attribute attribute, bool enable);
81 static bool testAttribute(Attribute attribute);
82
83 DPlatformTheme *systemTheme() const;
84 DPlatformTheme *applicationTheme() const;
85 D_DECL_DEPRECATED DPlatformTheme *windowTheme(QWindow *window) const;
86
87 DPalette applicationPalette() const;
88 void setApplicationPalette(const DPalette &palette);
89 D_DECL_DEPRECATED DPalette windowPalette(QWindow *window) const;
90
91 const DFontManager *fontManager() const;
92
93 static ColorType toColorType(const QColor &color);
94 static ColorType toColorType(const QPalette &palette);
95 ColorType themeType() const;
96 ColorType paletteType() const;
97
98 static bool setSingleInstance(const QString &key, SingleScope singleScope = UserScope);
99 static void setSingleInstanceInterval(int interval = 3000);
100 D_DECL_DEPRECATED static void setSingelInstanceInterval(int interval = 3000);
101
102 bool hasUserManual() const;
103
104public Q_SLOTS:
105 D_DECL_DEPRECATED_X("Plase use setPaletteType") void setThemeType(ColorType themeType);
106 void setPaletteType(ColorType paletteType);
107 void handleHelpAction();
108 static void openUrl(const QString &url);
109
110Q_SIGNALS:
111 void themeTypeChanged(ColorType themeType);
112 void paletteTypeChanged(ColorType paletteType);
113 void newProcessInstance(qint64 pid, const QStringList &arguments);
114 void fontChanged(const QFont &font);
115 void applicationPaletteChanged();
116
117protected:
118 explicit DGuiApplicationHelper();
119 virtual void initialize();
120
121private:
122 D_PRIVATE_SLOT(void _q_initApplicationTheme(bool))
123 friend class _DGuiApplicationHelper;
124};
125
126DGUI_END_NAMESPACE
127
128#endif // DGUIAPPLICATIONHELPER_H
字体大小设置的一个类,系统默认只设置T6.
Definition: dfontmanager.h:18
DGuiApplicationHelper 应用程序的 GUI ,如主题、调色板等.
Definition: dguiapplicationhelper.h:21
DPalette提供了修改的 QPalette 类.
Definition: dpalette.h:17
一个提供窗口主题的类.
Definition: dplatformtheme.h:17
Definition: dguiapplicationhelper.cpp:108