KWidgetsAddons

ktwofingertap.h
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2021 Steffen Hartleib <steffenhartleib@t-online.de>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#ifndef KTWOFINGERTAP_H
9#define KTWOFINGERTAP_H
10
11#include <kwidgetsaddons_export.h>
12
13#include <QGesture>
14#include <QGestureRecognizer>
15#include <memory>
16
17/**
18 * @class KTwoFingerTap ktwofingertap.h KTwoFingerTap
19 *
20 * @short A two finger tap gesture.
21 *
22 * Provides a class for a two finger tap gesture.
23 *
24 * Note: The QGestureManager need a QMainwindow, to delivery the gesture.
25 *
26 * @since 5.83
27 * @author Steffen Hartleib <steffenhartleib@t-online.de>
28 */
29class KWIDGETSADDONS_EXPORT KTwoFingerTap : public QGesture
30{
32 Q_PROPERTY(QPointF pos READ pos WRITE setPos)
33 Q_PROPERTY(QPointF screenPos READ screenPos WRITE setScreenPos)
34 Q_PROPERTY(QPointF scenePos READ scenePos WRITE setScenePos)
35public:
36 /**
37 * The constructor.
38 */
39 explicit KTwoFingerTap(QObject *parent = nullptr);
40
41 /**
42 * Destructor
43 */
44 ~KTwoFingerTap() override;
45
46 /**
47 * The position of the gesture, relative to the widget that received the gesture.
48 *
49 * Note: This is not necessarily the same position as in the widget that grabGesture() uses.
50 *
51 * @return The position of the gesture.
52 */
53 Q_REQUIRED_RESULT QPointF pos() const;
54
55 /**
56 * Sets the position, relative to the widget.
57 *
58 * @param pos The position.
59 */
60 void setPos(QPointF pos);
61
62 /**
63 * Sets the screen position.
64 *
65 * @param screenPos The screen position.
66 */
67 Q_REQUIRED_RESULT QPointF screenPos() const;
68
69 /**
70 * @return The start scene position of the gesture.
71 */
72 void setScreenPos(QPointF screenPos);
73
74 /**
75 * @return The start scene position of the gesture.
76 */
77 Q_REQUIRED_RESULT QPointF scenePos() const;
78
79 /**
80 * Sets the scene position.
81 *
82 * @param scenePos The scene position, identical to the screen position for widgets.
83 */
84 void setScenePos(QPointF scenePos);
85
86private:
87 std::unique_ptr<class KTwoFingerTapPrivate> const d;
88};
89
90/**
91 * @class KTwoFingerTapRecognizer ktwofingertaprecognizer.h KTwoFingerTapRecognizer
92 *
93 * @short The recognizer for a two finger tap gesture.
94 *
95 * Provides the recognizer for a two finger tap gesture.
96 *
97 * @since 5.83
98 * @author Steffen Hartleib <steffenhartleib@t-online.de>
99 */
100class KWIDGETSADDONS_EXPORT KTwoFingerTapRecognizer : public QGestureRecognizer
101{
102public:
103 /**
104 * The constructor.
105 */
107
108 /**
109 * Destructor
110 */
111 ~KTwoFingerTapRecognizer() override;
112
113 /**
114 * Qt called this member to create a new QGesture object.
115 *
116 * @param target The target for the gesture.
117 *
118 * @return The new QGesture object.
119 */
120 QGesture *create(QObject *target) override;
121
122 /**
123 * Handles the given event for the watched object and update the gesture object.
124 *
125 * @param gesture The gesture object.
126 * @param watched The watched object.
127 * @param event The event.
128 *
129 * @return The result reflects how much of the gesture has been recognized.
130 */
131 Result recognize(QGesture *gesture, QObject *watched, QEvent *event) override;
132
133 /**
134 * @return The maximum wiggle room for a touch point.
135 */
136 Q_REQUIRED_RESULT int tapRadius() const;
137
138 /**
139 * Set the maximum wiggle room for a touch point. If @param i is negative, it will be set to null.
140 *
141 * @param i The maximum wiggle room.
142 */
143 void setTapRadius(int i);
144
145private:
146 std::unique_ptr<class KTwoFingerTapRecognizerPrivate> const d;
147 Q_DISABLE_COPY(KTwoFingerTapRecognizer)
148};
149
150#endif
void setTapRadius(int i)
Set the maximum wiggle room for a touch point.
Result recognize(QGesture *gesture, QObject *watched, QEvent *event) override
Handles the given event for the watched object and update the gesture object.
QGesture * create(QObject *target) override
Qt called this member to create a new QGesture object.
KTwoFingerTapRecognizer()
The constructor.
void setPos(QPointF pos)
Sets the position, relative to the widget.
KTwoFingerTap(QObject *parent=nullptr)
The constructor.
void setScenePos(QPointF scenePos)
Sets the scene position.
void setScreenPos(QPointF screenPos)
QGesture(QObject *parent)
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 28 2025 12:02:04 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.