2
* Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
17
#ifndef UBUNTU_TOUCH_DISPATCHER_H
18
#define UBUNTU_TOUCH_DISPATCHER_H
20
#include "UbuntuGesturesQmlGlobal.h"
26
Dispatches touches to the given target, converting the touch point
27
coordinates accordingly.
29
Also takes care of synthesizing mouse events in case the target
30
doesn't work with touch events.
32
class UBUNTUGESTURESQML_EXPORT TouchDispatcher {
36
void setTargetItem(QQuickItem *target);
37
QQuickItem *targetItem() { return m_targetItem; }
39
void dispatch(QEvent::Type eventType,
41
Qt::KeyboardModifiers modifiers,
42
const QList<QTouchEvent::TouchPoint> &touchPoints,
46
void dispatchTouchBegin(
48
Qt::KeyboardModifiers modifiers,
49
const QList<QTouchEvent::TouchPoint> &touchPoints,
52
void dispatchAsTouch(QEvent::Type eventType,
54
Qt::KeyboardModifiers modifiers,
55
const QList<QTouchEvent::TouchPoint> &touchPoints,
60
Qt::KeyboardModifiers modifiers,
61
const QList<QTouchEvent::TouchPoint> &touchPoints,
64
static void transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform);
65
QTouchEvent *createQTouchEvent(QEvent::Type eventType,
67
Qt::KeyboardModifiers modifiers,
68
const QList<QTouchEvent::TouchPoint> &touchPoints,
71
QMouseEvent *touchToMouseEvent(QEvent::Type type, const QTouchEvent::TouchPoint &p,
72
ulong timestamp, Qt::KeyboardModifiers modifiers, bool transformNeeded = true);
74
bool checkIfDoubleClicked(ulong newPressEventTimestamp);
76
QPointer<QQuickItem> m_targetItem;
80
DeliveringTouchEvents,
81
DeliveringMouseEvents,
86
ulong m_touchMousePressTimestamp;
89
#endif // UBUNTU_TOUCH_DISPATCHER_H