Krita Source Code Documentation
Loading...
Searching...
No Matches
KisShortcutConfiguration Class Reference

A class encapsulating all settings for a single shortcut. More...

#include <kis_shortcut_configuration.h>

Classes

class  Private
 

Public Types

enum  MouseWheelMovement {
  NoMovement , WheelUp , WheelDown , WheelLeft ,
  WheelRight , WheelReserved_0
}
 
enum  NativeGestureAction {
  NoNativeGesture = 0 , PinchGesture = 1 , SmartZoomGesture = 4 , TouchpadScroll = 5 ,
  MaxNativeGesture
}
 
enum  ShortcutType {
  UnknownType , KeyCombinationType , MouseButtonType , MouseWheelType ,
  TouchGestureType , NativeGestureType
}
 
enum  TouchGestureAction {
  NoGesture , OneFingerTap , TwoFingerTap , ThreeFingerTap ,
  FourFingerTap , FiveFingerTap , OneFingerDrag , TwoFingerDrag ,
  ThreeFingerDrag , FourFingerDrag , FiveFingerDrag , OneFingerHold ,
  MaxGesture
}
 

Public Member Functions

KisAbstractInputAction * action () const
 
Qt::MouseButtons buttons () const
 
QString getInputText () const
 
bool isNoOp () const
 
QList< Qt::Key > keys () const
 
 KisShortcutConfiguration ()
 
 KisShortcutConfiguration (const KisShortcutConfiguration &other)
 
uint mode () const
 
NativeGestureAction nativeGesture () const
 
KisShortcutConfiguration & operator= (const KisShortcutConfiguration &other)
 
bool operator== (const KisShortcutConfiguration &other) const
 
QString serialize ()
 
void setAction (KisAbstractInputAction *newAction)
 
void setButtons (Qt::MouseButtons newButtons)
 
void setKeys (const QList< Qt::Key > &newKeys)
 
void setMode (uint newMode)
 
void setNativeGesture (NativeGestureAction type)
 
void setTouchGesture (TouchGestureAction type)
 
void setType (ShortcutType newType)
 
void setWheel (MouseWheelMovement type)
 
TouchGestureAction touchGesture () const
 
ShortcutType type () const
 
bool unserialize (const QString &serialized)
 
MouseWheelMovement wheel () const
 
virtual ~KisShortcutConfiguration ()
 

Static Public Member Functions

static QString buttonsInputToText (const QList< Qt::Key > &keys, Qt::MouseButtons buttons)
 
static QString buttonsToText (Qt::MouseButtons buttons)
 
static QString keysToText (const QList< Qt::Key > &keys)
 
static QString nativeGestureToText (NativeGestureAction action)
 
static QString shortcutTypeToText (ShortcutType type)
 
static QString touchGestureToText (TouchGestureAction action)
 
static QString wheelInputToText (const QList< Qt::Key > &keys, MouseWheelMovement wheel)
 
static QString wheelToText (MouseWheelMovement wheel)
 

Private Attributes

Private *const d
 

Detailed Description

A class encapsulating all settings for a single shortcut.

This class encapsulates mouse buttons, keyboard keys and other settings related to a single shortcut for a single action.

Note
Each action can have several modes that activate it with usually different behaviour for each mode. Different shortcuts can activate different modes.

Definition at line 29 of file kis_shortcut_configuration.h.

Member Enumeration Documentation

◆ MouseWheelMovement

The type of mouse wheel movement.

Enumerator
NoMovement 

No movement.

WheelUp 

Upwards movement, away from the user.

WheelDown 

Downwards movement, toward the user.

WheelLeft 

Left movement.

WheelRight 

Right movement.

WheelReserved_0 

Do not use! Previously was used for TouchpadScroll shortcut.

Definition at line 47 of file kis_shortcut_configuration.h.

47 {
49 WheelUp,
50 WheelDown,
51 WheelLeft,
54 };
@ WheelDown
Downwards movement, toward the user.
@ WheelUp
Upwards movement, away from the user.
@ WheelReserved_0
Do not use! Previously was used for TouchpadScroll shortcut.

