#include <KisLongPressEventFilter.h>
Definition at line 12 of file KisLongPressEventFilter.h.
◆ KisLongPressEventFilter()
| KisLongPressEventFilter::KisLongPressEventFilter |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
◆ cancel()
| void KisLongPressEventFilter::cancel |
( |
| ) |
|
|
private |
◆ eventFilter()
| bool KisLongPressEventFilter::eventFilter |
( |
QObject * | watched, |
|
|
QEvent * | event ) |
|
override |
Definition at line 29 of file KisLongPressEventFilter.cpp.
30{
31 switch (event->type()) {
32 case QEvent::MouseButtonPress:
33 case QEvent::MouseButtonDblClick:
34 handleMousePress(qobject_cast<QWidget *>(watched),
static_cast<QMouseEvent *
>(event));
35 break;
36 case QEvent::MouseMove:
38 break;
39 case QEvent::MouseButtonRelease:
41 break;
42 default:
43 break;
44 }
45 return QObject::eventFilter(watched, event);
46}
void handleMousePress(QWidget *target, const QMouseEvent *me)
void handleMouseMove(const QMouseEvent *me)
References cancel(), handleMouseMove(), and handleMousePress().
◆ handleMouseMove()
| void KisLongPressEventFilter::handleMouseMove |
( |
const QMouseEvent * | me | ) |
|
|
private |
Definition at line 74 of file KisLongPressEventFilter.cpp.
75{
76#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
77 QPoint globalPos = me->globalPos();
78#else
79 QPoint globalPos = me->globalPosition().toPoint();
80#endif
83 }
84}
bool isWithinDistance(const QPoint &globalPos) const
References cancel(), isWithinDistance(), and m_timer.
◆ handleMousePress()
| void KisLongPressEventFilter::handleMousePress |
( |
QWidget * | target, |
|
|
const QMouseEvent * | me ) |
|
private |
Definition at line 48 of file KisLongPressEventFilter.cpp.
49{
51 const QStyleHints *sh = qApp->styleHints();
54#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
57#else
60#endif
62#ifdef Q_OS_ANDROID
63 int longPressInterval =
64 QAndroidJniObject::callStaticMethod<jint>("org/krita/android/MainActivity", "getLongPressTimeout", "()I");
65#else
66 int longPressInterval = sh->mousePressAndHoldInterval();
67#endif
69 } else {
71 }
72}
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
qreal distance(const QPointF &p1, const QPointF &p2)
long long m_distanceSquared
static constexpr int MINIMUM_DISTANCE
static constexpr int MINIMUM_DELAY
static bool isContextMenuTarget(QWidget *target)
References cancel(), distance(), isContextMenuTarget(), m_distanceSquared, m_pressGlobalPos, m_pressLocalPos, m_target, m_timer, MINIMUM_DELAY, MINIMUM_DISTANCE, and target().
◆ isContextMenuTarget()
| bool KisLongPressEventFilter::isContextMenuTarget |
( |
QWidget * | target | ) |
|
|
staticprivate |
Definition at line 107 of file KisLongPressEventFilter.cpp.
108{
110 switch (
target->contextMenuPolicy()) {
111 case Qt::NoContextMenu:
113 break;
114 case Qt::PreventContextMenu:
115 return false;
116 default:
117 return true;
118 }
119 }
120 return false;
121}
static bool isLongPressableWidget(QWidget *target)
References isLongPressableWidget(), and target().
◆ isLongPressableWidget()
| bool KisLongPressEventFilter::isLongPressableWidget |
( |
QWidget * | target | ) |
|
|
staticprivate |
Definition at line 123 of file KisLongPressEventFilter.cpp.
124{
126 if (prop.isValid()) {
127 return prop.toBool();
128 }
129
130
131
132
133
134
135
136
137
138
139 if (qobject_cast<QAbstractButton *>(
target)) {
140 return false;
141 }
142
143
144
145 if (qobject_cast<QAbstractScrollArea *>(
target)) {
146 return false;
147 }
148
149
150 if (qobject_cast<QAbstractSlider *>(
target)) {
151 return false;
152 }
153
154
155 if (qobject_cast<QAbstractSpinBox *>(
target)) {
156 return false;
157 }
158
159
160 if (qobject_cast<QComboBox *>(
target)) {
161 return false;
162 }
163
164
165 if (qobject_cast<QLineEdit *>(
target)) {
166 return false;
167 }
168
169
170 if (qobject_cast<QMenu *>(
target)) {
171 return false;
172 }
173
174
175 if (qobject_cast<QMenuBar *>(
target)) {
176 return false;
177 }
178
179 return true;
180}
static constexpr char ENABLED_PROPERTY[]
References ENABLED_PROPERTY, and target().
◆ isWithinDistance()
| bool KisLongPressEventFilter::isWithinDistance |
( |
const QPoint & | globalPos | ) |
const |
|
private |
◆ triggerLongPress()
| void KisLongPressEventFilter::triggerLongPress |
( |
| ) |
|
|
private |
◆ ENABLED_PROPERTY
| constexpr char KisLongPressEventFilter::ENABLED_PROPERTY[] = "KRITA_LONG_PRESS" |
|
staticconstexpr |
◆ m_distanceSquared
| long long KisLongPressEventFilter::m_distanceSquared = 0LL |
|
private |
◆ m_pressGlobalPos
| QPoint KisLongPressEventFilter::m_pressGlobalPos |
|
private |
◆ m_pressLocalPos
| QPoint KisLongPressEventFilter::m_pressLocalPos |
|
private |
◆ m_target
| QPointer<QWidget> KisLongPressEventFilter::m_target |
|
private |
◆ m_timer
| QTimer* KisLongPressEventFilter::m_timer |
|
private |
◆ MINIMUM_DELAY
| constexpr int KisLongPressEventFilter::MINIMUM_DELAY = 100 |
|
staticconstexprprivate |
◆ MINIMUM_DISTANCE
| constexpr int KisLongPressEventFilter::MINIMUM_DISTANCE = 0 |
|
staticconstexprprivate |
The documentation for this class was generated from the following files: