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 QQUICKOVERLAY_P_H
38 #define QQUICKOVERLAY_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 <QtQuick/qquickitem.h>
52 #include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
53 
54 QT_BEGIN_NAMESPACE
55 
56 class QQmlComponent;
57 class QQuickOverlayPrivate;
58 class QQuickOverlayAttached;
59 class QQuickOverlayAttachedPrivate;
60 
61 class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickOverlay : public QQuickItem
62 {
63     Q_OBJECT
64     Q_PROPERTY(QQmlComponent *modal READ modal WRITE setModal NOTIFY modalChanged FINAL)
65     Q_PROPERTY(QQmlComponent *modeless READ modeless WRITE setModeless NOTIFY modelessChanged FINAL)
66 
67 public:
68     explicit QQuickOverlay(QQuickItem *parent = nullptr);
69     ~QQuickOverlay();
70 
71     QQmlComponent *modal() const;
72     void setModal(QQmlComponent *modal);
73 
74     QQmlComponent *modeless() const;
75     void setModeless(QQmlComponent *modeless);
76 
77     static QQuickOverlay *overlay(QQuickWindow *window);
78 
79     static QQuickOverlayAttached *qmlAttachedProperties(QObject *object);
80 
81 Q_SIGNALS:
82     void modalChanged();
83     void modelessChanged();
84     void pressed();
85     void released();
86 
87 protected:
88     void itemChange(ItemChange change, const ItemChangeData &data) override;
89     void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
90 
91     void mousePressEvent(QMouseEvent *event) override;
92     void mouseMoveEvent(QMouseEvent *event) override;
93     void mouseReleaseEvent(QMouseEvent *event) override;
94 #if QT_CONFIG(quicktemplates2_multitouch)
95     void touchEvent(QTouchEvent *event) override;
96 #endif
97 #if QT_CONFIG(wheelevent)
98     void wheelEvent(QWheelEvent *event) override;
99 #endif
100     bool childMouseEventFilter(QQuickItem *item, QEvent *event) override;
101     bool eventFilter(QObject *object, QEvent *event) override;
102 
103 private:
104     Q_DISABLE_COPY(QQuickOverlay)
105     Q_DECLARE_PRIVATE(QQuickOverlay)
106 };
107 
108 class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickOverlayAttached : public QObject
109 {
110     Q_OBJECT
111     Q_PROPERTY(QQuickOverlay *overlay READ overlay NOTIFY overlayChanged FINAL)
112     Q_PROPERTY(QQmlComponent *modal READ modal WRITE setModal NOTIFY modalChanged FINAL)
113     Q_PROPERTY(QQmlComponent *modeless READ modeless WRITE setModeless NOTIFY modelessChanged FINAL)
114 
115 public:
116     explicit QQuickOverlayAttached(QObject *parent = nullptr);
117 
118     QQuickOverlay *overlay() const;
119 
120     QQmlComponent *modal() const;
121     void setModal(QQmlComponent *modal);
122 
123     QQmlComponent *modeless() const;
124     void setModeless(QQmlComponent *modeless);
125 
126 Q_SIGNALS:
127     void overlayChanged();
128     void modalChanged();
129     void modelessChanged();
130     void pressed();
131     void released();
132 
133 private:
134     Q_DISABLE_COPY(QQuickOverlayAttached)
135     Q_DECLARE_PRIVATE(QQuickOverlayAttached)
136 };
137 
138 QT_END_NAMESPACE
139 
140 QML_DECLARE_TYPE(QQuickOverlay)
141 QML_DECLARE_TYPEINFO(QQuickOverlay, QML_HAS_ATTACHED_PROPERTIES)
142 
143 #endif // QQUICKOVERLAY_P_H
144