KWin
Loading...
Searching...
No Matches
gesturehandler.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "effect/globals.h"
10
11#include <QQmlParserStatus>
12
13class QAction;
14
15namespace KWin
16{
17
30class SwipeGestureHandler : public QObject, public QQmlParserStatus
31{
32 Q_OBJECT
33 Q_INTERFACES(QQmlParserStatus)
34
36 Q_PROPERTY(int fingerCount READ fingerCount WRITE setFingerCount NOTIFY fingerCountChanged)
37 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
39
40public:
41 explicit SwipeGestureHandler(QObject *parent = nullptr);
42
43 // Matches SwipeDirection.
44 enum class Direction {
45 Invalid,
46 Down,
47 Left,
48 Up,
49 Right,
50 };
51 Q_ENUM(Direction)
52
53 enum class Device {
56 };
57 Q_ENUM(Device)
58
59 void classBegin() override;
60 void componentComplete() override;
61
62 Direction direction() const;
64
65 int fingerCount() const;
67
68 qreal progress() const;
69 void setProgress(qreal progress);
70
71 Device deviceType() const;
72 void setDeviceType(Device device);
73
74Q_SIGNALS:
75 void activated();
80
81private:
82 QAction *m_action = nullptr;
83 Direction m_direction = Direction::Invalid;
84 Device m_deviceType = Device::Touchpad;
85 qreal m_progress = 0;
86 int m_fingerCount = 3;
87};
88
101class PinchGestureHandler : public QObject, public QQmlParserStatus
102{
103 Q_OBJECT
104 Q_INTERFACES(QQmlParserStatus)
105
108 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
109
110public:
111 explicit PinchGestureHandler(QObject *parent = nullptr);
112
113 // Matches PinchDirection.
114 enum class Direction {
115 Expanding,
117 };
118 Q_ENUM(Direction)
119
120 enum class Device {
121 Touchpad,
122 };
123 Q_ENUM(Device)
124
125 void classBegin() override;
126 void componentComplete() override;
127
128 Direction direction() const;
130
131 int fingerCount() const;
132 void setFingerCount(int fingerCount);
133
134 qreal progress() const;
135 void setProgress(qreal progress);
136
137 Device deviceType() const;
138 void setDeviceType(Device device);
139
140Q_SIGNALS:
141 void activated();
146
147private:
148 QAction *m_action = nullptr;
149 Direction m_direction = Direction::Contracting;
150 Device m_deviceType = Device::Touchpad;
151 qreal m_progress = 0;
152 int m_fingerCount = 3;
153};
154
155} // namespace KWin
void setDirection(Direction direction)
void componentComplete() override
void setDeviceType(Device device)
void setFingerCount(int fingerCount)
void setProgress(qreal progress)
void setFingerCount(int fingerCount)
void setDeviceType(Device device)
void setProgress(qreal progress)
void setDirection(Direction direction)
void componentComplete() override
#define explicit