4#include <QAbstractButton>
5#include <QAbstractScrollArea>
6#include <QAbstractSlider>
7#include <QAbstractSpinBox>
10#include <QContextMenuEvent>
16#include <QScopedValueRollback>
28 m_timer->setTimerType(Qt::CoarseTimer);
33 QAndroidJniObject::callStaticMethod<jint>(
"org/krita/android/MainActivity",
"getLongPressTimeout",
"()I");
41 switch (event->type()) {
42 case QEvent::MouseButtonPress:
43 if (
handleMousePress(qobject_cast<QWidget *>(watched),
static_cast<QMouseEvent *
>(event))) {
44 event->setAccepted(
true);
48 case QEvent::MouseMove:
53 case QEvent::MouseButtonDblClick:
54 case QEvent::MouseButtonRelease:
61 return QObject::eventFilter(watched, event);
67 const QStyleHints *sh = qApp->styleHints();
70#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
87 int longPressInterval = m_longPressTimeout;
89 int longPressInterval = sh->mousePressAndHoldInterval();
97 m_timer->start(qMax(0, longPressInterval - kineticScrollDelay));
108#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
109 QPoint globalPos = me->globalPos();
111 QPoint globalPos = me->globalPosition().toPoint();
127 QMouseEvent event(QEvent::MouseButtonPress,
133 qApp->sendEvent(
target, &event);
161 QMouseEvent pressEvent(QEvent::MouseButtonPress,
167 qApp->sendEvent(
target, &pressEvent);
170 QMouseEvent releaseEvent(QEvent::MouseButtonRelease,
176 qApp->sendEvent(
target, &releaseEvent);
193 qreal pressDelay = scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal();
194 if (pressDelay < 0.0) {
198 return int(pressDelay * 1000.0);
204 if (QScroller::hasScroller(
target)) {
205 return QScroller::scroller(
target);
216 switch (
target->contextMenuPolicy()) {
217 case Qt::NoContextMenu:
220 case Qt::PreventContextMenu:
232 if (prop.isValid()) {
233 return prop.toBool();
245 if (qobject_cast<QAbstractButton *>(
target)) {
251 if (qobject_cast<QAbstractScrollArea *>(
target)) {
256 if (qobject_cast<QAbstractSlider *>(
target)) {
261 if (qobject_cast<QAbstractSpinBox *>(
target)) {
266 if (qobject_cast<QComboBox *>(
target)) {
271 if (qobject_cast<QLineEdit *>(
target)) {
276 if (qobject_cast<QMenu *>(
target)) {
281 if (qobject_cast<QMenuBar *>(
target)) {
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
qreal distance(const QPointF &p1, const QPointF &p2)
static constexpr char ENABLED_PROPERTY[]
bool handleMouseMove(const QMouseEvent *me)
int getKineticScrollDelay(QWidget *target) const
long long m_distanceSquared
bool handleMousePress(QWidget *target, const QMouseEvent *me)
static constexpr int MINIMUM_DISTANCE
QPointer< QWidget > m_target
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)