DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickwindow.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DWINDOW_H
6#define DWINDOW_H
7
8#include <QQuickWindow>
9#include <DObject>
10
11#include <dtkdeclarative_global.h>
12#include <DWindowManagerHelper>
13#include <DPlatformHandle>
14
15QT_BEGIN_NAMESPACE
16class QQmlComponent;
17class QQuickPath;
18class QQuickTransition;
19QT_END_NAMESPACE
20
21DQUICK_BEGIN_NAMESPACE
22
23class DQuickWindowPrivate;
24class DQuickWindowAttached;
25class DQuickWindowAttachedPrivate;
26
27class DQuickWindow : public QQuickWindow, public DTK_CORE_NAMESPACE::DObject
28{
29 Q_OBJECT
30#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
31 QML_UNCREATABLE("DQuickWindow Attached.")
32 QML_NAMED_ELEMENT(DWindow)
33 QML_ATTACHED(DQuickWindowAttached)
34#endif
35public:
36 explicit DQuickWindow(QWindow *parent = nullptr);
37 ~DQuickWindow() override;
38
39 DQuickWindowAttached *attached() const;
40 static DQuickWindowAttached *qmlAttachedProperties(QObject *object);
41
42private:
43 D_DECLARE_PRIVATE(DQuickWindow)
44};
45
48class DQuickWindowAttached : public QObject, public DTK_CORE_NAMESPACE::DObject
49{
50 Q_OBJECT
51 Q_PROPERTY(QQuickWindow *window READ window CONSTANT)
52 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
53 Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
54 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
55 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
56 Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
57 Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged)
58 Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
59 Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged)
60 Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged)
61 Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged)
62 Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged)
63 Q_PROPERTY(int alphaBufferSize READ alphaBufferSize WRITE setAlphaBufferSize NOTIFY alphaBufferSizeChanged)
64 Q_PROPERTY(QQuickPath *clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged)
65 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes READ wmWindowTypes WRITE setWmWindowTypes NOTIFY wmWindowTypesChanged)
66 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions READ motifFunctions WRITE setMotifFunctions NOTIFY motifFunctionsChanged)
67 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations READ motifDecorations WRITE setMotifDecorations NOTIFY motifDecorationsChanged)
68 Q_PROPERTY(QQuickTransition *overlayExited READ overlayExited WRITE setOverlayExited NOTIFY overlayExitedChanged FINAL)
69 Q_PROPERTY(QQmlComponent *loadingOverlay READ loadingOverlay WRITE setLoadingOverlay NOTIFY loadingOverlayChanged FINAL)
70 Q_PROPERTY(DTK_QUICK_NAMESPACE::DQuickAppLoaderItem *appLoader READ appLoader NOTIFY appLoaderChanged)
71#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
72 QML_ANONYMOUS
73#endif
74
75public:
76 explicit DQuickWindowAttached(QWindow *window);
77
78 QQuickWindow *window() const;
79 bool isEnabled() const;
80
81 int windowRadius() const;
82
83 int borderWidth() const;
84 QColor borderColor() const;
85
86 int shadowRadius() const;
87 QPoint shadowOffset() const;
88 QColor shadowColor() const;
89
90 QRegion frameMask() const;
91
92 bool translucentBackground() const;
93 bool enableSystemResize() const;
94 bool enableSystemMove() const;
95 bool enableBlurWindow() const;
96 int alphaBufferSize() const;
97
98 QQuickPath *clipPath() const;
99
100 QQuickTransition *overlayExited() const;
101 QQmlComponent *loadingOverlay() const;
102
103 DQuickAppLoaderItem *appLoader() const;
104 void setAppLoader(DQuickAppLoaderItem *item);
105
106 DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes() const;
107 DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions() const;
108 DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations() const;
109
110public Q_SLOTS:
111 void setEnabled(bool e);
112
113 void setWindowRadius(int windowRadius);
114
115 void setBorderWidth(int borderWidth);
116 void setBorderColor(const QColor &borderColor);
117
118 void setShadowRadius(int shadowRadius);
119 void setShadowOffset(const QPoint &shadowOffset);
120 void setShadowColor(const QColor &shadowColor);
121
122 void setTranslucentBackground(bool translucentBackground);
123 void setEnableSystemResize(bool enableSystemResize);
124 void setEnableSystemMove(bool enableSystemMove);
125 void setEnableBlurWindow(bool enableBlurWindow);
126 void setAlphaBufferSize(int size);
127
128 void setWmWindowTypes(DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes);
129 void setMotifFunctions(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions);
130 void setMotifDecorations(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations);
131
132 void popupSystemWindowMenu();
133
134 bool setWindowBlurAreaByWM(const QVector<DPlatformHandle::WMBlurArea> &area);
135 bool setWindowBlurAreaByWM(const QList<QPainterPath> &area);
136
137 void setClipPathByWM(const QPainterPath &clipPath);
138 void setClipPath(QQuickPath *path);
139 void setOverlayExited(QQuickTransition *exit);
140 void setLoadingOverlay(QQmlComponent *component);
141
142protected:
143 bool eventFilter(QObject *watched, QEvent *event) override;
144
145Q_SIGNALS:
146 void enabledChanged();
147 void windowRadiusChanged();
148 void borderWidthChanged();
149 void borderColorChanged();
150 void shadowRadiusChanged();
151 void shadowOffsetChanged();
152 void shadowColorChanged();
153 void translucentBackgroundChanged();
154 void enableSystemResizeChanged();
155 void enableSystemMoveChanged();
156 void enableBlurWindowChanged();
157 void wmWindowTypesChanged();
158 void motifFunctionsChanged();
159 void motifDecorationsChanged();
160 void alphaBufferSizeChanged();
161 void clipPathChanged();
162 void overlayExitedChanged();
163 void loadingOverlayChanged();
164 void appLoaderChanged();
165
166private:
167 D_DECLARE_PRIVATE(DQuickWindowAttached)
168 D_PRIVATE_SLOT(void _q_onWindowMotifHintsChanged(quint32))
169 D_PRIVATE_SLOT(void _q_updateBlurAreaForWindow())
170 D_PRIVATE_SLOT(void _q_updateClipPath())
171 D_PRIVATE_SLOT(void _q_ensurePlatformHandle())
172
173 friend class DQuickBehindWindowBlur;
175};
176
177DQUICK_END_NAMESPACE
178
179QML_DECLARE_TYPEINFO(DTK_QUICK_NAMESPACE::DQuickWindow, QML_HAS_ATTACHED_PROPERTIES)
180
181#endif // DWINDOW_H
Definition dquickapploaderitem_p.h:16
Definition dquickbehindwindowblur_p_p.h:16
Definition dquickbehindwindowblur_p.h:19
Definition dquickwindow_p.h:29
Definition dquickwindow.h:49
Definition dquickwindow.h:28