| 1 |
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DTREELANDPLATFORMWINDOWINTERFACE_H |
| 6 |
#define DTREELANDPLATFORMWINDOWINTERFACE_H |
| 7 |
|
| 8 |
#include "dtkgui_global.h" |
| 9 |
#include "dtreelandplatforminterface.h" |
| 10 |
#include <QObject> |
| 11 |
#include <QtWaylandClient/private/qwaylandwindow_p.h> |
| 12 |
#include "private/dplatformwindowinterface_p.h" |
| 13 |
|
| 14 |
DGUI_BEGIN_NAMESPACE |
| 15 |
class PersonalizationWindowContext; |
| 16 |
class DTreeLandPlatformWindowHelper : public QObject { |
| 17 |
Q_OBJECT |
| 18 |
public: |
| 19 |
static DTreeLandPlatformWindowHelper *get(QWindow *window); |
| 20 |
~DTreeLandPlatformWindowHelper() override; |
| 21 |
|
| 22 |
QWindow *window() const { return qobject_cast<QWindow *>(parent()); } |
| 23 |
PersonalizationWindowContext *windowContext() const; |
| 24 |
|
| 25 |
void setEnabledNoTitlebar(bool enable); |
| 26 |
void setWindowRadius(int windowRadius); |
| 27 |
void setEnableBlurWindow(bool enableBlurWindow); |
| 28 |
|
| 29 |
private slots: |
| 30 |
void onActiveChanged(); |
| 31 |
void onSurfaceCreated(); |
| 32 |
void onSurfaceDestroyed(); |
| 33 |
private: |
| 34 |
explicit DTreeLandPlatformWindowHelper(QWindow *window); |
| 35 |
bool eventFilter(QObject *watched, QEvent *event) override; |
| 36 |
void initWaylandWindow(); |
| 37 |
|
| 38 |
void doSetEnabledNoTitlebar(); |
| 39 |
void doSetWindowRadius(); |
| 40 |
void doSetEnabledBlurWindow(); |
| 41 |
private: |
| 42 |
PersonalizationWindowContext *m_windowContext = nullptr; |
| 43 |
static QMap<QWindow *, DTreeLandPlatformWindowHelper*> windowMap; |
| 44 |
|
| 45 |
bool m_isNoTitlebar = false; |
| 46 |
bool m_isWindowBlur = false; |
| 47 |
int m_radius = 0; |
| 48 |
}; |
| 49 |
|
| 50 |
class DTreeLandPlatformWindowInterface : public QObject, public DPlatformWindowInterface |
| 51 |
{ |
| 52 |
Q_OBJECT |
| 53 |
public: |
| 54 |
DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent = nullptr); |
| 55 |
~DTreeLandPlatformWindowInterface() override; |
| 56 |
|
| 57 |
void setEnabled(bool enabled) override; |
| 58 |
bool isEnabled() const override; |
| 59 |
|
| 60 |
bool isEnabledNoTitlebar() const override; |
| 61 |
bool setEnabledNoTitlebar(bool enable) override; |
| 62 |
|
| 63 |
int windowRadius() const override; |
| 64 |
void setWindowRadius(int windowRadius) override; |
| 65 |
|
| 66 |
bool enableBlurWindow() const override; |
| 67 |
void setEnableBlurWindow(bool enableBlurWindow) override; |
| 68 |
|
| 69 |
private: |
| 70 |
bool m_isNoTitlebar = false; |
| 71 |
bool m_isWindowBlur = false; |
| 72 |
int m_radius = 0; |
| 73 |
}; |
| 74 |
|
| 75 |
DGUI_END_NAMESPACE |
| 76 |
#endif // DTREELANDPLATFORMWINDOWINTERFACE_H |