◆ NativeGestureAction

Enumerator
NoNativeGesture 

No gesture.

PinchGesture 

Pinch gesture, a two finger gesture used for navigating the canvas.

SmartZoomGesture 

Smart zoom gesture, typically a double tap that is a boolean zoom/unzoom.

TouchpadScroll 

Two-dimensional pixel scrolling on a touchpad, supported on MacOS and Wayland only.

MaxNativeGesture 

Definition at line 75 of file kis_shortcut_configuration.h.

75 {
76 NoNativeGesture = 0,
77 PinchGesture = 1,
78
79 // WARNING: elements with indexes 1 and 2 are intentionally skipped,
80 // they used to represent Qt::PanNativeGesture and Qt::RotateNativeGesture,
81 // but now all three gestures are represented as a single PinchGesture.
82
84 TouchpadScroll = 5,
86 };
@ TouchpadScroll
Two-dimensional pixel scrolling on a touchpad, supported on MacOS and Wayland only.
@ SmartZoomGesture
Smart zoom gesture, typically a double tap that is a boolean zoom/unzoom.
@ PinchGesture
Pinch gesture, a two finger gesture used for navigating the canvas.

◆ ShortcutType

The type of shortcut, i.e. what kind of input does it expect.

Enumerator
UnknownType 

Unknown, empty shortcut.

KeyCombinationType 

A list of keys that should be pressed.

MouseButtonType 

A mouse button, possibly with key modifiers.

MouseWheelType 

Mouse wheel movement, possibly with key modifiers.

TouchGestureType 

A touch gesture.

NativeGestureType 

A macOS gesture.

Definition at line 35 of file kis_shortcut_configuration.h.

35 {
42 };
@ 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.
@ UnknownType
Unknown, empty shortcut.

◆ TouchGestureAction

The type of gesture.

Enumerator
NoGesture 

No gesture.

OneFingerTap 
TwoFingerTap 
ThreeFingerTap 
FourFingerTap 
FiveFingerTap 
OneFingerDrag 
TwoFingerDrag 
ThreeFingerDrag 
FourFingerDrag 
FiveFingerDrag 
OneFingerHold 
MaxGesture 

Definition at line 59 of file kis_shortcut_configuration.h.

59 {
60 NoGesture,
73 };

Constructor & Destructor Documentation

◆ KisShortcutConfiguration() [1/2]

KisShortcutConfiguration::KisShortcutConfiguration ( )

Constructor.

Definition at line 40 of file kis_shortcut_configuration.cpp.

◆ KisShortcutConfiguration() [2/2]

KisShortcutConfiguration::KisShortcutConfiguration ( const KisShortcutConfiguration & other)

Copy constructor.

Definition at line 46 of file kis_shortcut_configuration.cpp.

47 : d(new Private)
48{
49 d->action = other.action();
50 d->type = other.type();
51 d->mode = other.mode();
52 d->keys = other.keys();
53 d->buttons = other.buttons();
54 d->wheel = other.wheel();
55 d->touchGesture = other.touchGesture();
56 d->nativeGesture = other.nativeGesture();
57}
KisAbstractInputAction * action() const
NativeGestureAction nativeGesture() const
TouchGestureAction touchGesture() const

References KisShortcutConfiguration::Private::action, action(), KisShortcutConfiguration::Private::buttons, buttons(), d, KisShortcutConfiguration::Private::keys, keys(), KisShortcutConfiguration::Private::mode, mode(), KisShortcutConfiguration::Private::nativeGesture, nativeGesture(), KisShortcutConfiguration::Private::touchGesture, touchGesture(), KisShortcutConfiguration::Private::type, type(), KisShortcutConfiguration::Private::wheel, and wheel().

◆ ~KisShortcutConfiguration()

KisShortcutConfiguration::~KisShortcutConfiguration ( )
virtual

Destructor.

Definition at line 79 of file kis_shortcut_configuration.cpp.

80{
81 delete d;
82}

References d.

Member Function Documentation

◆ action()

KisAbstractInputAction * KisShortcutConfiguration::action ( ) const
Returns
The action this shortcut is associated with.

Definition at line 175 of file kis_shortcut_configuration.cpp.

176{
177 return d->action;
178}

References KisShortcutConfiguration::Private::action, and d.

◆ buttons()

Qt::MouseButtons KisShortcutConfiguration::buttons ( ) const
Returns
The mouse buttons that will trigger this shortcut.
Note
Only applicable when type is MouseButtonType.

Definition at line 223 of file kis_shortcut_configuration.cpp.

224{
225 return d->buttons;
226}

References KisShortcutConfiguration::Private::buttons, and d.

◆ buttonsInputToText()

QString KisShortcutConfiguration::buttonsInputToText ( const QList< Qt::Key > & keys,
Qt::MouseButtons buttons )
static

Convert a shortcut build of a set of keys and a set of mouse buttons into a user-readable string.

This will convert the given mouse buttons-based shortcut into a string that can be shown to a user. For example, the combination of Qt::Key_Control and Qt::LeftButton + Qt::RightButton will produce the string "Ctrl + Left + Right Button".

Parameters
keysThe keys to convert.
buttonsThe mouse buttons to convert.
Returns
A string representing the shortcut that can be shown to a user.
Note
An empty set of buttons will appear as the string "None".

Definition at line 442 of file kis_shortcut_configuration.cpp.

443{
445
446 if (keys.size() > 0) {
447 return i18nc(
448 "%1 = modifier keys in shortcut; %2 = mouse buttons in shortcut",
449 "%1 + %2",
451 buttonsText);
452 }
453 else {
454 return buttonsText;
455 }
456}
static QString buttonsToText(Qt::MouseButtons buttons)
static QString keysToText(const QList< Qt::Key > &keys)

References buttons(), buttonsToText(), keys(), and keysToText().

◆ buttonsToText()

QString KisShortcutConfiguration::buttonsToText ( Qt::MouseButtons buttons)
static

Convert a set of mouse buttons into a user-readable string.

This will convert the given set of buttons into a string that can be shown to a user. For example, the combination Qt::LeftButton + Qt::RightButton will produce the string "Left + Right Button".

Parameters
buttonsThe buttons to convert.
Returns
A string representing the buttons that can be shown to a user.
Note
An empty set will produce the string "None".

Definition at line 297 of file kis_shortcut_configuration.cpp.

298{
299 QString text;
300 QString sep = i18nc("Separator in the list of mouse buttons for shortcut", " + ");
301
302 int buttonCount = 0;
303
304 if (buttons & Qt::LeftButton) {
305 text.append(i18nc("Left Mouse Button", "Left"));
306 buttonCount++;
307 }
308
309 if (buttons & Qt::RightButton) {
310 if (buttonCount++ > 0) {
311 text.append(sep);
312 }
313
314 text.append(i18nc("Right Mouse Button", "Right"));
315 }
316
317 if (buttons & Qt::MiddleButton) {
318 if (buttonCount++ > 0) {
319 text.append(sep);
320 }
321
322 text.append(i18nc("Middle Mouse Button", "Middle"));
323 }
324
325 if (buttons & Qt::BackButton) {
326 if (buttonCount++ > 0) {
327 text.append(sep);
328 }
329
330 text.append(i18nc("Mouse Back Button", "Back"));
331 }
332
333 if (buttons & Qt::ForwardButton) {
334 if (buttonCount++ > 0) {
335 text.append(sep);
336 }
337
338 text.append(i18nc("Mouse Forward Button", "Forward"));
339 }
340
341 if (buttons & Qt::TaskButton) {
342 if (buttonCount++ > 0) {
343 text.append(sep);
344 }
345
346 text.append(i18nc("Mouse Task Button", "Task"));
347 }
348
349// Qt supports up to ExtraButton24 so include those
350#define EXTRA_BUTTON(z, n, _)\
351 if (buttons & Qt::ExtraButton##n) { \
352 if (buttonCount++ > 0) { text.append(sep); } \
353 text.append(i18nc("Mouse Button", "Mouse %1", n + 3)); \
354 }
355BOOST_PP_REPEAT_FROM_TO(4, 25, EXTRA_BUTTON, _)
356#undef EXTRA_BUTTON
357
358 if (buttonCount == 0) {
359 text.append(i18nc("No mouse buttons for shortcut", "None"));
360 }
361 else {
362 text = i18ncp(
363 "%1 = List of mouse buttons for shortcut. "
364 "Plural form is chosen upon the number of buttons in that list.",
365 "%1 Button", "%1 Buttons", text, buttonCount);
366 }
367
368 return text;
369}
#define EXTRA_BUTTON(z, n, _)

