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 QTimer;
11
12class KisLongPressEventFilter : public QObject
13{
14 Q_OBJECT
15public:
16 static constexpr char ENABLED_PROPERTY[] = "KRITA_LONG_PRESS";
17
18 explicit KisLongPressEventFilter(QObject *parent = nullptr);
19
20 bool eventFilter(QObject *watched, QEvent *event) override;
21
22private:
23 static constexpr int MINIMUM_DELAY = 100;
24 static constexpr int MINIMUM_DISTANCE = 0;
25
26 void handleMousePress(QWidget *target, const QMouseEvent *me);
27 void handleMouseMove(const QMouseEvent *me);
28 void cancel();
29
30 bool isWithinDistance(const QPoint &globalPos) const;
31
32 void triggerLongPress();
33
34 static bool isContextMenuTarget(QWidget *target);
35 static bool isLongPressableWidget(QWidget *target);
36
37 QTimer *m_timer;
38 long long m_distanceSquared = 0LL;
42};
43
44#endif
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static constexpr char ENABLED_PROPERTY[]
void handleMousePress(QWidget *target, const QMouseEvent *me)
static constexpr int MINIMUM_DISTANCE
KisLongPressEventFilter(QObject *parent=nullptr)
bool isWithinDistance(const QPoint &globalPos) const
void handleMouseMove(const QMouseEvent *me)
static bool isLongPressableWidget(QWidget *target)
bool eventFilter(QObject *watched, QEvent *event) override
static constexpr int MINIMUM_DELAY
static bool isContextMenuTarget(QWidget *target)