1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2017 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL3$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or later as published by the Free 28 ** Software Foundation and appearing in the file LICENSE.GPL included in 29 ** the packaging of this file. Please review the following information to 30 ** ensure the GNU General Public License version 2.0 requirements will be 31 ** met: http://www.gnu.org/licenses/gpl-2.0.html. 32 ** 33 ** $QT_END_LICENSE$ 34 ** 35 ****************************************************************************/ 36 37 #ifndef QQUICKPOPUP_P_P_H 38 #define QQUICKPOPUP_P_P_H 39 40 // 41 // W A R N I N G 42 // ------------- 43 // 44 // This file is not part of the Qt API. It exists purely as an 45 // implementation detail. This header file may change from version to 46 // version without notice, or even be removed. 47 // 48 // We mean it. 49 // 50 51 #include <QtQuickTemplates2/private/qquickpopup_p.h> 52 #include <QtQuickTemplates2/private/qquickcontrol_p.h> 53 54 #include <QtCore/private/qobject_p.h> 55 #include <QtQuick/qquickitem.h> 56 #include <QtQuick/private/qquickitemchangelistener_p.h> 57 #include <QtQuick/private/qquicktransitionmanager_p_p.h> 58 59 QT_BEGIN_NAMESPACE 60 61 class QQuickTransition; 62 class QQuickTransitionManager; 63 class QQuickPopup; 64 class QQuickPopupAnchors; 65 class QQuickPopupItem; 66 class QQuickPopupPrivate; 67 class QQuickPopupPositioner; 68 69 class QQuickPopupTransitionManager : public QQuickTransitionManager 70 { 71 public: 72 QQuickPopupTransitionManager(QQuickPopupPrivate *popup); 73 74 void transitionEnter(); 75 void transitionExit(); 76 77 protected: 78 void finished() override; 79 80 private: 81 QQuickPopupPrivate *popup = nullptr; 82 }; 83 84 class Q_AUTOTEST_EXPORT QQuickPopupPrivate : public QObjectPrivate, public QQuickItemChangeListener 85 { 86 Q_DECLARE_PUBLIC(QQuickPopup) 87 88 public: 89 QQuickPopupPrivate(); 90 get(QQuickPopup * popup)91 static QQuickPopupPrivate *get(QQuickPopup *popup) 92 { 93 return popup->d_func(); 94 } 95 96 QQmlListProperty<QObject> contentData(); 97 QQmlListProperty<QQuickItem> contentChildren(); 98 99 void init(); 100 void closeOrReject(); 101 bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags); 102 103 bool contains(const QPointF &scenePos) const; 104 105 #if QT_CONFIG(quicktemplates2_multitouch) 106 virtual bool acceptTouch(const QTouchEvent::TouchPoint &point); 107 #endif 108 virtual bool blockInput(QQuickItem *item, const QPointF &point) const; 109 110 virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp); 111 virtual bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp); 112 virtual bool handleRelease(QQuickItem* item, const QPointF &point, ulong timestamp); 113 virtual void handleUngrab(); 114 115 bool handleMouseEvent(QQuickItem *item, QMouseEvent *event); 116 #if QT_CONFIG(quicktemplates2_multitouch) 117 bool handleTouchEvent(QQuickItem *item, QTouchEvent *event); 118 #endif 119 120 void reposition(); 121 122 void createOverlay(); 123 void destroyOverlay(); 124 void toggleOverlay(); 125 virtual void showOverlay(); 126 virtual void hideOverlay(); 127 virtual void resizeOverlay(); 128 129 virtual bool prepareEnterTransition(); 130 virtual bool prepareExitTransition(); 131 virtual void finalizeEnterTransition(); 132 virtual void finalizeExitTransition(); 133 134 QMarginsF getMargins() const; 135 136 void setTopMargin(qreal value, bool reset = false); 137 void setLeftMargin(qreal value, bool reset = false); 138 void setRightMargin(qreal value, bool reset = false); 139 void setBottomMargin(qreal value, bool reset = false); 140 141 QQuickPopupAnchors *getAnchors(); 142 virtual QQuickPopupPositioner *getPositioner(); 143 144 void setWindow(QQuickWindow *window); 145 void itemDestroyed(QQuickItem *item) 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 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 int touchId = -1; 176 qreal x = 0; 177 qreal y = 0; 178 qreal effectiveX = 0; 179 qreal effectiveY = 0; 180 qreal margins = -1; 181 qreal topMargin = 0; 182 qreal leftMargin = 0; 183 qreal rightMargin = 0; 184 qreal bottomMargin = 0; 185 QPointF pressPoint; 186 TransitionState transitionState = NoTransition; 187 QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy; 188 QQuickItem *parentItem = nullptr; 189 QQuickItem *dimmer = nullptr; 190 QPointer<QQuickWindow> window; 191 QQuickTransition *enter = nullptr; 192 QQuickTransition *exit = nullptr; 193 QQuickPopupItem *popupItem = nullptr; 194 QQuickPopupPositioner *positioner = nullptr; 195 QList<QQuickStateAction> enterActions; 196 QList<QQuickStateAction> exitActions; 197 QQuickPopupTransitionManager transitionManager; 198 QQuickPopupAnchors *anchors = nullptr; 199 200 friend class QQuickPopupTransitionManager; 201 }; 202 203 QT_END_NAMESPACE 204 205 #endif // QQUICKPOPUP_P_P_H 206