DtkGui 5.5.23
DTK Gui module
dplatformhandle.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DPLATFORMHANDLE_H
6#define DPLATFORMHANDLE_H
7
8#include <dtkgui_global.h>
9
10#include <QObject>
11#include <QPainterPath>
12#include <QColor>
13#include <QRegion>
14
15#include <functional>
16
17QT_BEGIN_NAMESPACE
18class QWindow;
19QT_END_NAMESPACE
20
21DGUI_BEGIN_NAMESPACE
22
24{
25 Q_OBJECT
26
27 Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
28 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
29 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
30 Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
31 Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged)
32 Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
33 Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged)
34 Q_PROPERTY(QRegion frameMask READ frameMask WRITE setFrameMask NOTIFY frameMaskChanged)
35 Q_PROPERTY(QMargins frameMargins READ frameMargins NOTIFY frameMarginsChanged)
36 Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged)
37 Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged)
38 Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged)
39 Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged)
40 Q_PROPERTY(bool autoInputMaskByClipPath READ autoInputMaskByClipPath WRITE setAutoInputMaskByClipPath NOTIFY autoInputMaskByClipPathChanged)
41 Q_PROPERTY(WId realWindowId READ realWindowId CONSTANT)
42
43public:
44 explicit DPlatformHandle(QWindow *window, QObject *parent = 0);
45
46 static QString pluginVersion();
47 static bool isDXcbPlatform();
48
49 static void enableDXcbForWindow(QWindow *window);
50 static void enableDXcbForWindow(QWindow *window, bool redirectContent);
51 static bool isEnabledDXcb(const QWindow *window);
52
53 static bool setEnabledNoTitlebarForWindow(QWindow *window, bool enable);
54 static bool isEnabledNoTitlebar(const QWindow *window);
55
56 struct WMBlurArea {
57 qint32 x = 0;
58 qint32 y = 0;
59 qint32 width = 0;
60 qint32 height = 0;
61 qint32 xRadius = 0;
62 qint32 yRaduis = 0;
63 };
64
65 enum WallpaperScaleMode {
66 FollowScreen = 0x00000000,
67 FollowWindow = 0x00010000
68 };
69
70 enum WallpaperFillMode {
71 PreserveAspectCrop = 0x00000000,
72 PreserveAspectFit = 0x00000001
73 };
74
75 static bool setWindowBlurAreaByWM(QWindow *window, const QVector<WMBlurArea> &area);
76 static bool setWindowBlurAreaByWM(QWindow *window, const QList<QPainterPath> &paths);
77 static bool setWindowWallpaperParaByWM(QWindow *window, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode);
78 static bool connectWindowManagerChangedSignal(QObject *object, std::function<void ()> slot);
79 static bool connectHasBlurWindowChanged(QObject *object, std::function<void ()> slot);
80
81 bool setWindowBlurAreaByWM(const QVector<WMBlurArea> &area);
82 bool setWindowBlurAreaByWM(const QList<QPainterPath> &paths);
83
84 static void setDisableWindowOverrideCursor(QWindow *window, bool disable);
85
86 int windowRadius() const;
87
88 int borderWidth() const;
89 QColor borderColor() const;
90
91 int shadowRadius() const;
92 QPoint shadowOffset() const;
93 QColor shadowColor() const;
94
95 QPainterPath clipPath() const;
96 QRegion frameMask() const;
97 QMargins frameMargins() const;
98
99 bool translucentBackground() const;
100 bool enableSystemResize() const;
101 bool enableSystemMove() const;
102 bool enableBlurWindow() const;
103 bool autoInputMaskByClipPath() const;
104
105 WId realWindowId() const;
106 static WId windowLeader();
107
108public Q_SLOTS:
109 void setWindowRadius(int windowRadius);
110
111 void setBorderWidth(int borderWidth);
112 void setBorderColor(const QColor &borderColor);
113
114 void setShadowRadius(int shadowRadius);
115 void setShadowOffset(const QPoint &shadowOffset);
116 void setShadowColor(const QColor &shadowColor);
117
118 void setClipPath(const QPainterPath &clipPath);
119 void setFrameMask(const QRegion &frameMask);
120
121 void setTranslucentBackground(bool translucentBackground);
122 void setEnableSystemResize(bool enableSystemResize);
123 void setEnableSystemMove(bool enableSystemMove);
124 void setEnableBlurWindow(bool enableBlurWindow);
125 void setAutoInputMaskByClipPath(bool autoInputMaskByClipPath);
126
127Q_SIGNALS:
142
143protected:
144 bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
145
146private:
147 QWindow *m_window;
148};
149
150inline DPlatformHandle::WMBlurArea dMakeWMBlurArea(quint32 x, quint32 y, quint32 width, quint32 height, quint32 xr = 0, quint32 yr = 0)
151{
153
154 a.x = x;
155 a.y = y;
156 a.width = width;
157 a.height = height;
158 a.xRadius = xr;
159 a.yRaduis = yr;
160
161 return a;
162}
163
164DGUI_END_NAMESPACE
165
166QT_BEGIN_NAMESPACE
167DGUI_USE_NAMESPACE
168QDebug operator<<(QDebug deg, const DPlatformHandle::WMBlurArea &area);
169QT_END_NAMESPACE
170
171Q_DECLARE_METATYPE(QPainterPath)
172Q_DECLARE_METATYPE(QRegion)
173Q_DECLARE_METATYPE(QMargins)
174
175#endif // DPLATFORMHANDLE_H
一个和Qt dxcb平台插件交互的工具类.
Definition: dplatformhandle.h:24
void translucentBackgroundChanged()
信号会在 translucentBackground 属性的值改变时被发送
void borderWidthChanged()
信号会在 borderWidth 属性的值改变时被发送
void borderColorChanged()
信号会在 borderColor 属性的值改变时被发送
void autoInputMaskByClipPathChanged()
信号会在 autoInputMaskByClipPath 属性的值改变时被发送
void shadowRadiusChanged()
信号会在 shadowRadius 属性的值改变时被发送
void enableBlurWindowChanged()
信号会在 enableBlurWindow 属性的值改变时被发送
void frameMarginsChanged()
信号会在 frameMargins 属性的值改变时被发送.
void windowRadiusChanged()
信号会在 windowRadius 属性的值改变时被发送
void enableSystemMoveChanged()
信号会在 enableSystemMove 属性的值改变时被发送
void shadowColorChanged()
信号会在 shadowColor 属性的值改变时被发送
void shadowOffsetChanged()
信号会在 shadowOffset 属性的值改变时被发送
void frameMaskChanged()
信号会在 frameMask 属性的值改变时被发送
void enableSystemResizeChanged()
信号会在 enableSystemResize 属性的值改变时被发送
void clipPathChanged()
信号会在 clipPath 属性的值改变时被发送
描述窗口背景模糊区域的数据结构,包含位置、大小、圆角半径等信息.
Definition: dplatformhandle.h:56