1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKPOPUP_P_P_H
5#define QQUICKPOPUP_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTemplates2/private/qquickpopup_p.h>
19#include <QtQuickTemplates2/private/qquickcontrol_p.h>
20#include <QtQuickTemplates2/private/qquicktheme_p.h>
21
22#include <QtCore/private/qobject_p.h>
23#include <QtQuick/qquickitem.h>
24#include <QtQuick/private/qquickitemchangelistener_p.h>
25#include <QtQuick/private/qquicktransitionmanager_p_p.h>
26#include <QtQuick/private/qquickitem_p.h>
27
28QT_BEGIN_NAMESPACE
29
30class QQuickTransition;
31class QQuickTransitionManager;
32class QQuickPopup;
33class QQuickPopupAnchors;
34class QQuickPopupItem;
35class QQuickPopupPrivate;
36class QQuickPopupPositioner;
37
38class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupTransitionManager : public QQuickTransitionManager
39{
40public:
41 QQuickPopupTransitionManager(QQuickPopupPrivate *popup);
42
43 void transitionEnter();
44 void transitionExit();
45
46protected:
47 void finished() override;
48
49private:
50 QQuickPopupPrivate *popup = nullptr;
51};
52
53class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupPrivate
54 : public QObjectPrivate
55 , public QQuickItemChangeListener
56 , public QQuickPaletteProviderPrivateBase<QQuickPopup, QQuickPopupPrivate>
57{
58public:
59 Q_DECLARE_PUBLIC(QQuickPopup)
60
61 QQuickPopupPrivate();
62
63 static QQuickPopupPrivate *get(QQuickPopup *popup)
64 {
65 return popup->d_func();
66 }
67
68 QQmlListProperty<QObject> contentData();
69 QQmlListProperty<QQuickItem> contentChildren();
70
71 void init();
72 void closeOrReject();
73 bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags);
74
75 bool contains(const QPointF &scenePos) const;
76
77#if QT_CONFIG(quicktemplates2_multitouch)
78 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
79#endif
80 virtual bool blockInput(QQuickItem *item, const QPointF &point) const;
81
82 virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp);
83 virtual bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp);
84 virtual bool handleRelease(QQuickItem* item, const QPointF &point, ulong timestamp);
85 virtual void handleUngrab();
86
87 bool handleMouseEvent(QQuickItem *item, QMouseEvent *event);
88 bool handleHoverEvent(QQuickItem *item, QHoverEvent *event);
89#if QT_CONFIG(quicktemplates2_multitouch)
90 bool handleTouchEvent(QQuickItem *item, QTouchEvent *event);
91#endif
92
93 void reposition();
94
95 void createOverlay();
96 void destroyOverlay();
97 void toggleOverlay();
98 void updateContentPalettes(const QPalette& parentPalette);
99 virtual void showOverlay();
100 virtual void hideOverlay();
101 virtual void resizeOverlay();
102
103 virtual bool prepareEnterTransition();
104 virtual bool prepareExitTransition();
105 virtual void finalizeEnterTransition();
106 virtual void finalizeExitTransition();
107
108 virtual void opened();
109
110 QMarginsF getMargins() const;
111
112 void setTopMargin(qreal value, bool reset = false);
113 void setLeftMargin(qreal value, bool reset = false);
114 void setRightMargin(qreal value, bool reset = false);
115 void setBottomMargin(qreal value, bool reset = false);
116
117 QQuickPopupAnchors *getAnchors();
118 virtual QQuickPopupPositioner *getPositioner();
119
120 void setWindow(QQuickWindow *window);
121 void itemDestroyed(QQuickItem *item) override;
122
123 QPalette defaultPalette() const override;
124
125 enum TransitionState {
126 NoTransition, EnterTransition, ExitTransition
127 };
128
129 static const QQuickPopup::ClosePolicy DefaultClosePolicy;
130
131 bool focus = false;
132 bool modal = false;
133 bool dim = false;
134 bool hasDim = false;
135 bool visible = false;
136 bool complete = true;
137 bool positioning = false;
138 bool hasWidth = false;
139 bool hasHeight = false;
140 bool hasTopMargin = false;
141 bool hasLeftMargin = false;
142 bool hasRightMargin = false;
143 bool hasBottomMargin = false;
144 bool hasZ = false;
145 bool allowVerticalFlip = false;
146 bool allowHorizontalFlip = false;
147 bool allowVerticalMove = true;
148 bool allowHorizontalMove = true;
149 bool allowVerticalResize = true;
150 bool allowHorizontalResize = true;
151 bool hadActiveFocusBeforeExitTransition = false;
152 bool interactive = true;
153 bool hasClosePolicy = false;
154 bool outsidePressed = false;
155 bool outsideParentPressed = false;
156 bool inDestructor = false;
157 int touchId = -1;
158 qreal x = 0;
159 qreal y = 0;
160 qreal effectiveX = 0;
161 qreal effectiveY = 0;
162 qreal margins = -1;
163 qreal topMargin = 0;
164 qreal leftMargin = 0;
165 qreal rightMargin = 0;
166 qreal bottomMargin = 0;
167 QPointF pressPoint;
168 TransitionState transitionState = NoTransition;
169 QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy;
170 QQuickItem *parentItem = nullptr;
171 QQuickItem *dimmer = nullptr;
172 QPointer<QQuickWindow> window;
173 QQuickTransition *enter = nullptr;
174 QQuickTransition *exit = nullptr;
175 QQuickPopupItem *popupItem = nullptr;
176 QQuickPopupPositioner *positioner = nullptr;
177 QList<QQuickStateAction> enterActions;
178 QList<QQuickStateAction> exitActions;
179 QQuickPopupTransitionManager transitionManager;
180 QQuickPopupAnchors *anchors = nullptr;
181 qreal prevOpacity = 0;
182 qreal prevScale = 0;
183
184 friend class QQuickPopupTransitionManager;
185};
186
187QT_END_NAMESPACE
188
189#endif // QQUICKPOPUP_P_P_H
190

source code of qtdeclarative/src/quicktemplates/qquickpopup_p_p.h