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  GestureAction {
  NoGesture , OneFingerTap , TwoFingerTap , ThreeFingerTap ,
  FourFingerTap , FiveFingerTap , OneFingerDrag , TwoFingerDrag ,
  ThreeFingerDrag , FourFingerDrag , FiveFingerDrag , MaxGesture
}
 
enum  MouseWheelMovement {
  NoMovement , WheelUp , WheelDown , WheelLeft ,
  WheelRight , WheelTrackpad
}
 
enum  ShortcutType {
  UnknownType , KeyCombinationType , MouseButtonType , MouseWheelType ,
  GestureType , MacOSGestureType
}
 

Public Member Functions

KisAbstractInputActionaction () const
 
Qt::MouseButtons buttons () const
 
GestureAction gesture () const
 
QString getInputText () const
 
bool isNoOp () const
 
QList< Qt::Key > keys () const
 
 KisShortcutConfiguration ()
 
 KisShortcutConfiguration (const KisShortcutConfiguration &other)
 
uint mode () const
 
KisShortcutConfigurationoperator= (const KisShortcutConfiguration &other)
 
bool operator== (const KisShortcutConfiguration &other) const
 
QString serialize ()
 
void setAction (KisAbstractInputAction *newAction)
 
void setButtons (Qt::MouseButtons newButtons)
 
void setGesture (GestureAction type)
 
void setKeys (const QList< Qt::Key > &newKeys)
 
void setMode (uint newMode)
 
void setType (ShortcutType newType)
 
void setWheel (MouseWheelMovement type)
 
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 gestureToText (GestureAction action)
 
static QString keysToText (const QList< Qt::Key > &keys)
 
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 27 of file kis_shortcut_configuration.h.

Member Enumeration Documentation

◆ GestureAction

The type of gesture.

Enumerator
NoGesture 

No gesture.

OneFingerTap 
TwoFingerTap 
ThreeFingerTap 
FourFingerTap 
FiveFingerTap 
OneFingerDrag 
TwoFingerDrag 
ThreeFingerDrag 
FourFingerDrag 
FiveFingerDrag 
MaxGesture 

Definition at line 57 of file kis_shortcut_configuration.h.

◆ 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.

WheelTrackpad 

A pan movement on a trackpad.

Definition at line 45 of file kis_shortcut_configuration.h.

45 {
47 WheelUp,
48 WheelDown,
49 WheelLeft,
52 };
@ WheelTrackpad
A pan movement on a trackpad.
@ WheelDown
Downwards movement, toward the user.
@ WheelUp
Upwards movement, away from the user.

◆ 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.

GestureType 

A touch gesture.

MacOSGestureType 

A macOS gesture.

Definition at line 33 of file kis_shortcut_configuration.h.

33 {
40 };
@ 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.

Constructor & Destructor Documentation

◆ KisShortcutConfiguration() [1/2]

KisShortcutConfiguration::KisShortcutConfiguration ( )

Constructor.

Definition at line 37 of file kis_shortcut_configuration.cpp.

◆ KisShortcutConfiguration() [2/2]

KisShortcutConfiguration::KisShortcutConfiguration ( const KisShortcutConfiguration & other)

Copy constructor.

Definition at line 43 of file kis_shortcut_configuration.cpp.

44 : d(new Private)
45{
46 d->action = other.action();
47 d->type = other.type();
48 d->mode = other.mode();
49 d->keys = other.keys();
50 d->buttons = other.buttons();
51 d->wheel = other.wheel();
52 d->gesture = other.gesture();
53}
KisAbstractInputAction * action() const

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

◆ ~KisShortcutConfiguration()

KisShortcutConfiguration::~KisShortcutConfiguration ( )
virtual

Destructor.

Definition at line 74 of file kis_shortcut_configuration.cpp.

75{
76 delete d;
77}

References d.

Member Function Documentation

◆ action()

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

Definition at line 180 of file kis_shortcut_configuration.cpp.

181{
182 return d->action;
183}

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 228 of file kis_shortcut_configuration.cpp.

229{
230 return d->buttons;
231}

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 439 of file kis_shortcut_configuration.cpp.

440{
442
443 if (keys.size() > 0) {
444 return i18nc(
445 "%1 = modifier keys in shortcut; %2 = mouse buttons in shortcut",
446 "%1 + %2",
448 buttonsText);
449 }
450 else {
451 return buttonsText;
452 }
453}
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 290 of file kis_shortcut_configuration.cpp.

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

References _, buttons(), and EXTRA_BUTTON.

◆ gesture()

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

Definition at line 252 of file kis_shortcut_configuration.cpp.

253{
254 return d->gesture;
255}

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

◆ gestureToText()

QString KisShortcutConfiguration::gestureToText ( GestureAction action)
static

Definition at line 471 of file kis_shortcut_configuration.cpp.

472{
473 switch (action) {
474#ifdef Q_OS_MACOS
475 case PinchGesture:
476 return i18n("Pinch Gesture");
477 case PanGesture:
478 return i18n("Pan Gesture");
479 case RotateGesture:
480 return i18n("Rotate Gesture");
481 case SmartZoomGesture:
482 return i18n("Smart Zoom Gesture");
483#else
484 case OneFingerTap:
485 return i18n("One Finger Tap");
486 case TwoFingerTap:
487 return i18n("Two Finger Tap");
488 case ThreeFingerTap:
489 return i18n("Three Finger Tap");
490 case FourFingerTap:
491 return i18n("Four Finger Tap");
492 case FiveFingerTap:
493 return i18n("Five Finger Tap");
494 case OneFingerDrag:
495 return i18n("One Finger Drag");
496 case TwoFingerDrag:
497 return i18n("Two Finger Drag");
498 case ThreeFingerDrag:
499 return i18n("Three Finger Drag");
500 case FourFingerDrag:
501 return i18n("Four Finger Drag");
502 case FiveFingerDrag:
503 return i18n("Five Finger Drag");
504#endif
505 default:
506 return i18n("No Gesture");
507 }
508}

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

◆ getInputText()

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

Definition at line 273 of file kis_shortcut_configuration.cpp.

274{
275 switch (d->type) {
277 return keysToText(d->keys);
278 case MouseButtonType:
279 return buttonsInputToText(d->keys, d->buttons);
280 case MouseWheelType:
281 return wheelInputToText(d->keys, d->wheel);
282 case GestureType:
283 case MacOSGestureType:
284 return gestureToText(d->gesture);
285 default:
286 return QString();
287 }
288}
static QString wheelInputToText(const QList< Qt::Key > &keys, MouseWheelMovement wheel)
static QString gestureToText(GestureAction action)
static QString buttonsInputToText(const QList< Qt::Key > &keys, Qt::MouseButtons buttons)

References KisShortcutConfiguration::Private::buttons, buttonsInputToText(), d, KisShortcutConfiguration::Private::gesture, gestureToText(), GestureType, KeyCombinationType, KisShortcutConfiguration::Private::keys, keysToText(), MacOSGestureType, MouseButtonType, MouseWheelType, KisShortcutConfiguration::Private::type, KisShortcutConfiguration::Private::wheel, and wheelInputToText().

◆ isNoOp()

bool KisShortcutConfiguration::isNoOp ( ) const
Returns
True if shortcut is a no-op, that is it isn't bound to any input which can be performed by the user.

Definition at line 264 of file kis_shortcut_configuration.cpp.

265{
266 return d->type == UnknownType || (d->type == KeyCombinationType && d->keys.isEmpty())
267 || (d->type == MouseButtonType && d->buttons.testFlag(Qt::NoButton))
268 || (d->type == MouseWheelType && d->wheel == NoMovement)
269 || ((d->type == GestureType || d->type == MacOSGestureType)
270 && (d->gesture == NoGesture || d->gesture == MaxGesture));
271}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::gesture, GestureType, KeyCombinationType, KisShortcutConfiguration::Private::keys, MacOSGestureType, MaxGesture, MouseButtonType, MouseWheelType, NoGesture, NoMovement, KisShortcutConfiguration::Private::type, UnknownType, and KisShortcutConfiguration::Private::wheel.

◆ 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 216 of file kis_shortcut_configuration.cpp.

217{
218 return d->keys;
219}

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 364 of file kis_shortcut_configuration.cpp.

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

205{
206 return d->mode;
207}

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

◆ 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 68 of file kis_shortcut_configuration.cpp.

69{
70 return d->type == other.d->type && d->keys == other.d->keys && d->buttons == other.d->buttons
71 && d->wheel == other.d->wheel && d->gesture == other.d->gesture;
72}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::gesture, KisShortcutConfiguration::Private::keys, 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 79 of file kis_shortcut_configuration.cpp.

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

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::gesture, GestureType, KisShortcutConfiguration::Private::keys, MacOSGestureType, KisShortcutConfiguration::Private::mode, 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 185 of file kis_shortcut_configuration.cpp.

186{
187 if (d->action != newAction) {
188 d->action = newAction;
189 }
190}

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 233 of file kis_shortcut_configuration.cpp.

234{
235 if (d->buttons != newButtons) {
236 d->buttons = newButtons;
237 }
238}

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

◆ setGesture()

void KisShortcutConfiguration::setGesture ( KisShortcutConfiguration::GestureAction type)

Set the gesture that will trigger this shortcut.

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

Definition at line 257 of file kis_shortcut_configuration.cpp.

