Krita Source Code Documentation
Loading...
Searching...
No Matches
KisMouseClickEater.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QMouseEvent>
10#include "kis_debug.h"
11
13 int clicksToEat,
14 QObject *parent)
15 : QObject(parent),
16 m_buttons(buttons),
17 m_clicksToEat(clicksToEat)
18{
19 reset();
20}
21
25
31
32bool KisMouseClickEater::eventFilter(QObject *watched, QEvent *event)
33{
34#ifdef Q_OS_WIN
35 const int tabletMouseEventsFlowDelay = 500;
36#else
37 const int tabletMouseEventsFlowDelay = 256;
38#endif
39
40 bool blockTimedRelease = false;
41
42 if (event->type() == QEvent::TabletMove) {
43 blockTimedRelease = true;
44 }
45
46 if (!blockTimedRelease &&
47 m_timeSinceReset.elapsed() > tabletMouseEventsFlowDelay) {
48 return QObject::eventFilter(watched, event);
49 }
50
51 if (event->type() == QEvent::MouseButtonPress ||
52 event->type() == QEvent::MouseButtonRelease) {
53
54 QMouseEvent *mevent = static_cast<QMouseEvent*>(event);
55 if (mevent->button() & m_buttons) {
57 return false;
58 }
59
60 if (event->type() == QEvent::MouseButtonRelease) {
62 }
63
64 return true;
65 }
66 }
67
68 if (event->type() == QEvent::MouseMove) {
69 QMouseEvent *mevent = static_cast<QMouseEvent*>(event);
70 if (mevent->buttons() & m_buttons) {
72 }
73 }
74
75 return QObject::eventFilter(watched, event);
76}
bool eventFilter(QObject *watched, QEvent *event) override
QElapsedTimer m_timeSinceReset
KisMouseClickEater(Qt::MouseButtons buttons, int clicksToEat=1, QObject *parent=0)
Qt::MouseButtons m_buttons
QString buttons(const T &ev)