References buttons(), and EXTRA_BUTTON.

◆ getInputText()

QString KisShortcutConfiguration::getInputText ( ) const
Returns
an input string for the shortcut type.

Definition at line 279 of file kis_shortcut_configuration.cpp.

280{
281 switch (d->type) {
283 return keysToText(d->keys);
284 case MouseButtonType:
285 return buttonsInputToText(d->keys, d->buttons);
286 case MouseWheelType:
287 return wheelInputToText(d->keys, d->wheel);
288 case TouchGestureType:
292 default:
293 return QString();
294 }
295}
static QString wheelInputToText(const QList< Qt::Key > &keys, MouseWheelMovement wheel)
static QString nativeGestureToText(NativeGestureAction action)
static QString touchGestureToText(TouchGestureAction action)
static QString buttonsInputToText(const QList< Qt::Key > &keys, Qt::MouseButtons buttons)

References KisShortcutConfiguration::Private::buttons, buttonsInputToText(), d, KeyCombinationType, KisShortcutConfiguration::Private::keys, keysToText(), MouseButtonType, MouseWheelType, KisShortcutConfiguration::Private::nativeGesture, nativeGestureToText(), NativeGestureType, KisShortcutConfiguration::Private::touchGesture, touchGestureToText(), TouchGestureType, KisShortcutConfiguration::Private::type, KisShortcutConfiguration::Private::wheel, and wheelInputToText().

◆ isNoOp()

◆ keys()

QList< Qt::Key > KisShortcutConfiguration::keys ( ) const
Returns
The list of keys that will trigger this shortcut.
Note
Not applicable when type is GestureType.

Definition at line 211 of file kis_shortcut_configuration.cpp.

212{
213 return d->keys;
214}

References d, and KisShortcutConfiguration::Private::keys.

◆ keysToText()

QString KisShortcutConfiguration::keysToText ( const QList< Qt::Key > & keys)
static

Convert a list of keys to a user-readable string.

This will convert the given list of keys into a string that can be shown to a user. For example, the list [Qt::Key_Shift, Qt::Key_Space] will produce the string "Shift + Space".

Parameters
keysThe keys to convert.
Returns
A string representing the keys that can be shown to a user.
Note
An empty list will produce the string "None".

Definition at line 371 of file kis_shortcut_configuration.cpp.

372{
373 QString output;
374
375 Q_FOREACH (Qt::Key key, keys) {
376#if defined(Q_OS_MAC)
377 // This works for modifier keys on macOS but not other platforms.
378 // They are shown with symbols, so no translation or separators needed.
379 output.append(QKeySequence(key).toString(QKeySequence::NativeText));
380#else
381 if (output.size() > 0) {
382 output.append(i18nc("Separator in the list of keys for shortcut", " + "));
383 }
384
385 switch (key) { //Because QKeySequence fails for Ctrl, Alt, Shift and Meta
386 case Qt::Key_Control:
387 output.append(i18nc("Ctrl key", "Ctrl"));
388 break;
389
390 case Qt::Key_Meta:
391 output.append(i18nc("Meta key", "Meta"));
392 break;
393
394 case Qt::Key_Alt:
395 output.append(i18nc("Alt key", "Alt"));
396 break;
397
398 case Qt::Key_Shift:
399 output.append(i18nc("Shift key", "Shift"));
400 break;
401
402 default:
403 QKeySequence s(key);
404 output.append(s.toString(QKeySequence::NativeText));
405 break;
406 }
407#endif
408 }
409
410 if (output.size() == 0) {
411 output = i18nc("No keys for shortcut", "None");
412 }
413
414 return output;
415}
QString toString(const QString &value)

