Unity 8
MouseEventGenerator.h
1 /*
2  * Copyright (C) 2015-2016 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MOUSEEVENTGENERATOR_H
18 #define MOUSEEVENTGENERATOR_H
19 
20 #include <QObject>
21 #include <QPointF>
22 
23 #include "UbuntuGesturesQmlGlobal.h"
24 
25 class QQuickItem;
26 
27 class UBUNTUGESTURESQML_EXPORT MouseEventGenerator : public QObject {
28  Q_OBJECT
29  Q_PROPERTY(QQuickItem* targetItem MEMBER m_targetItem NOTIFY targetItemChanged)
30 
31 public:
32  MouseEventGenerator(QObject *parent = nullptr);
33 
34  Q_INVOKABLE void move(const QPointF position);
35  Q_INVOKABLE void press(const QPointF position);
36  Q_INVOKABLE void release(const QPointF position);
37 
38 Q_SIGNALS:
39  void targetItemChanged(QQuickItem *);
40 
41 private:
42  bool m_mousePressed {false};
43  QQuickItem *m_targetItem {nullptr};
44 
45  friend class tst_FloatingFlickable;
46 };
47 
48 #endif // MOUSEEVENTGENERATOR_H