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:
79
80 bool hasRunningShortcut() const;
81
82 void addShortcut(KisSingleActionShortcut *shortcut);
83 void addShortcut(KisStrokeShortcut *shortcut);
84 void addShortcut(KisTouchShortcut *shortcut);
85 void addShortcut(KisNativeGestureShortcut *shortcut);
86
94 bool supportsHiResInputEvents();
95
103 bool keyPressed(Qt::Key key);
104
112 bool autoRepeatedKeyPressed(Qt::Key key);
113
121 bool keyReleased(Qt::Key key);
122
132 bool buttonPressed(Qt::MouseButton button, QEvent *event);
133
143 bool buttonReleased(Qt::MouseButton button, QEvent *event);
144
151 bool wheelEvent(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event);
152
161 bool pointerMoved(QEvent *event);
162
167 void enterEvent();
168
173 void leaveEvent();
174
175 bool touchBeginEvent(QTouchEvent *event);
176 bool touchUpdateEvent(QTouchEvent *event);
177 bool touchEndEvent(QTouchEvent *event);
178
184 void touchCancelEvent(QTouchEvent *event, const QPointF &localPos);
185
186 bool nativeGestureBeginEvent(QNativeGestureEvent *event);
187 bool nativeGestureEvent(QNativeGestureEvent *event);
188 bool nativeGestureEndEvent(QNativeGestureEvent *event);
189
197 void reinitialize();
198
206 void reinitializeButtons();
207
216 void handlePolledKeys(const QVector<Qt::Key> &keys);
217
224 bool sanityCheckModifiersCorrectness(Qt::KeyboardModifiers modifiers) const;
225
229 QVector<Qt::Key> debugPressedKeys() const;
230
234 bool hasPolledKeys();
235
240 void lostFocusEvent(const QPointF &localPos);
241
246 void toolHasBeenActivated();
247
256
260 void suppressConflictingKeyActions(const QVector<QKeySequence> &shortcuts);
261
272
276 void clearShortcuts();
277
278 void setInputActionGroupsMaskCallback(std::function<KisInputActionGroupsMask()> func);
279
280private:
281 friend class KisInputManagerTest;
282
283 void reset();
284 void reset(QString msg);
285
286 bool tryRunWheelShortcut(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event);
287 template<typename T, typename U> bool tryRunSingleActionShortcutImpl(T param, U *event, const QSet<Qt::Key> &keysState, bool keyboard = true);
288
289 void prepareReadyShortcuts();
290
291 bool tryRunReadyShortcut( Qt::MouseButton button, QEvent* event );
292 void tryActivateReadyShortcut();
293 bool tryEndRunningShortcut( Qt::MouseButton button, QEvent* event );
294 void forceEndRunningShortcut(const QPointF &localPos);
295 void forceDeactivateAllActions();
296
297 void setMaxTouchPointEvent(QTouchEvent *event);
298 void fireReadyTouchShortcut(QTouchEvent *event);
299 KisTouchShortcut *matchTouchShortcut(QTouchEvent *event);
300 bool tryRunTouchShortcut(QTouchEvent *event);
301 bool tryEndTouchShortcut(QTouchEvent *event);
302
303 bool tryRunNativeGestureShortcut(QNativeGestureEvent *event);
304 bool tryEndNativeGestureShortcut(QNativeGestureEvent *event);
305
306private:
307 class Private;
308 Private * const m_d;
309};
310
311#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)