Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickpopup_p_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKPOPUP_P_P_H
6#define QQUICKPOPUP_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTemplates2/private/qquickpopup_p.h>
20#include <QtQuickTemplates2/private/qquickcontrol_p.h>
21#include <QtQuickTemplates2/private/qquicktheme_p.h>
22
23#include <QtCore/private/qobject_p.h>
24#include <QtQuick/qquickitem.h>
25#include <QtQuick/private/qquickitemchangelistener_p.h>
26#include <QtQuick/private/qquicktransitionmanager_p_p.h>
27#include <QtQuick/private/qquickitem_p.h>
28
29#include <QtCore/qpointer.h>
30
32
33class QQuickTransition;
34class QQuickTransitionManager;
35class QQuickPopup;
36class QQuickPopupAnchors;
37class QQuickPopupItem;
38class QQuickPopupWindow;
39class QQuickPopupPrivate;
40class QQuickPopupPositioner;
41
42class Q_QUICKTEMPLATES2_EXPORT QQuickPopupTransitionManager : public QQuickTransitionManager
43{
44public:
45 QQuickPopupTransitionManager(QQuickPopupPrivate *popup);
46
47 void transitionEnter();
48 void transitionExit();
49
50protected:
51 void finished() override;
52
53private:
54 QQuickPopupPrivate *popup = nullptr;
55};
56
57class Q_QUICKTEMPLATES2_EXPORT QQuickPopupPrivate
58 : public QObjectPrivate
59 , public QSafeQuickItemChangeListener<QQuickPopupPrivate>
60 , public QQuickPaletteProviderPrivateBase<QQuickPopup, QQuickPopupPrivate>
61{
62public:
63 Q_DECLARE_PUBLIC(QQuickPopup)
64
65 QQuickPopupPrivate();
66
67 static QQuickPopupPrivate *get(QQuickPopup *popup)
68 {
69 return popup->d_func();
70 }
71
72 QQmlListProperty<QObject> contentData();
73 QQmlListProperty<QQuickItem> contentChildren();
74
75 void init();
76 void closeOrReject();
77 bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags);
78
79 bool contains(const QPointF &scenePos) const;
80
81#if QT_CONFIG(quicktemplates2_multitouch)
82 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
83#endif
84 virtual bool blockInput(QQuickItem *item, const QPointF &point) const;
85
86 virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp);
87 virtual bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp);
88 virtual bool handleRelease(QQuickItem* item, const QPointF &point, ulong timestamp);
89 virtual bool handleReleaseWithoutGrab(const QEventPoint &) { return false; }
90 virtual void handleUngrab();
91
92 bool handleMouseEvent(QQuickItem *item, QMouseEvent *event);
93 bool handleHoverEvent(QQuickItem *item, QHoverEvent *event);
94#if QT_CONFIG(quicktemplates2_multitouch)
95 bool handleTouchEvent(QQuickItem *item, QTouchEvent *event);
96#endif
97
98 QMarginsF windowInsets() const;
99 QPointF windowInsetsTopLeft() const;
100 void setEffectivePosFromWindowPos(const QPointF &windowPos);
101 void reposition();
102
103 bool usePopupWindow() const;
104 void adjustPopupItemParentAndWindow();
105 void createOverlay();
106 QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQuickItem *parent) const;
107 void destroyDimmer();
108 void toggleOverlay();
109 void updateContentPalettes(const QPalette& parentPalette);
110
111 virtual QQuickPopup::PopupType resolvedPopupType() const;
112
113 virtual void showDimmer();
114 virtual void hideDimmer();
115 virtual void resizeDimmer();
116
117 virtual bool prepareEnterTransition();
118 virtual bool prepareExitTransition();
119 virtual void finalizeEnterTransition();
120 virtual void finalizeExitTransition();
121
122 virtual void opened();
123
124 virtual Qt::WindowFlags popupWindowType() const;
125
126 QMarginsF getMargins() const;
127
128 void setTopMargin(qreal value, bool reset = false);
129 void setLeftMargin(qreal value, bool reset = false);
130 void setRightMargin(qreal value, bool reset = false);
131 void setBottomMargin(qreal value, bool reset = false);
132
133 QQuickPopupAnchors *getAnchors();
134 virtual QQuickPopupPositioner *getPositioner();
135
136 void setWindow(QQuickWindow *window);
137 void itemDestroyed(QQuickItem *item) override;
138
139 QPalette defaultPalette() const override;
140
141 void updateChildrenPalettes(const QPalette &parentPalette) override;
142
143 enum TransitionState {
144 NoTransition, EnterTransition, ExitTransition
145 };
146
147 static const QQuickPopup::ClosePolicy DefaultClosePolicy;
148
149 bool focus = false;
150 bool modal = false;
151 bool dim = false;
152 bool hasDim = false;
153 bool visible = false;
154 bool complete = true;
155 bool positioning = false;
156 bool hasWidth = false;
157 bool hasHeight = false;
158 bool hasTopMargin = false;
159 bool hasLeftMargin = false;
160 bool hasRightMargin = false;
161 bool hasBottomMargin = false;
162 bool hasZ = false;
163 bool allowVerticalFlip = false;
164 bool allowHorizontalFlip = false;
165 bool allowVerticalMove = true;
166 bool allowHorizontalMove = true;
167 bool allowVerticalResize = true;
168 bool allowHorizontalResize = true;
169 bool hadActiveFocusBeforeExitTransition = false;
170 bool interactive = true;
171 bool hasClosePolicy = false;
172 bool outsidePressed = false;
173 bool outsideParentPressed = false;
174 bool inDestructor = false;
175 bool relaxEdgeConstraint = false;
176 bool popupWindowDirty = false;
177 bool savedLastActiveFocusItem = false;
178 int touchId = -1;
179 qreal x = 0;
180 qreal y = 0;
181 QPointF effectivePos;
182 qreal margins = -1;
183 qreal topMargin = 0;
184 qreal leftMargin = 0;
185 qreal rightMargin = 0;
186 qreal bottomMargin = 0;
187 QPointF pressPoint;
188 TransitionState transitionState = NoTransition;
189 QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy;
190 QQuickItem *parentItem = nullptr;
191 QQuickItem *dimmer = nullptr;
192 QPointer<QQuickWindow> window;
193 QQuickTransition *enter = nullptr;
194 QQuickTransition *exit = nullptr;
195 QQuickPopupItem *popupItem = nullptr;
196 QQuickPopupWindow *popupWindow = nullptr;
197 QQuickPopupPositioner *positioner = nullptr;
198 QList<QQuickStateAction> enterActions;
199 QList<QQuickStateAction> exitActions;
200 QQuickPopupTransitionManager transitionManager;
201 QQuickPopupAnchors *anchors = nullptr;
202 qreal explicitDimmerOpacity = 0;
203 qreal prevOpacity = 0;
204 qreal prevScale = 0;
205 QString title;
206 QQuickPopup::PopupType popupType = QQuickPopup::Item;
207 Qt::WindowModality popupWndModality = Qt::NonModal;
208
209 friend class QQuickPopupTransitionManager;
210};
211
212QT_END_NAMESPACE
213
214#endif // QQUICKPOPUP_P_P_H
bool isInteractiveControlType(const QQuickItem *item)
static void layoutItem(QQuickItem *item, qreal y, qreal width)
static const QQuickItemPrivate::ChangeTypes ItemChanges
Styled top-level window with support for a header and footer.
static QQuickItem * findActiveFocusControl(QQuickWindow *window)