Index: libs/ui/input/kis_abstract_input_action.h =================================================================== --- libs/ui/input/kis_abstract_input_action.h +++ libs/ui/input/kis_abstract_input_action.h @@ -168,7 +168,7 @@ /** * Some of the actions are available in particular situations - * only. E.g. switch frame action is available iff a animated + * only. E.g. switch frame action is available iff an animated * layer is selected. If isAvailable() returns true then the * action will *not* be triggered by the shortcut matcher. */ Index: libs/ui/input/kis_input_manager_p.cpp =================================================================== --- libs/ui/input/kis_input_manager_p.cpp +++ libs/ui/input/kis_input_manager_p.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include "kis_input_manager.h" #include "kis_config.h" #include "kis_abstract_input_action.h" @@ -363,6 +365,11 @@ return QObject::eventFilter(object, event); } +#define EXTRA_BUTTON(z, n, _) \ + if(buttons & Qt::ExtraButton##n) { \ + buttonList << Qt::ExtraButton##n; \ + } + void KisInputManager::Private::addStrokeShortcut(KisAbstractInputAction* action, int index, const QList &modifiers, Qt::MouseButtons buttons) @@ -380,12 +387,8 @@ if(buttons & Qt::MidButton) { buttonList << Qt::MidButton; } - if(buttons & Qt::XButton1) { - buttonList << Qt::XButton1; - } - if(buttons & Qt::XButton2) { - buttonList << Qt::XButton2; - } + + BOOST_PP_REPEAT_FROM_TO(1, 25, EXTRA_BUTTON, _) if (buttonList.size() > 0) { strokeShortcut->setButtons(QSet::fromList(modifiers), QSet::fromList(buttonList)); Index: libs/ui/input/kis_shortcut_configuration.cpp =================================================================== --- libs/ui/input/kis_shortcut_configuration.cpp +++ libs/ui/input/kis_shortcut_configuration.cpp @@ -23,6 +23,8 @@ #include #include +#include + class KisShortcutConfiguration::Private { public: @@ -114,10 +116,10 @@ return false; //Invalid input, abort //First entry in the list is the mode - d->mode = parts.at(0).toUInt(); + d->mode = parts.at(0).toUInt(nullptr, 16); //Second entry is the shortcut type - d->type = static_cast(parts.at(1).toInt()); + d->type = static_cast(parts.at(1).toInt(nullptr, 16)); if (d->type == UnknownType) { //Reject input that would set this shortcut to "Unknown" @@ -132,14 +134,14 @@ QStringList keylist = serializedKeys.split(','); Q_FOREACH(QString key, keylist) { if (!key.isEmpty()) { - d->keys.append(static_cast(key.toUInt(0, 16))); + d->keys.append(static_cast(key.toUInt(nullptr, 16))); } } //Fourth entry is the button mask - d->buttons = static_cast(parts.at(3).toInt()); - d->wheel = static_cast(parts.at(4).toUInt()); - d->gesture = static_cast(parts.at(5).toUInt()); + d->buttons = static_cast(parts.at(3).toInt(nullptr, 16)); + d->wheel = static_cast(parts.at(4).toUInt(nullptr, 16)); + d->gesture = static_cast(parts.at(5).toUInt(nullptr, 16)); return true; } @@ -228,6 +230,12 @@ } } +#define EXTRA_BUTTON(z, n, _)\ + if (buttons & Qt::ExtraButton##n) { \ + if (buttonCount++ > 0) { text.append(sep); } \ + text.append(i18nc("Mouse Button", "Mouse %1", n + 7)); \ + } + QString KisShortcutConfiguration::buttonsToText(Qt::MouseButtons buttons) { QString text; @@ -248,7 +256,7 @@ text.append(i18nc("Right Mouse Button", "Right")); } - if (buttons & Qt::MidButton) { + if (buttons & Qt::MiddleButton) { if (buttonCount++ > 0) { text.append(sep); } @@ -256,7 +264,7 @@ text.append(i18nc("Middle Mouse Button", "Middle")); } - if (buttons & Qt::XButton1) { + if (buttons & Qt::BackButton) { if (buttonCount++ > 0) { text.append(sep); } @@ -264,7 +272,7 @@ text.append(i18nc("Mouse Back Button", "Back")); } - if (buttons & Qt::XButton2) { + if (buttons & Qt::ForwardButton) { if (buttonCount++ > 0) { text.append(sep); } @@ -272,6 +280,16 @@ text.append(i18nc("Mouse Forward Button", "Forward")); } + if (buttons & Qt::TaskButton) { + if (buttonCount++ > 0) { + text.append(sep); + } + + text.append(i18nc("Mouse Task Button", "Task")); + } + + BOOST_PP_REPEAT_FROM_TO(4, 25, EXTRA_BUTTON, _) + if (buttonCount == 0) { text.append(i18nc("No mouse buttons for shortcut", "None")); } Index: libs/ui/input/kis_shortcut_matcher.h =================================================================== --- libs/ui/input/kis_shortcut_matcher.h +++ libs/ui/input/kis_shortcut_matcher.h @@ -45,7 +45,7 @@ * * The class works with two types of actions: long running * (represented by KisStrokeShortcuts) and "atomic" - * (KisSingleActionShortcut). The former one invole some long + * (KisSingleActionShortcut). The former one involves some long * interaction with the user by means of a mouse cursor or a tablet, * the latter one simple action like "Zoom 100%" or "Reset Rotation". * Index: libs/ui/input/kis_stroke_shortcut.cpp =================================================================== --- libs/ui/input/kis_stroke_shortcut.cpp +++ libs/ui/input/kis_stroke_shortcut.cpp @@ -22,6 +22,7 @@ #include +#include class Q_DECL_HIDDEN KisStrokeShortcut::Private { @@ -44,9 +45,13 @@ int KisStrokeShortcut::priority() const { - int buttonScore = 0; + Qt::MouseButtons buttons { 0 }; Q_FOREACH (Qt::MouseButton button, m_d->buttons) { - buttonScore += Qt::XButton2 - button; + buttons |= button; + } + int buttonScore = Qt::AllButtons - buttons; + if (buttonScore) { + buttonScore = std::round(std::log2(buttonScore)); } return m_d->modifiers.size() * 0xFFFF + buttonScore * 0xFF + action()->priority();