258{
259 if (d->gesture != type) {
260 d->gesture = type;
261 }
262}

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

◆ 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 221 of file kis_shortcut_configuration.cpp.

222{
223 if (d->keys != newKeys) {
224 d->keys = newKeys;
225 }
226}

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 209 of file kis_shortcut_configuration.cpp.

210{
211 if (d->mode != newMode) {
212 d->mode = newMode;
213 }
214}

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

◆ setType()

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

Set the type of shortcut.

Parameters
newTypeThe type to set.

Definition at line 197 of file kis_shortcut_configuration.cpp.

198{
199 if (d->type != newType) {
200 d->type = newType;
201 }
202}

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 245 of file kis_shortcut_configuration.cpp.

246{
247 if (d->wheel != type) {
248 d->wheel = type;
249 }
250}

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

◆ type()

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

Definition at line 192 of file kis_shortcut_configuration.cpp.

193{
194 return d->type;
195}

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 116 of file kis_shortcut_configuration.cpp.

117{
118 if (!serialized.startsWith('{'))
119 return false;
120
121 //Parse the serialized data and apply it to the current shortcut
122 QString remainder = serialized;
123
124 //Remove brackets
125 remainder.remove('{').remove('}');
126
127 //Split the remainder by ;
128 QStringList parts = remainder.split(';');
129
130 if (parts.size() < 6)
131 return false; //Invalid input, abort
132
133 //First entry in the list is the mode
134 d->mode = parts.at(0).toUInt(nullptr, 16);
135
136 //Second entry is the shortcut type
137 d->type = static_cast<ShortcutType>(parts.at(1).toInt(nullptr, 16));
138
139 if (d->type == UnknownType) {
140 //Reject input that would set this shortcut to "Unknown"
141 return false;
142 }
143
144#ifdef Q_OS_MACOS
145 // On MacOS, the GestureType gestures aren't handled. But! MacOSGestureType gestures are handled as
146 // GestureTypes. Confusing? Yes, but this is done only here (and when serializing).
147 if (d->type == GestureType) {
148 return false;
149 }
150 if (d->type == MacOSGestureType) {
151 d->type = GestureType;
152 }
153#else
154 // only macOS platform handles these gestures
155 if (d->type == MacOSGestureType) {
156 return false;
157 }
158#endif
159
160 //Third entry is the list of keys
161 QString serializedKeys = parts.at(2);
162 //Remove brackets
163 serializedKeys.remove('[').remove(']');
164 //Split by , and add each entry as a key
165 QStringList keylist = serializedKeys.split(',');
166 Q_FOREACH(QString key, keylist) {
167 if (!key.isEmpty()) {
168 d->keys.append(static_cast<Qt::Key>(key.toUInt(nullptr, 16)));
169 }
170 }
171
172 //Fourth entry is the button mask
173 d->buttons = static_cast<Qt::MouseButtons>(parts.at(3).toInt(nullptr, 16));
174 d->wheel = static_cast<MouseWheelMovement>(parts.at(4).toUInt(nullptr, 16));
175 d->gesture = static_cast<GestureAction>(parts.at(5).toUInt(nullptr, 16));
176
177 return true;
178}

References KisShortcutConfiguration::Private::buttons, d, KisShortcutConfiguration::Private::gesture, GestureType, KisShortcutConfiguration::Private::keys, MacOSGestureType, KisShortcutConfiguration::Private::mode, KisShortcutConfiguration::Private::type, UnknownType, and KisShortcutConfiguration::Private::wheel.

◆ 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 240 of file kis_shortcut_configuration.cpp.

241{
242 return d->wheel;
243}

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 455 of file kis_shortcut_configuration.cpp.

456{
457 QString wheelText = KisShortcutConfiguration::wheelToText(wheel);
458
459 if (keys.size() > 0) {
460 return i18nc(
461 "%1 = modifier keys in shortcut; %2 = mouse wheel buttons in shortcut",
462 "%1 + %2",
464 wheelText);
465 }
466 else {
467 return wheelText;
468 }
469}
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 410 of file kis_shortcut_configuration.cpp.

411{
412 switch (wheel) {
414 return i18n("Mouse Wheel Up");
415 break;
416
418 return i18n("Mouse Wheel Down");
419 break;
420
422 return i18n("Mouse Wheel Left");
423 break;
424
426 return i18n("Mouse Wheel Right");
427 break;
428
430 return i18n("Trackpad Pan");
431 break;
432
433 default:
434 return i18nc("No mouse wheel buttons for shortcut", "None");
435 break;
436 }
437}

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

Member Data Documentation

◆ d

Private* const KisShortcutConfiguration::d
private

Definition at line 326 of file kis_shortcut_configuration.h.


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