References keys().

◆ mode()

uint KisShortcutConfiguration::mode ( ) const
Returns
The mode of the action this shortcut will trigger.

Definition at line 199 of file kis_shortcut_configuration.cpp.

200{
201 return d->mode;
202}

References d, and KisShortcutConfiguration::Private::mode.

◆ nativeGesture()

KisShortcutConfiguration::NativeGestureAction KisShortcutConfiguration::nativeGesture ( ) const
Returns
The native gesture that will trigger this shortcut.
Note
Only applicable when type is MacOSGestureType.

Definition at line 257 of file kis_shortcut_configuration.cpp.

258{
259 return d->nativeGesture;
260}

References d, and KisShortcutConfiguration::Private::nativeGesture.

◆ nativeGestureToText()

QString KisShortcutConfiguration::nativeGestureToText ( NativeGestureAction action)
static

Definition at line 474 of file kis_shortcut_configuration.cpp.

475{
476 switch (action) {
477 case PinchGesture:
478 return i18n("Pinch Gesture");
479 case SmartZoomGesture:
480 return i18n("Smart Zoom Gesture");
481 case TouchpadScroll:
482 return i18n("Touchpad Scroll Gesture");
483 default:
484 return i18n("No Gesture");
485 }
486}

References action(), PinchGesture, SmartZoomGesture, and TouchpadScroll.

◆ operator=()

◆ operator==()

bool KisShortcutConfiguration::operator== ( const KisShortcutConfiguration & other) const

Checks whether two configurations have the same input config.

Note
This does not compare the action or the modes the Shortcut is mapped to. This is because those fields are what the input mapping should do and not what an input mapping is. That is: this will return true even if two profiles have different actions.

Definition at line 73 of file kis_shortcut_configuration.cpp.

74{
75 return d->type == other.d->type && d->keys == other.d->keys && d->buttons == other.d->buttons
76 && d->wheel == other.d->wheel && d->touchGesture == other.d->touchGesture && d->nativeGesture == other.d->nativeGesture;
77}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::keys, KisShortcutConfiguration::Private::nativeGesture, KisShortcutConfiguration::Private::touchGesture, KisShortcutConfiguration::Private::type, and KisShortcutConfiguration::Private::wheel.

◆ serialize()

QString KisShortcutConfiguration::serialize ( )

Serialize the data of this shortcut into a string that can be saved into a configuration file.

The string will have the following format:

{mode;type;[key,key];buttons;wheel;gesture}

with each property serialized into a base-16 integer.

Returns
A serialized representation of this shortcut.

Definition at line 84 of file kis_shortcut_configuration.cpp.

85{
86 QString serialized("{");
87
88 serialized.append(QString::number(d->mode, 16));
89 serialized.append(';');
90 serialized.append(QString::number(d->type, 16));
91 serialized.append(";[");
92
93 for (QList<Qt::Key>::iterator itr = d->keys.begin(); itr != d->keys.end(); ++itr) {
94 serialized.append(QString::number(*itr, 16));
95
96 if (itr + 1 != d->keys.end()) {
97 serialized.append(',');
98 }
99 }
100
101 serialized.append("];");
102
103 serialized.append(QString::number(d->buttons, 16));
104 serialized.append(';');
105 serialized.append(QString::number(d->wheel, 16));
106 serialized.append(';');
107 if (d->type == NativeGestureType) {
108 serialized.append(QString::number(d->nativeGesture, 16));
109 } else {
110 serialized.append(QString::number(d->touchGesture, 16));
111 }
112 serialized.append('}');
113
114 return serialized;
115}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::keys, KisShortcutConfiguration::Private::mode, KisShortcutConfiguration::Private::nativeGesture, NativeGestureType, KisShortcutConfiguration::Private::touchGesture, KisShortcutConfiguration::Private::type, and KisShortcutConfiguration::Private::wheel.

