Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_shortcut_matcher.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2012 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_SHORTCUT_MATCHER_H
8#define __KIS_SHORTCUT_MATCHER_H
9
10
12#include "KisInputActionGroup.h"
13#include <functional>
15
16class QEvent;
17class QWheelEvent;
18class QTouchEvent;
19class QNativeGestureEvent;
20class QString;
21class QPointF;
22
26
27
74class KRITAUI_EXPORT KisShortcutMatcher
75{
76public:
77 static constexpr int TOUCH_SLOP_SQUARED = 16 * 16;
78
81
82 bool hasRunningShortcut() const;
83 bool hasTouchHoldShortcut() const;
84
85 void addShortcut(KisSingleActionShortcut *shortcut);
86 void addShortcut(KisStrokeShortcut *shortcut);
87 void addShortcut(KisTouchShortcut *shortcut);
88 void addShortcut(KisNativeGestureShortcut *shortcut);
89
97 bool supportsHiResInputEvents();
98
106 bool keyPressed(Qt::Key key);
107
115 bool autoRepeatedKeyPressed(Qt::Key key);
116
124 bool keyReleased(Qt::Key key);
125
135 bool buttonPressed(Qt::MouseButton button, QEvent *event);
136
146 bool buttonReleased(Qt::MouseButton button, QEvent *event);
147
154 bool wheelEvent(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event);
155
164 bool pointerMoved(QEvent *event);
165
170 void enterEvent();
171
176 void leaveEvent();
177
178 bool touchBeginEvent(QTouchEvent *event);
179 bool touchUpdateEvent(QTouchEvent *event);
180 bool touchEndEvent(QTouchEvent *event);
181
187 void touchCancelEvent(QTouchEvent *event, const QPointF &localPos);
188
194 bool touchHoldBeginEvent(QTouchEvent *event);
195
196 bool nativeGestureBeginEvent(QNativeGestureEvent *event);
197 bool nativeGestureEvent(QNativeGestureEvent *event);
198 bool nativeGestureEndEvent(QNativeGestureEvent *event);
199
207 void reinitialize();
208
216 void reinitializeButtons();
217
226 void handlePolledKeys(const QVector<Qt::Key> &keys);
227
234 bool sanityCheckModifiersCorrectness(Qt::KeyboardModifiers modifiers) const;
235
239 QVector<Qt::Key> debugPressedKeys() const;
240
244 bool hasPolledKeys();
245
250 void lostFocusEvent(const QPointF &localPos);
251
256 void toolHasBeenActivated();
257
266
270 void suppressConflictingKeyActions(const QVector<QKeySequence> &shortcuts);
271
282
286 void clearShortcuts();
287
288 void setInputActionGroupsMaskCallback(std::function<KisInputActionGroupsMask()> func);
289
290private:
291 friend class KisInputManagerTest;
292
293 void reset();
294 void reset(QString msg);
295
296 bool tryRunWheelShortcut(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event);
297 template<typename T, typename U> bool tryRunSingleActionShortcutImpl(T param, U *event, const QSet<Qt::Key> &keysState, bool keyboard = true);
298
299 void prepareReadyShortcuts();
300
301 bool tryRunReadyShortcut( Qt::MouseButton button, QEvent* event );
302 void tryActivateReadyShortcut();
303 bool tryEndRunningShortcut( Qt::MouseButton button, QEvent* event );
304 void forceEndRunningShortcut(const QPointF &localPos);
305 void forceDeactivateAllActions();
306
307 void setMaxTouchPointEvent(QTouchEvent *event);
308 void fireReadyTouchShortcut(QTouchEvent *event);
309 KisTouchShortcut *matchTouchShortcut(QTouchEvent *event);
310 bool matchTouchShortcutBasedOnState(QTouchEvent *event, KisTouchShortcut *shortcut);
311 bool tryRunTouchShortcut(QTouchEvent *event);
312 bool tryEndTouchShortcut(QTouchEvent *event);
313
314 bool tryRunNativeGestureShortcut(QNativeGestureEvent *event);
315 bool tryEndNativeGestureShortcut(QNativeGestureEvent *event);
316
317private:
318 class Private;
319 Private * const m_d;
320};
321
322#endif /* __KIS_SHORTCUT_MATCHER_H */
float value(const T *src, size_t ch)
void suppressAllKeyboardActions(bool value)
void suppressAllActions(bool value)
The KisTouchShortcut class only handles touch gestures it does not handle tool invocation i....
QString button(const QWheelEvent &ev)