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 <QtGui/qpa/qplatformwindow.h>
25#include <QtGui/qpa/qplatformwindow_p.h>
26#include <QtQuick/qquickitem.h>
27#include <QtQuick/private/qquickitemchangelistener_p.h>
28#include <QtQuick/private/qquicktransitionmanager_p_p.h>
29#include <QtQuick/private/qquickitem_p.h>
30
31#include <QtCore/qpointer.h>
32
34
35class QQuickTransition;
36class QQuickTransitionManager;
37class QQuickPopup;
38class QQuickPopupAnchors;
39class QQuickPopupItem;
40class QQuickPopupWindow;
41class QQuickPopupPrivate;
42class QQuickPopupPositioner;
43
44class Q_QUICKTEMPLATES2_EXPORT QQuickPopupTransitionManager : public QQuickTransitionManager
45{
46public:
47 QQuickPopupTransitionManager(QQuickPopupPrivate *popup);
48
49 void transitionEnter();
50 void transitionExit();
51
52protected:
53 void finished() override;
54
55private:
56 QQuickPopupPrivate *popup = nullptr;
57};
58
59class Q_QUICKTEMPLATES2_EXPORT QQuickPopupPrivate
60 : public QObjectPrivate
61 , public QSafeQuickItemChangeListener<QQuickPopupPrivate>
62 , public QQuickPaletteProviderPrivateBase<QQuickPopup, QQuickPopupPrivate>
63{
64public:
65 Q_DECLARE_PUBLIC(QQuickPopup)
66
67 QQuickPopupPrivate();
68
69 static QQuickPopupPrivate *get(QQuickPopup *popup)
70 {
71 return popup->d_func();
72 }
73
74 QQmlListProperty<QObject> contentData();
75 QQmlListProperty<QQuickItem> contentChildren();
76
77 void init();
78 void closeOrReject();
79 bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags);
80
81 bool contains(const QPointF &scenePos) const;
82 bool belongsToOverlayChildAbove(QQuickItem *item) const;
83
84#if QT_CONFIG(quicktemplates2_multitouch)
85 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
86#endif
87 virtual bool blockInput(QQuickItem *item, const QPointF &point) const;
88
89 virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp);
90 virtual bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp);
91 virtual bool handleRelease(QQuickItem* item, const QEventPoint &point);
92 virtual bool handleReleaseWithoutGrab(const QEventPoint &) { return false; }
93 virtual void handleUngrab();
94
95 bool handleMouseEvent(QQuickItem *item, QMouseEvent *event);
96 bool handleHoverEvent(QQuickItem *item, QHoverEvent *event);
97#if QT_CONFIG(quicktemplates2_multitouch)
98 bool handleTouchEvent(QQuickItem *item, QTouchEvent *event);
99#endif
100
101 QMarginsF windowInsets() const;
102 QPointF windowInsetsTopLeft() const;
103 void setEffectivePosFromWindowPos(const QPointF &windowPos);
104 void reposition();
105
106 bool usePopupWindow() const;
107 void adjustPopupItemParentAndWindow();
108 void createOverlay();
109 QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQuickItem *parent) const;
110 void destroyDimmer();
111 void toggleOverlay();
112 void updateContentPalettes(const QPalette& parentPalette);
113
114 virtual QQuickPopup::PopupType resolvedPopupType() const;
115
116 virtual void showDimmer();
117 virtual void hideDimmer();
118 virtual void resizeDimmer();
119
120 virtual bool prepareEnterTransition();
121 virtual bool prepareExitTransition();
122 virtual void finalizeEnterTransition();
123 virtual void finalizeExitTransition();
124
125 virtual void opened();
126
127 Qt::WindowFlags popupWindowFlags() const;
128 void setPopupWindowFlags(Qt::WindowFlags flags);
129
130 QMarginsF getMargins() const;
131
132 void setTopMargin(qreal value, bool reset = false);
133 void setLeftMargin(qreal value, bool reset = false);
134 void setRightMargin(qreal value, bool reset = false);
135 void setBottomMargin(qreal value, bool reset = false);
136
137 QQuickPopupAnchors *getAnchors();
138 virtual QQuickPopupPositioner *getPositioner();
139
140 void setWindow(QQuickWindow *window);
141 void itemDestroyed(QQuickItem *item) override;
142
143 QPalette defaultPalette() const override;
144
145 void updateChildrenPalettes(const QPalette &parentPalette) override;
146
147 enum TransitionState {
148 NoTransition, EnterTransition, ExitTransition
149 };
150
151 static const QQuickPopup::ClosePolicy DefaultClosePolicy;
152
153 bool focus = false;
154 bool modal = false;
155 bool dim = false;
156 bool hasDim = false;
157 bool visible = false;
158 bool complete = true;
159 bool positioning = false;
160 bool hasWidth = false;
161 bool hasHeight = false;
162 bool hasTopMargin = false;
163 bool hasLeftMargin = false;
164 bool hasRightMargin = false;
165 bool hasBottomMargin = false;
166 bool hasZ = false;
167 bool allowVerticalFlip = false;
168 bool allowHorizontalFlip = false;
169 bool allowVerticalMove = true;
170 bool allowHorizontalMove = true;
171 bool allowVerticalResize = true;
172 bool allowHorizontalResize = true;
173 bool hadActiveFocusBeforeExitTransition = false;
174 bool interactive = true;
175 bool hasClosePolicy = false;
176 bool outsidePressed = false;
177 bool outsideParentPressed = false;
178 bool inDestructor = false;
179 bool relaxEdgeConstraint = false;
180 bool popupWindowDirty = false;
181 QPointer<QQuickItem> lastActiveFocusItem;
182 int touchId = -1;
183 qreal x = 0;
184 qreal y = 0;
185 QPointF effectivePos;
186 qreal margins = -1;
187 qreal topMargin = 0;
188 qreal leftMargin = 0;
189 qreal rightMargin = 0;
190 qreal bottomMargin = 0;
191 QPointF pressPoint;
192 TransitionState transitionState = NoTransition;
193 QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy;
194 QQuickItem *parentItem = nullptr;
195 QQuickItem *dimmer = nullptr;
196 QPointer<QQuickWindow> window;
197 QQuickTransition *enter = nullptr;
198 QQuickTransition *exit = nullptr;
199 QQuickPopupItem *popupItem = nullptr;
200 QQuickPopupWindow *popupWindow = nullptr;
201 QQuickPopupPositioner *positioner = nullptr;
202 QList<QQuickStateAction> enterActions;
203 QList<QQuickStateAction> exitActions;
204 QQuickPopupTransitionManager transitionManager;
205 QQuickPopupAnchors *anchors = nullptr;
206 qreal explicitDimmerOpacity = 0;
207 qreal prevOpacity = 0;
208 qreal prevScale = 0;
209 QString title;
210 QQuickPopup::PopupType popupType = QQuickPopup::Item;
211 Qt::WindowModality popupWndModality = Qt::NonModal;
212 Qt::WindowFlags windowFlags = Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint;
213#if QT_CONFIG(wayland)
214 // The extended window type is used by the wayland compositor to support things like flipping of menus and combobox popups
215 QNativeInterface::Private::QWaylandWindow::WindowType extendedWindowType = QNativeInterface::Private::QWaylandWindow::Default;
216#endif
217#if QT_CONFIG(xcb)
218 // When popupType is Popup.Window, this will end up setting the _NET_WM_WINDOW_TYPE extended window manager hint.
219 QNativeInterface::Private::QXcbWindow::WindowTypes wmWindowType = QNativeInterface::Private::QXcbWindow::None;
220#endif
221
222 friend class QQuickPopupTransitionManager;
223};
224
225QT_END_NAMESPACE
226
227#endif // QQUICKPOPUP_P_P_H
bool isInteractiveControlType(const QQuickItem *item)
Combined button and popup list for selecting options.
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)