◆ setAction()

void KisShortcutConfiguration::setAction ( KisAbstractInputAction * newAction)

Set the action this shortcut should be associated with.

Parameters
newActionThe action to set.

Definition at line 180 of file kis_shortcut_configuration.cpp.

181{
182 if (d->action != newAction) {
183 d->action = newAction;
184 }
185}

References KisShortcutConfiguration::Private::action, and d.

◆ setButtons()

void KisShortcutConfiguration::setButtons ( Qt::MouseButtons newButtons)

Set the mouse buttons that will trigger this shortcut.

Parameters
newButtonsThe mouse buttons to use.
Note
Only applicable when type is MouseButtonType.

Definition at line 228 of file kis_shortcut_configuration.cpp.

229{
230 if (d->buttons != newButtons) {
231 d->buttons = newButtons;
232 }
233}

References KisShortcutConfiguration::Private::buttons, and d.

◆ setKeys()

void KisShortcutConfiguration::setKeys ( const QList< Qt::Key > & newKeys)

Set the list of keys that will trigger this shortcut.

Parameters
newKeysThe list of keys to use.
Note
Not applicable when type is GestureType.

Definition at line 216 of file kis_shortcut_configuration.cpp.

217{
218 if (d->keys != newKeys) {
219 d->keys = newKeys;
220 }
221}

References d, and KisShortcutConfiguration::Private::keys.

◆ setMode()

void KisShortcutConfiguration::setMode ( uint newMode)

Set the mode of the action this shortcut will trigger.

Parameters
newModeThe mode to set.

Definition at line 204 of file kis_shortcut_configuration.cpp.

205{
206 if (d->mode != newMode) {
207 d->mode = newMode;
208 }
209}

References d, and KisShortcutConfiguration::Private::mode.

◆ setNativeGesture()

void KisShortcutConfiguration::setNativeGesture ( NativeGestureAction type)

Set the native gesture that will trigger this shortcut.

Parameters
typeThe native gesture to use.
Note
Only applicable when type is MacOSGestureType.

Definition at line 262 of file kis_shortcut_configuration.cpp.

263{
265}

References d, KisShortcutConfiguration::Private::nativeGesture, and type().

◆ setTouchGesture()

void KisShortcutConfiguration::setTouchGesture ( KisShortcutConfiguration::TouchGestureAction type)

Set the gesture that will trigger this shortcut.

Parameters
typeThe gesture to use.
Note
Only applicable when type is GestureType.

Definition at line 252 of file kis_shortcut_configuration.cpp.

253{
255}

References d, KisShortcutConfiguration::Private::touchGesture, and type().

◆ setType()

void KisShortcutConfiguration::setType ( KisShortcutConfiguration::ShortcutType newType)

Set the type of shortcut.

Parameters
newTypeThe type to set.

Definition at line 192 of file kis_shortcut_configuration.cpp.

193{
194 if (d->type != newType) {
195 d->type = newType;
196 }
197}

References d, and KisShortcutConfiguration::Private::type.

◆ setWheel()

void KisShortcutConfiguration::setWheel ( KisShortcutConfiguration::MouseWheelMovement type)

Set the mouse wheel movement that will trigger this shortcut.

Parameters
typeThe wheel movement to use.
Note
Only applicable when type is MouseWheelType.

Definition at line 240 of file kis_shortcut_configuration.cpp.

241{
242 if (d->wheel != type) {
243 d->wheel = type;
244 }
245}

References d, type(), and KisShortcutConfiguration::Private::wheel.

◆ shortcutTypeToText()

QString KisShortcutConfiguration::shortcutTypeToText ( ShortcutType type)
static

Definition at line 518 of file kis_shortcut_configuration.cpp.

519{
520 switch (type) {
522 return i18nc("Shortcut type", "Key Combination");
523
525 return i18nc("Shortcut type", "Mouse Button");
526
528 return i18nc("Shortcut type", "Mouse Wheel");
529
531 return i18nc("Shortcut type", "Touch Gesture");
532
534 return i18nc("Shortcut type", "Touchpad Gesture");
535
536 default:
537 return i18n("Unknown Input");
538 }
539}

