DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickwindow.h
1// SPDX-FileCopyrightText: 2020 - 2026 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#include <DGuiApplicationHelper>
15
16QT_BEGIN_NAMESPACE
17class QQmlComponent;
18class QQuickPath;
19class QQuickTransition;
20QT_END_NAMESPACE
21
22DQUICK_BEGIN_NAMESPACE
23
24class DQuickWindowPrivate;
25class DQuickWindowAttached;
26class DQuickWindowAttachedPrivate;
27
28class DQuickWindow : public QQuickWindow, public DTK_CORE_NAMESPACE::DObject
29{
30 Q_OBJECT
31#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
32 QML_UNCREATABLE("DQuickWindow Attached.")
33 QML_NAMED_ELEMENT(DWindow)
34 QML_ATTACHED(DQuickWindowAttached)
35#endif
36public:
37 explicit DQuickWindow(QWindow *parent = nullptr);
38 ~DQuickWindow() override;
39
40 DQuickWindowAttached *attached() const;
41 static DQuickWindowAttached *qmlAttachedProperties(QObject *object);
42
43private:
44 D_DECLARE_PRIVATE(DQuickWindow)
45};
46
49class DQuickWindowAttached : public QObject, public DTK_CORE_NAMESPACE::DObject
50{
51 Q_OBJECT
52 Q_PROPERTY(QQuickWindow *window READ window CONSTANT)
53 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
54 Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
55 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
56 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
57 Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
58 Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged)
59 Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
60 Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged)
61 Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged)
62 Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged)
63 Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged)
64 Q_PROPERTY(int alphaBufferSize READ alphaBufferSize WRITE setAlphaBufferSize NOTIFY alphaBufferSizeChanged)
65 Q_PROPERTY(QQuickPath *clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged)
66 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes READ wmWindowTypes WRITE setWmWindowTypes NOTIFY wmWindowTypesChanged)
67 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions READ motifFunctions WRITE setMotifFunctions NOTIFY motifFunctionsChanged)
68 Q_PROPERTY(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations READ motifDecorations WRITE setMotifDecorations NOTIFY motifDecorationsChanged)
69 Q_PROPERTY(QQuickTransition *overlayExited READ overlayExited WRITE setOverlayExited NOTIFY overlayExitedChanged FINAL)
70 Q_PROPERTY(QQmlComponent *loadingOverlay READ loadingOverlay WRITE setLoadingOverlay NOTIFY loadingOverlayChanged FINAL)
71 Q_PROPERTY(DTK_QUICK_NAMESPACE::DQuickAppLoaderItem *appLoader READ appLoader NOTIFY appLoaderChanged)
72#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
73 Q_PROPERTY(DTK_GUI_NAMESPACE::DGuiApplicationHelper::ColorType themeType READ themeType WRITE setThemeType RESET resetThemeType NOTIFY themeTypeChanged)
74#endif
75 Q_PROPERTY(DTK_GUI_NAMESPACE::DPlatformHandle::EffectScene windowEffect READ windowEffect WRITE setWindowEffect NOTIFY windowEffectChanged)
76 Q_PROPERTY(DTK_GUI_NAMESPACE::DPlatformHandle::EffectType windowStartUpEffect READ windowStartUpEffect WRITE setWindowStartUpEffect NOTIFY windowStartUpEffectChanged)
77#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
78 QML_ANONYMOUS
79#endif
80
81public:
82 explicit DQuickWindowAttached(QWindow *window);
83 explicit DQuickWindowAttached(QObject *popupObject);
84
85 QQuickWindow *window() const;
86 void setWindow(QQuickWindow *window);
87 bool isEnabled() const;
88
89 int windowRadius() const;
90
91 int borderWidth() const;
92 QColor borderColor() const;
93
94 int shadowRadius() const;
95 QPoint shadowOffset() const;
96 QColor shadowColor() const;
97
98 QRegion frameMask() const;
99
100 bool translucentBackground() const;
101 bool enableSystemResize() const;
102 bool enableSystemMove() const;
103 bool enableBlurWindow() const;
104 int alphaBufferSize() const;
105
106 QQuickPath *clipPath() const;
107
108 QQuickTransition *overlayExited() const;
109 QQmlComponent *loadingOverlay() const;
110
111 DQuickAppLoaderItem *appLoader() const;
112 void setAppLoader(DQuickAppLoaderItem *item);
113
114 DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes() const;
115 DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions() const;
116 DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations() const;
117
118#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
119 DTK_GUI_NAMESPACE::DGuiApplicationHelper::ColorType themeType() const;
120 void setThemeType(const DTK_GUI_NAMESPACE::DGuiApplicationHelper::ColorType &newThemeType);
121 void resetThemeType();
122#endif
123
124 DTK_GUI_NAMESPACE::DPlatformHandle::EffectScene windowEffect() const;
125 DTK_GUI_NAMESPACE::DPlatformHandle::EffectType windowStartUpEffect() const;
126
127public Q_SLOTS:
128 void setEnabled(bool e);
129
130 void setWindowRadius(int windowRadius);
131
132 void setBorderWidth(int borderWidth);
133 void setBorderColor(const QColor &borderColor);
134
135 void setShadowRadius(int shadowRadius);
136 void setShadowOffset(const QPoint &shadowOffset);
137 void setShadowColor(const QColor &shadowColor);
138
139 void setTranslucentBackground(bool translucentBackground);
140 void setEnableSystemResize(bool enableSystemResize);
141 void setEnableSystemMove(bool enableSystemMove);
142 void setEnableBlurWindow(bool enableBlurWindow);
143 void setAlphaBufferSize(int size);
144
145 void setWmWindowTypes(DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes wmWindowTypes);
146 void setMotifFunctions(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions motifFunctions);
147 void setMotifDecorations(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations motifDecorations);
148
149 void popupSystemWindowMenu();
150
151 bool setWindowBlurAreaByWM(const QVector<DPlatformHandle::WMBlurArea> &area);
152 bool setWindowBlurAreaByWM(const QList<QPainterPath> &area);
153
154 void setClipPathByWM(const QPainterPath &clipPath);
155 void setClipPath(QQuickPath *path);
156 void setOverlayExited(QQuickTransition *exit);
157 void setLoadingOverlay(QQmlComponent *component);
158
159 void setWindowEffect(DTK_GUI_NAMESPACE::DPlatformHandle::EffectScenes effect);
160 void setWindowStartUpEffect(DTK_GUI_NAMESPACE::DPlatformHandle::EffectTypes type);
161
162 void showMinimized();
163 void showMaximized();
164 void showFullScreen();
165 void showNormal();
166
167protected:
168 bool eventFilter(QObject *watched, QEvent *event) override;
169
170Q_SIGNALS:
171 void enabledChanged();
172 void windowRadiusChanged();
173 void borderWidthChanged();
174 void borderColorChanged();
175 void shadowRadiusChanged();
176 void shadowOffsetChanged();
177 void shadowColorChanged();
178 void translucentBackgroundChanged();
179 void enableSystemResizeChanged();
180 void enableSystemMoveChanged();
181 void enableBlurWindowChanged();
182 void wmWindowTypesChanged();
183 void motifFunctionsChanged();
184 void motifDecorationsChanged();
185 void alphaBufferSizeChanged();
186 void clipPathChanged();
187 void overlayExitedChanged();
188 void loadingOverlayChanged();
189 void appLoaderChanged();
190#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
191 void themeTypeChanged();
192#endif
193 void windowEffectChanged();
194 void windowStartUpEffectChanged();
195
196private:
197 D_DECLARE_PRIVATE(DQuickWindowAttached)
198 D_PRIVATE_SLOT(void _q_onWindowMotifHintsChanged(quint32))
199 D_PRIVATE_SLOT(void _q_updateBlurAreaForWindow())
200 D_PRIVATE_SLOT(void _q_updateClipPath())
201 D_PRIVATE_SLOT(void _q_ensurePlatformHandle())
202#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
203 D_PRIVATE_SLOT(void _q_onPaletteChanged())
204 D_PRIVATE_SLOT(void _q_updateWindowPalette())
205#endif
206
207 friend class DQuickBehindWindowBlur;
209};
210
211DQUICK_END_NAMESPACE
212
213QML_DECLARE_TYPEINFO(DTK_QUICK_NAMESPACE::DQuickWindow, QML_HAS_ATTACHED_PROPERTIES)
214
215#endif // DWINDOW_H
Definition dquickapploaderitem_p.h:16
Definition dquickbehindwindowblur_p_p.h:16
Definition dquickbehindwindowblur_p.h:19
Definition dquickwindow_p.h:31
Definition dquickwindow.h:50
Definition dquickwindow.h:29