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