References KeyCombinationType, MouseButtonType, MouseWheelType, NativeGestureType, TouchGestureType, and type().

◆ touchGesture()

KisShortcutConfiguration::TouchGestureAction KisShortcutConfiguration::touchGesture ( ) const
Returns
The gesture that will trigger this shortcut.
Note
Only applicable when type is GestureType.

Definition at line 247 of file kis_shortcut_configuration.cpp.

248{
249 return d->touchGesture;
250}

References d, and KisShortcutConfiguration::Private::touchGesture.

◆ touchGestureToText()

QString KisShortcutConfiguration::touchGestureToText ( TouchGestureAction action)
static

Definition at line 488 of file kis_shortcut_configuration.cpp.

489{
490 switch (action) {
491 case OneFingerTap:
492 return i18n("One Finger Tap");
493 case TwoFingerTap:
494 return i18n("Two Finger Tap");
495 case ThreeFingerTap:
496 return i18n("Three Finger Tap");
497 case FourFingerTap:
498 return i18n("Four Finger Tap");
499 case FiveFingerTap:
500 return i18n("Five Finger Tap");
501 case OneFingerDrag:
502 return i18n("One Finger Drag");
503 case TwoFingerDrag:
504 return i18n("Two Finger Drag");
505 case ThreeFingerDrag:
506 return i18n("Three Finger Drag");
507 case FourFingerDrag:
508 return i18n("Four Finger Drag");
509 case FiveFingerDrag:
510 return i18n("Five Finger Drag");
511 case OneFingerHold:
512 return i18n("One Finger Hold");
513 default:
514 return i18n("No Gesture");
515 }
516}

References action(), FiveFingerDrag, FiveFingerTap, FourFingerDrag, FourFingerTap, OneFingerDrag, OneFingerHold, OneFingerTap, ThreeFingerDrag, ThreeFingerTap, TwoFingerDrag, and TwoFingerTap.

◆ type()

KisShortcutConfiguration::ShortcutType KisShortcutConfiguration::type ( ) const
Returns
The type of shortcut.

Definition at line 187 of file kis_shortcut_configuration.cpp.

188{
189 return d->type;
190}

References d, and KisShortcutConfiguration::Private::type.

◆ unserialize()

bool KisShortcutConfiguration::unserialize ( const QString & serialized)

Apply the data from a serialized shortcut to this shortcut.

This method expects a string as described in serialize().

Parameters
serializedThe serialized shortcut.
Returns
true if successful, false if an error occurred.
See also
serialize()

Definition at line 117 of file kis_shortcut_configuration.cpp.

118{
119 if (!serialized.startsWith('{'))
120 return false;
121
122 //Parse the serialized data and apply it to the current shortcut
123 QString remainder = serialized;
124
125 //Remove brackets
126 remainder.remove('{').remove('}');
127
128 //Split the remainder by ;
129 QStringList parts = remainder.split(';');
130
131 if (parts.size() < 6)
132 return false; //Invalid input, abort
133
134 //First entry in the list is the mode
135 d->mode = parts.at(0).toUInt(nullptr, 16);
136
137 //Second entry is the shortcut type
138 d->type = static_cast<ShortcutType>(parts.at(1).toInt(nullptr, 16));
139
140 if (d->type == UnknownType) {
141 //Reject input that would set this shortcut to "Unknown"
142 return false;
143 }
144
145 //Third entry is the list of keys
146 QString serializedKeys = parts.at(2);
147 //Remove brackets
148 serializedKeys.remove('[').remove(']');
149 //Split by , and add each entry as a key
150 QStringList keylist = serializedKeys.split(',');
151 Q_FOREACH(QString key, keylist) {
152 if (!key.isEmpty()) {
153 d->keys.append(static_cast<Qt::Key>(key.toUInt(nullptr, 16)));
154 }
155 }
156
157 //Fourth entry is the button mask
158 d->buttons = static_cast<Qt::MouseButtons>(parts.at(3).toInt(nullptr, 16));
159 d->wheel = static_cast<MouseWheelMovement>(parts.at(4).toUInt(nullptr, 16));
160
161 if (d->type == MouseWheelType && d->wheel == WheelReserved_0) {
162 qWarning() << "WARNING: input profile contains deprecated Mouse Wheel shortcut (WheelReserved_0), skipping...";
163 return false;
164 }
165
166 if (d->type == NativeGestureType) {
167 d->nativeGesture = static_cast<NativeGestureAction>(parts.at(5).toUInt(nullptr, 16));
168 } else {
169 d->touchGesture = static_cast<TouchGestureAction>(parts.at(5).toUInt(nullptr, 16));
170 }
171
172 return true;
173}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::keys, KisShortcutConfiguration::Private::mode, MouseWheelType, KisShortcutConfiguration::Private::nativeGesture, NativeGestureType, KisShortcutConfiguration::Private::touchGesture, KisShortcutConfiguration::Private::type, UnknownType, KisShortcutConfiguration::Private::wheel, and WheelReserved_0.

