File indexing completed on 2024-12-01 11:10:42
0001 /* 0002 SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef VIEWEVENTSSINK_H 0007 #define VIEWEVENTSSINK_H 0008 0009 // Qt 0010 #include <QEvent> 0011 #include <QObject> 0012 #include <QList> 0013 #include <QPointer> 0014 #include <QQuickItem> 0015 0016 namespace Latte { 0017 class View; 0018 } 0019 0020 namespace Latte { 0021 namespace ViewPart { 0022 0023 //! This class is used in order to sunk events from children rects of originParentItem 0024 //! into the destination Item. Each applet container from containment qml part is responsible 0025 //! to initialize properly the originParentItem and the destinationItem to be used for 0026 //! sunk events 0027 0028 class EventsSink: public QObject 0029 { 0030 Q_OBJECT 0031 0032 Q_PROPERTY(QQuickItem *originParentItem READ originParentItem NOTIFY itemsChanged) 0033 Q_PROPERTY(QQuickItem *destinationItem READ destinationItem NOTIFY itemsChanged) 0034 0035 public: 0036 EventsSink(Latte::View *parent); 0037 virtual ~EventsSink(); 0038 0039 bool isActive(); 0040 0041 QQuickItem *originParentItem() const; 0042 QQuickItem *destinationItem() const; 0043 0044 public slots: 0045 Q_INVOKABLE void setSink(QQuickItem *originParent, QQuickItem *destination); 0046 0047 QEvent *onEvent(QEvent *e); 0048 0049 signals: 0050 void itemsChanged(); 0051 0052 private slots: 0053 void release(); 0054 0055 private: 0056 QPointF positionAdjustedForDestination(const QPointF &point) const; 0057 0058 bool originSinksContain(const QPointF &point) const; 0059 bool destinationContains(const QPointF &point) const; 0060 private: 0061 QPointer<Latte::View> m_view; 0062 0063 QPointer<QQuickItem> m_originParentItem; 0064 QPointer<QQuickItem> m_destinationItem; 0065 }; 0066 0067 } 0068 } 0069 0070 #endif 0071