Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLongPressEventFilter.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#ifndef __KISLONGPRESSEVENTFILTER_H
3#define __KISLONGPRESSEVENTFILTER_H
4#include <QObject>
5#include <QPoint>
6#include <QPointer>
7#include <QWidget>
8
9class QMouseEvent;
10class QScroller;
11class QTimer;
12
13class KisLongPressEventFilter : public QObject
14{
15 Q_OBJECT
16public:
17 static constexpr char ENABLED_PROPERTY[] = "KRITA_LONG_PRESS";
18
19 explicit KisLongPressEventFilter(QObject *parent = nullptr);
20
21 bool eventFilter(QObject *watched, QEvent *event) override;
22
23private:
24 static constexpr int MINIMUM_DELAY = 100;
25 static constexpr int MINIMUM_DISTANCE = 0;
26
27 bool handleMousePress(QWidget *target, const QMouseEvent *me);
28 bool handleMouseMove(const QMouseEvent *me);
29 void flush();
30 void cancel();
31
32 bool isWithinDistance(const QPoint &globalPos) const;
33
34 int getKineticScrollDelay(QWidget *target) const;
35 static const QScroller *searchScroller(QWidget *target);
36
37 void triggerLongPress();
38
39 static bool isContextMenuTarget(QWidget *target);
40 static bool isLongPressableWidget(QWidget *target);
41
42 QTimer *m_timer;
43 long long m_distanceSquared = 0LL;
47#ifdef Q_OS_ANDROID
48 int m_longPressTimeout;
49#endif
50 bool m_handlingEvent = false;
51};
52
53#endif
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static constexpr char ENABLED_PROPERTY[]
bool handleMouseMove(const QMouseEvent *me)
int getKineticScrollDelay(QWidget *target) const
bool handleMousePress(QWidget *target, const QMouseEvent *me)
static constexpr int MINIMUM_DISTANCE
KisLongPressEventFilter(QObject *parent=nullptr)
bool isWithinDistance(const QPoint &globalPos) const
static bool isLongPressableWidget(QWidget *target)
bool eventFilter(QObject *watched, QEvent *event) override
static const QScroller * searchScroller(QWidget *target)
static constexpr int MINIMUM_DELAY
static bool isContextMenuTarget(QWidget *target)