◆ wheel()

KisShortcutConfiguration::MouseWheelMovement KisShortcutConfiguration::wheel ( ) const
Returns
The mouse wheel movement that will trigger this shortcut.
Note
Only applicable when type is MouseWheelType.

Definition at line 235 of file kis_shortcut_configuration.cpp.

236{
237 return d->wheel;
238}

References d, and KisShortcutConfiguration::Private::wheel.

◆ wheelInputToText()

QString KisShortcutConfiguration::wheelInputToText ( const QList< Qt::Key > & keys,
KisShortcutConfiguration::MouseWheelMovement wheel )
static

Convert a shortcut build of a set of keys and a set of mouse wheel buttons into a user-readable string.

This will convert the given mouse wheel-based shortcut into a string that can be shown to a user. For example, the combination of Qt::Key_Control and WheelUp will produce the string "Ctrl + Mouse Wheel Up".

Parameters
keysThe keys to convert.
wheelThe mouse wheel buttons to convert.
Returns
A string representing the shortcut that can be shown to a user.
Note
An empty set of wheel buttons will appear as the string "None".

Definition at line 458 of file kis_shortcut_configuration.cpp.

459{
460 QString wheelText = KisShortcutConfiguration::wheelToText(wheel);
461
462 if (keys.size() > 0) {
463 return i18nc(
464 "%1 = modifier keys in shortcut; %2 = mouse wheel buttons in shortcut",
465 "%1 + %2",
467 wheelText);
468 }
469 else {
470 return wheelText;
471 }
472}
static QString wheelToText(MouseWheelMovement wheel)

References keys(), keysToText(), wheel(), and wheelToText().

◆ wheelToText()

QString KisShortcutConfiguration::wheelToText ( KisShortcutConfiguration::MouseWheelMovement wheel)
static

Convert the given mouse wheel movement to a string.

This will convert the given mouse wheel movement into a string that can be shown to a user. For example, WheelUp will produce the string "Mouse Wheel Up".

Parameters
wheelThe mouse wheel movement to convert.
Returns
A string representing the mouse wheel movement that can be shown to a user.
Note
NoMovement will produce the string "None".

Definition at line 417 of file kis_shortcut_configuration.cpp.

418{
419 switch (wheel) {
421 return i18n("Mouse Wheel Up");
422 break;
423
425 return i18n("Mouse Wheel Down");
426 break;
427
429 return i18n("Mouse Wheel Left");
430 break;
431
433 return i18n("Mouse Wheel Right");
434 break;
435
436 default:
437 return i18nc("No mouse wheel buttons for shortcut", "None");
438 break;
439 }
440}

References wheel(), WheelDown, WheelLeft, WheelRight, and WheelUp.

Member Data Documentation

◆ d

Private* const KisShortcutConfiguration::d
private

Definition at line 354 of file kis_shortcut_configuration.h.


The documentation for this class was generated from the following files: