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
83#if QT_CONFIG(quicktemplates2_multitouch)
84 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
85#endif
86 virtual bool blockInput(QQuickItem *item, const QPointF &point) const;
87
88 virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp);
89 virtual bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp);
90 virtual bool handleRelease(QQuickItem* item, const QPointF &point, ulong timestamp);
91 virtual bool handleReleaseWithoutGrab(const QEventPoint &) { return false; }
92 virtual void handleUngrab();
93
94 bool handleMouseEvent(QQuickItem *item, QMouseEvent *event);
95 bool handleHoverEvent(QQuickItem *item, QHoverEvent *event);
96#if QT_CONFIG(quicktemplates2_multitouch)
97 bool handleTouchEvent(QQuickItem *item, QTouchEvent *event);
98#endif
99
100 QMarginsF windowInsets() const;
101 QPointF windowInsetsTopLeft() const;
102 void setEffectivePosFromWindowPos(const QPointF &windowPos);
103 void reposition();
104
105 bool usePopupWindow() const;
106 void adjustPopupItemParentAndWindow();
107 void createOverlay();
108 QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQuickItem *parent) const;
109 void destroyDimmer();
110 void toggleOverlay();
111 void updateContentPalettes(const QPalette& parentPalette);
112
113 virtual QQuickPopup::PopupType resolvedPopupType() const;
114
115 virtual void showDimmer();
116 virtual void hideDimmer();
117 virtual void resizeDimmer();
118
119 virtual bool prepareEnterTransition();
120 virtual bool prepareExitTransition();
121 virtual void finalizeEnterTransition();
122 virtual void finalizeExitTransition();
123
124 virtual void opened();
125
126 Qt::WindowFlags popupWindowFlags() const;
127 void setPopupWindowFlags(Qt::WindowFlags flags);
128
129 QMarginsF getMargins() const;
130
131 void setTopMargin(qreal value, bool reset = false);
132 void setLeftMargin(qreal value, bool reset = false);
133 void setRightMargin(qreal value, bool reset = false);
134 void setBottomMargin(qreal value, bool reset = false);
135
136 QQuickPopupAnchors *getAnchors();
137 virtual QQuickPopupPositioner *getPositioner();
138
139 void setWindow(QQuickWindow *window);
140 void itemDestroyed(QQuickItem *item) override;
141
142 QPalette defaultPalette() const override;
143
144 void updateChildrenPalettes(const QPalette &parentPalette) override;
145
146 enum TransitionState {
147 NoTransition, EnterTransition, ExitTransition
148 };
149
150 static const QQuickPopup::ClosePolicy DefaultClosePolicy;
151
152 bool focus = false;
153 bool modal = false;
154 bool dim = false;
155 bool hasDim = false;
156 bool visible = false;
157 bool complete = true;
158 bool positioning = false;
159 bool hasWidth = false;
160 bool hasHeight = false;
161 bool hasTopMargin = false;
162 bool hasLeftMargin = false;
163 bool hasRightMargin = false;
164 bool hasBottomMargin = false;
165 bool hasZ = false;
166 bool allowVerticalFlip = false;
167 bool allowHorizontalFlip = false;
168 bool allowVerticalMove = true;
169 bool allowHorizontalMove = true;
170 bool allowVerticalResize = true;
171 bool allowHorizontalResize = true;
172 bool hadActiveFocusBeforeExitTransition = false;
173 bool interactive = true;
174 bool hasClosePolicy = false;
175 bool outsidePressed = false;
176 bool outsideParentPressed = false;
177 bool inDestructor = false;
178 bool relaxEdgeConstraint = false;
179 bool popupWindowDirty = false;
180 QPointer<QQuickItem> lastActiveFocusItem;
181 int touchId = -1;
182 qreal x = 0;
183 qreal y = 0;
184 QPointF effectivePos;
185 qreal margins = -1;
186 qreal topMargin = 0;
187 qreal leftMargin = 0;
188 qreal rightMargin = 0;
189 qreal bottomMargin = 0;
190 QPointF pressPoint;
191 TransitionState transitionState = NoTransition;
192 QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy;
193 QQuickItem *parentItem = nullptr;
194 QQuickItem *dimmer = nullptr;
195 QPointer<QQuickWindow> window;
196 QQuickTransition *enter = nullptr;
197 QQuickTransition *exit = nullptr;
198 QQuickPopupItem *popupItem = nullptr;
199 QQuickPopupWindow *popupWindow = nullptr;
200 QQuickPopupPositioner *positioner = nullptr;
201 QList<QQuickStateAction> enterActions;
202 QList<QQuickStateAction> exitActions;
203 QQuickPopupTransitionManager transitionManager;
204 QQuickPopupAnchors *anchors = nullptr;
205 qreal explicitDimmerOpacity = 0;
206 qreal prevOpacity = 0;
207 qreal prevScale = 0;
208 QString title;
209 QQuickPopup::PopupType popupType = QQuickPopup::Item;
210 Qt::WindowModality popupWndModality = Qt::NonModal;
211 Qt::WindowFlags windowFlags = Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint;
212#if QT_CONFIG(wayland)
213 // The extended window type is used by the wayland compositor to support things like flipping of menus and combobox popups
214 QNativeInterface::Private::QWaylandWindow::WindowType extendedWindowType = QNativeInterface::Private::QWaylandWindow::Default;
215#endif
216#if QT_CONFIG(xcb)
217 // When popupType is Popup.Window, this will end up setting the _NET_WM_WINDOW_TYPE extended window manager hint.
218 QNativeInterface::Private::QXcbWindow::WindowTypes wmWindowType = QNativeInterface::Private::QXcbWindow::None;
219#endif
220
221 friend class QQuickPopupTransitionManager;
222};
223
224QT_END_NAMESPACE
225
226#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)