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{
31 Q_OBJECT
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);
85private:
86 std::unique_ptr<class KTwoFingerTapPrivate> const d;
87};
88
89/**
90 * @class KTwoFingerTapRecognizer ktwofingertaprecognizer.h KTwoFingerTapRecognizer
91 *
92 * @short The recognizer for a two finger tap gesture.
93 *
94 * Provides the recognizer for a two finger tap gesture.
95 *
96 * @since 5.83
97 * @author Steffen Hartleib <steffenhartleib@t-online.de>
98 */
99class KWIDGETSADDONS_EXPORT KTwoFingerTapRecognizer : public QGestureRecognizer
100{
101public:
102 /**
103 * The constructor.
104 */
106
107 /**
108 * Destructor
109 */
110 ~KTwoFingerTapRecognizer() override;
111
112 /**
113 * Qt called this member to create a new QGesture object.
114 *
115 * @param target The target for the gesture.
116 *
117 * @return The new QGesture object.
118 */
119 QGesture* create(QObject *target) override;
120
121 /**
122 * Handles the given event for the watched object and update the gesture object.
123 *
124 * @param gesture The gesture object.
125 * @param watched The watched object.
126 * @param event The event.
127 *
128 * @return The result reflects how much of the gesture has been recognized.
129 */
130 Result recognize(QGesture *gesture, QObject *watched, QEvent *event) override;
131
132 /**
133 * @return The maximum wiggle room for a touch point.
134 */
135 Q_REQUIRED_RESULT int tapRadius() const;
136
137 /**
138 * Set the maximum wiggle room for a touch point. If @param i is negative, it will be set to null.
139 *
140 * @param i The maximum wiggle room.
141 */
142 void setTapRadius(int i);
143
144private:
145 std::unique_ptr<class KTwoFingerTapRecognizerPrivate> const d;
146 Q_DISABLE_COPY(KTwoFingerTapRecognizer)
147};
148
149#endif
The recognizer for a two finger tap gesture.
A two finger tap gesture.
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:51:03 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.