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 @@ -93,6 +93,7 @@ virtual void begin(int shortcut, QEvent *event); /** * End the action. + * * \param event The mouse event that has finished this action. * Is null for keyboard-activated actions. */ @@ -168,7 +169,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) { \ + buttonSet << Qt::ExtraButton##n; \ + } + void KisInputManager::Private::addStrokeShortcut(KisAbstractInputAction* action, int index, const QList &modifiers, Qt::MouseButtons buttons) @@ -370,25 +377,21 @@ KisStrokeShortcut *strokeShortcut = new KisStrokeShortcut(action, index); - QList buttonList; + QSet buttonSet; if(buttons & Qt::LeftButton) { - buttonList << Qt::LeftButton; + buttonSet << Qt::LeftButton; } if(buttons & Qt::RightButton) { - buttonList << Qt::RightButton; + buttonSet << Qt::RightButton; } if(buttons & Qt::MidButton) { - buttonList << Qt::MidButton; - } - if(buttons & Qt::XButton1) { - buttonList << Qt::XButton1; - } - if(buttons & Qt::XButton2) { - buttonList << Qt::XButton2; + buttonSet << Qt::MidButton; } - if (buttonList.size() > 0) { - strokeShortcut->setButtons(QSet::fromList(modifiers), QSet::fromList(buttonList)); + BOOST_PP_REPEAT_FROM_TO(1, 25, EXTRA_BUTTON, _) + + if (!buttonSet.empty()) { + strokeShortcut->setButtons(QSet::fromList(modifiers), buttonSet); matcher.addShortcut(strokeShortcut); } else { Index: libs/ui/input/kis_input_profile_manager.cpp =================================================================== --- libs/ui/input/kis_input_profile_manager.cpp +++ libs/ui/input/kis_input_profile_manager.cpp @@ -188,7 +188,7 @@ void KisInputProfileManager::loadProfiles() { //Remove any profiles that already exist - d->currentProfile = 0; + d->currentProfile = nullptr; qDeleteAll(d->profiles); d->profiles.clear(); @@ -223,7 +223,7 @@ } if (p.contains(".kde") || p.contains(".krita")) { - // It's the user define one, drop the others + // It's the user defined one, drop the others profileEntries[entry.name].clear(); profileEntries[entry.name].append(entry); break; 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.h =================================================================== --- libs/ui/input/kis_stroke_shortcut.h +++ libs/ui/input/kis_stroke_shortcut.h @@ -39,7 +39,6 @@ * user the cursor of the upcoming action and the Running state shows * that the action linked to the shortcut should be activated. */ - class KRITAUI_EXPORT KisStrokeShortcut : public KisAbstractShortcut { public: @@ -65,9 +64,9 @@ * can show the user that pressing the mouse button will start some * action. This can be done with, e.g. changing the cursor. */ - bool matchReady(const QSet &modifiers, const QSet &buttons); + /** * Reports whether the shortcut can transit form the "Ready" * to "Running" state. It means that the last button of the shortcut 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,10 @@ int KisStrokeShortcut::priority() const { + const int maxScore = std::log2((int) Qt::MaxMouseButton); int buttonScore = 0; Q_FOREACH (Qt::MouseButton button, m_d->buttons) { - buttonScore += Qt::XButton2 - button; + buttonScore += maxScore - std::log2((int) button); } return m_d->modifiers.size() * 0xFFFF + buttonScore * 0xFF + action()->priority(); @@ -55,7 +57,7 @@ void KisStrokeShortcut::setButtons(const QSet &modifiers, const QSet &buttons) { - if (buttons.size() == 0) return; + if (buttons.empty()) return; m_d->modifiers = modifiers; m_d->buttons = buttons; @@ -69,7 +71,6 @@ compareKeys(m_d->modifiers, modifiers); if (!modifiersOk || buttons.size() < m_d->buttons.size() - 1) { - return false; }