13#include <klocalizedstring.h>
14#include <QApplication>
55#include "config-qt-patches-present.h"
60 return reinterpret_cast<quintptr
>(
value.data());
64 : QObject(parent), d(new
Private(this))
77 QApplication::instance()->
83 KisExtendedModifiersMapper::setLocalMonitor(
true, &
d->
matcher);
90 KisExtendedModifiersMapper::setLocalMonitor(
false);
110 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
122 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
124 disconnect(popupObject,
nullptr,
this,
nullptr);
146 Private::PriorityList::iterator it = begin;
149 it = std::find_if(begin, end,
152 if (it != end)
return;
154 it = std::find_if(begin, end,
166 it = std::find_if(it, end,
187#if defined (__clang__)
188#pragma GCC diagnostic ignored "-Wswitch"
204 if (filter.isNull()) {
208 savedPriorityEventFilterSeqNo++;
212 if (filter->eventFilter(
object, event))
return true;
238template <
class Event>
245 static_assert(std::is_same<Event, QMouseEvent>::value ||
246 std::is_same<Event, QTabletEvent>::value ||
247 std::is_same<Event, QTouchEvent>::value,
248 "event should be a mouse or a tablet event");
256 if ((event->type() == QEvent::MouseMove ||
257 event->type() == QEvent::TabletMove ||
258 event->type() == QEvent::TouchUpdate) &&
261#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
275 event->setAccepted(
true);
290 event->type() == QEvent::FocusIn ||
291 event->type() == QEvent::FocusOut ||
292 event->type() == QEvent::MouseButtonPress ||
293 event->type() == QEvent::MouseButtonRelease ||
294 event->type() == QEvent::MouseButtonDblClick ||
295 event->type() == QEvent::TabletPress ||
296 event->type() == QEvent::TabletRelease ||
297 event->type() == QEvent::Enter ||
298 event->type() == QEvent::Leave ||
299 event->type() == QEvent::TouchBegin ||
300 event->type() == QEvent::TouchEnd ||
301 event->type() == QEvent::TouchCancel ||
302 event->type() == QEvent::NativeGesture;
313 QEvent::Type type =
event->type();
315 if (type == QEvent::MouseButtonPress
316 || type == QEvent::MouseButtonDblClick
317 || type == QEvent::TabletPress
318 || type == QEvent::TouchBegin
319 || type == QEvent::NativeGesture) {
325 event->setAccepted(
true);
335 if (event->type() == QEvent::MouseMove ||
336 event->type() == QEvent::MouseButtonPress ||
337 event->type() == QEvent::MouseButtonRelease ||
338 event->type() == QEvent::TabletMove ||
339 event->type() == QEvent::TabletPress ||
340 event->type() == QEvent::TabletRelease ||
341 event->type() == QEvent::Wheel) {
353 if (receivingWidget && !receivingWidget->hasFocus()) {
363 QInputEvent *inputEvent =
static_cast<QInputEvent*
>(event);
364 if (event->type() != QEvent::ShortcutOverride &&
381 switch (event->type()) {
382 case QEvent::MouseButtonPress:
383 case QEvent::MouseButtonDblClick: {
387 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
398 event->setAccepted(retval);
401 case QEvent::MouseButtonRelease: {
405 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
407 event->setAccepted(retval);
410 case QEvent::ShortcutOverride: {
412 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
428 QKeyEvent kevent(QEvent::ShortcutOverride, key, modifiers);
433 guessedKeys.removeOne(key);
440 if (!keyEvent->isAutoRepeat()) {
450 keyEvent->setAccepted(
true);
455 case QEvent::KeyRelease: {
457 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
459 if (!keyEvent->isAutoRepeat()) {
491 (key == Qt::Key_Shift || key == Qt::Key_Alt ||
492 key == Qt::Key_Control || key == Qt::Key_Meta)) {
499 case QEvent::MouseMove: {
502 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
507 case QEvent::Wheel: {
509 QWheelEvent *wheelEvent =
static_cast<QWheelEvent*
>(event);
518 if (wheelEvent->source() == Qt::MouseEventSource::MouseEventSynthesizedBySystem) {
533 if (wheelEvent->angleDelta().isNull()) {
539 if (wheelEvent->angleDelta().x() < 0) {
541 }
else if (wheelEvent->angleDelta().x() >0) {
545 if (wheelEvent->angleDelta().y() < 0) {
547 }
else if (wheelEvent->angleDelta().y() > 0) {
551 bool wasScrolled =
false;
559 QWheelEvent::DefaultDeltasPerStep;
567 retval = !wasScrolled;
597 case QEvent::FocusIn:
607 case QEvent::FocusOut: {
611 QPointF currentLocalPos =
618 case QEvent::TabletPress: {
620 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
632 event->setAccepted(
true);
640#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
643 event->setAccepted(
false);
645#elif defined Q_OS_WIN32
655 case QEvent::TabletMove: {
658 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
674#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
677 event->setAccepted(
false);
682 case QEvent::TabletRelease: {
683#if defined(Q_OS_MAC) || defined(Q_OS_ANDROID)
689 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
692 event->setAccepted(
true);
694#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
697 event->setAccepted(
false);
703 case QEvent::TouchBegin:
709 QTouchEvent *touchEvent =
static_cast<QTouchEvent *
>(event);
713#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
728 case QEvent::TouchUpdate:
731 event->setAccepted(
true);
734 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
739 Q_FOREACH (
const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
740 if (point.state() != Qt::TouchPointReleased) {
745 if (count < 2 && touchEvent->touchPoints().
length() > count) {
750 QPointF currentPos = touchEvent->touchPoints().at(0).pos();
753 && touchEvent->touchPoints().count() == 1
754 && touchEvent->touchPointStates() != Qt::TouchPointStationary
781 if (!
KisConfig(
true).disableTouchOnCanvas())
788 case QEvent::TouchEnd:
791 event->setAccepted(
true);
795 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
802 && touchEvent->touchPoints().count() == 1) {
815 if (!
KisConfig(
true).disableTouchOnCanvas())
821 case QEvent::TouchCancel:
824 event->setAccepted(
true);
830 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
840 case QEvent::NativeGesture:
842 QNativeGestureEvent *gevent =
static_cast<QNativeGestureEvent*
>(event);
843 switch (gevent->gestureType()) {
844 case Qt::BeginNativeGesture:
853 case Qt::EndNativeGesture:
883 if (
KisConfig(
true).disableTouchOnCanvas()) {
920 QPointF currentLocalPos;
979 dbgUI <<
"Adding shortcut" << shortcut->keys() <<
"for action" << shortcut->action()->name();
980 switch(shortcut->type()) {
982 d->
addKeyShortcut(shortcut->action(), shortcut->mode(), shortcut->keys());
985 d->
addStrokeShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->buttons());
988 d->
addWheelShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->wheel());
1001 dbgInput <<
"No Input Profile Found: canvas interaction will be impossible";
qreal length(const QPointF &vec)
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisAbstractCanvasWidget * canvasWidget
static KisConfigNotifier * instance()
bool disableTouchOnCanvas() const
bool ignoreHighFunctionKeys(bool defaultValue=false) const
static Qt::Key workaroundShiftAltMetaHell(const QKeyEvent *keyEvent)
Qt::KeyboardModifiers queryStandardModifiers()
ExtendedModifiers queryExtendedModifiers()
A class encapsulating all settings for a single shortcut.
@ MouseButtonType
A mouse button, possibly with key modifiers.
@ MouseWheelType
Mouse wheel movement, possibly with key modifiers.
@ KeyCombinationType
A list of keys that should be pressed.
@ GestureType
A touch gesture.
void lostFocusEvent(const QPointF &localPos)
bool hasRunningShortcut() const
bool autoRepeatedKeyPressed(Qt::Key key)
bool buttonReleased(Qt::MouseButton button, QEvent *event)
void toolHasBeenActivated()
bool nativeGestureEndEvent(QNativeGestureEvent *event)
bool keyPressed(Qt::Key key)
bool touchBeginEvent(QTouchEvent *event)
bool suppressAllKeyboardActions
void reinitializeButtons()
QVector< Qt::Key > debugPressedKeys() const
bool touchEndEvent(QTouchEvent *event)
bool touchUpdateEvent(QTouchEvent *event)
bool nativeGestureEvent(QNativeGestureEvent *event)
bool buttonPressed(Qt::MouseButton button, QEvent *event)
bool sanityCheckModifiersCorrectness(Qt::KeyboardModifiers modifiers) const
bool supportsHiResInputEvents()
bool nativeGestureBeginEvent(QNativeGestureEvent *event)
void suppressConflictingKeyActions(const QVector< QKeySequence > &shortcuts)
bool keyReleased(Qt::Key key)
void touchCancelEvent(QTouchEvent *event, const QPointF &localPos)
bool wheelEvent(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event)
@ WheelDown
Mouse wheel moves down.
@ WheelTrackpad
A pan movement on a trackpad.
@ WheelUp
Mouse wheel moves up.
@ WheelRight
Mouse wheel moves right.
@ WheelLeft
Mouse wheel moves left.
static KisTabletDebugger * instance()
#define KIS_SAFE_ASSERT_RECOVER(cond)
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
auto mem_equal_to(MemTypeNoRef Class::*ptr, MemType &&value)
mem_equal_to is an unary functor that compares a member of the object to a given value
auto mem_greater(MemTypeNoRef Class::*ptr, MemType &&value)
mem_greater is an unary functor that compares a member of the object to a given value