DtkGui
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 {
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 SizeMode {
45 NormalMode,
46 CompactMode
47 };
48 Q_ENUM(SizeMode)
49
50 enum Attribute {
51 UseInactiveColorGroup = 1 << 0,
52 ColorCompositing = 1 << 1,
53 DontSaveApplicationTheme = 1 << 2,
54
55 /* readonly flag */
56 ReadOnlyLimit = 1 << 22,
57 IsDeepinPlatformTheme = ReadOnlyLimit << 0,
58 IsDXcbPlatform = ReadOnlyLimit << 1,
59 IsXWindowPlatform = ReadOnlyLimit << 2,
60 IsTableEnvironment = ReadOnlyLimit << 3,
61 IsDeepinEnvironment = ReadOnlyLimit << 4,
62 IsSpecialEffectsEnvironment = ReadOnlyLimit << 5,
63 IsWaylandPlatform = ReadOnlyLimit << 6,
64 IsTreelandPlatform Q_DECL_ENUMERATOR_DEPRECATED_X("Use DGuiApplicationHelper::IsWaylandPlatform instead") = IsWaylandPlatform,
65 HasAnimations = ReadOnlyLimit << 7,
66 };
67 Q_ENUM(Attribute)
68 Q_DECLARE_FLAGS(Attributes, Attribute)
69
70#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
71 typedef DGuiApplicationHelper *(*HelperCreator)();
72 D_DECL_DEPRECATED static void registerInstanceCreator(HelperCreator creator);
73#endif
74 static DGuiApplicationHelper *instance();
76
77 static QColor adjustColor(const QColor &base, qint8 hueFloat, qint8 saturationFloat, qint8 lightnessFloat,
78 qint8 redFloat, qint8 greenFloat, qint8 blueFloat, qint8 alphaFloat);
79 static QImage adjustColor(const QImage &base, qint8 hueFloat, qint8 saturationFloat, qint8 lightnessFloat,
80 qint8 redFloat, qint8 greenFloat, qint8 blueFloat, qint8 alphaFloat);
81 static QColor blendColor(const QColor &substrate, const QColor &superstratum);
82 static DPalette standardPalette(ColorType type);
83 static void generatePaletteColor(DPalette &base, QPalette::ColorRole role, ColorType type);
84 static void generatePaletteColor(DPalette &base, DPalette::ColorType role, ColorType type);
85 static void generatePalette(DPalette &base, ColorType type = UnknownType);
86 static DPalette fetchPalette(const DPlatformTheme *theme);
87#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
88 Q_DECL_DEPRECATED_X("Use UseInactiveColorGroup enum with setAttribute.") static void setUseInactiveColorGroup(bool on);
89 Q_DECL_DEPRECATED_X("Use ColorCompositing enum with setAttribute.") static void setColorCompositingEnabled(bool on);
90#endif
91 static bool isXWindowPlatform();
92 static bool isTabletEnvironment();
93 static bool isSpecialEffectsEnvironment();
94 static void setAttribute(Attribute attribute, bool enable);
95 static bool testAttribute(Attribute attribute);
96
97 DPlatformTheme *systemTheme() const;
98 DPlatformTheme *applicationTheme() const;
99#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
100 D_DECL_DEPRECATED DPlatformTheme *windowTheme(QWindow *window) const;
101#endif
102
103 DPalette applicationPalette() const;
104 DPalette applicationPalette(ColorType paletteType) const;
105 void setApplicationPalette(const DPalette &palette);
106#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
107 D_DECL_DEPRECATED DPalette windowPalette(QWindow *window) const;
108#endif
109
110 const DFontManager *fontManager() const;
111
112 static ColorType toColorType(const QColor &color);
113 static ColorType toColorType(const QPalette &palette);
114 ColorType themeType() const;
115 ColorType paletteType() const;
116
117 static bool setSingleInstance(const QString &key, SingleScope singleScope = UserScope);
118 static void setSingleInstanceInterval(int interval = 3000);
119#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
120 D_DECL_DEPRECATED static void setSingelInstanceInterval(int interval = 3000);
121#endif
122
123 // 获取帮助手册目录
124 static QStringList userManualPaths(const QString &appName);
125 bool hasUserManual() const;
126
127 static bool loadTranslator(const QString &fileName, const QList<QString> &translateDirs, const QList<QLocale> &localeFallback);
128 static bool loadTranslator(const QList<QLocale> &localeFallback = QList<QLocale>() << QLocale::system());
129
130public Q_SLOTS:
131#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
132 D_DECL_DEPRECATED_X("Plase use setPaletteType") void setThemeType(ColorType themeType);
133#endif
134 void setPaletteType(ColorType paletteType);
135 void handleHelpAction();
136 static void openUrl(const QString &url);
137
138 DGuiApplicationHelper::SizeMode sizeMode() const;
139 void setSizeMode(const DGuiApplicationHelper::SizeMode mode);
140 void resetSizeMode();
141 static inline bool isCompactMode()
142 {
143 return instance()->sizeMode() == DGuiApplicationHelper::CompactMode;
144 }
145
146Q_SIGNALS:
147 void themeTypeChanged(ColorType themeType);
148 void paletteTypeChanged(ColorType paletteType);
149 void newProcessInstance(qint64 pid, const QStringList &arguments);
150 void fontChanged(const QFont &font);
153
154protected:
155 explicit DGuiApplicationHelper();
156 virtual void initialize();
157
158private:
159 D_PRIVATE_SLOT(void _q_initApplicationTheme(bool))
160 D_PRIVATE_SLOT(void _q_sizeModeChanged(int))
161 friend class _DGuiApplicationHelper;
162};
163
164DGUI_END_NAMESPACE
165
166#endif // DGUIAPPLICATIONHELPER_H
字体大小设置的一个类,系统默认只设置T6.
Definition dfontmanager.h:19
DGuiApplicationHelper 应用程序的 GUI ,如主题、调色板等.
Definition dguiapplicationhelper.h:21
static bool isCompactMode()
当前控件大小模式是否为紧凑模式。
Definition dguiapplicationhelper.h:141
ColorType
Definition dguiapplicationhelper.h:30
@ LightType
Definition dguiapplicationhelper.h:32
@ UnknownType
Definition dguiapplicationhelper.h:31
void applicationPaletteChanged()
通知调色板对象的改变。
void sizeModeChanged(DGuiApplicationHelper::SizeMode sizeMode)
通知控件大小模式发生改变。
void newProcessInstance(qint64 pid, const QStringList &arguments)
通知新进程的信息。
SizeMode
控件大小模式枚举包含 dtk支持的控件大小模式种类.
Definition dguiapplicationhelper.h:44
Attribute
Definition dguiapplicationhelper.h:50
DPalette继承并且扩展了 QPalette 类, 提供了dtk特有的特性.
Definition dpalette.h:17
ColorType
Definition dpalette.h:20
一个提供窗口主题的类.
Definition dplatformtheme.h:17