DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dpopupwindowhandle_p.h
1// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include <dtkdeclarative_global.h>
8
9#include <QtQml>
10
11#include "dqmlglobalobject_p.h"
12
13#include <private/qquickitemchangelistener_p.h>
14
15QT_BEGIN_NAMESPACE
16class QQuickWindow;
17class QQuickItem;
18QT_END_NAMESPACE
19DQUICK_BEGIN_NAMESPACE
20
21class DQuickWindowAttached;
22
23class DPopupWindowHandle : public QObject, public QQuickItemChangeListener
24{
25 Q_OBJECT
26
27 QML_UNCREATABLE("PopupHandle Attached.")
28 QML_NAMED_ELEMENT(PopupHandle)
29 QML_ATTACHED(DQuickWindowAttached)
30
31public:
32 explicit DPopupWindowHandle(QObject *popup);
33 ~DPopupWindowHandle() override;
34
35 static DQuickWindowAttached *qmlAttachedProperties(QObject *object);
36
37 DQuickWindowAttached *windowAttached() const;
38
39protected:
40 bool eventFilter(QObject *watched, QEvent *event) override;
41
42 // QQuickItemChangeListener
43 void itemGeometryChanged(QQuickItem *item,
44 QQuickGeometryChange change,
45 const QRectF &oldGeometry) override;
46
47 void itemVisibilityChanged(QQuickItem *item) override;
48
49 void itemParentChanged(QQuickItem *item, QQuickItem *oldParent) override;
50
51private Q_SLOTS:
52 void updateEnabled();
53 void onWindowChanged(QQuickWindow *window);
54
55private:
56 QQuickWindow *popupWindow() const;
57 QQuickItem *popupItem() const;
58 void popupItemReparented();
59
60 bool isEnabled() const;
61 void adjustPopupPosition();
62
63private:
64 QObject *m_popup = nullptr;
65
66 bool m_enabled = false;
67 DQuickWindowAttached *m_attached = nullptr;
68 QPointer<QQuickWindow> m_parentWindow = nullptr;
69 QPointer<QQuickWindow> m_popupWin = nullptr;
70 QPointer<QQuickItem> m_trackedItem = nullptr;
71};
72
73DQUICK_END_NAMESPACE
74
75QML_DECLARE_TYPEINFO(DTK_QUICK_NAMESPACE::DPopupWindowHandle, QML_HAS_ATTACHED_PROPERTIES)
Definition dpopupwindowhandle_p.h:24
Definition dquickwindow.h:50