From 5ea990a74093d96a5d6d4ea15284cbbb60c1a7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 14 Jul 2013 22:58:30 +0200 Subject: [PATCH] Export global pointer shortcuts to effect system and use it for cube Used in cube effect as an example with hard coded ctrl+alt+left click. BUG: 163121 --- effects.cpp | 5 +++++ effects.h | 1 + effects/cube/cube.cpp | 1 + libkwineffects/kwineffects.h | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/effects.cpp b/effects.cpp index 7221ec87cc..f6841a582f 100644 --- a/effects.cpp +++ b/effects.cpp @@ -825,6 +825,11 @@ void EffectsHandlerImpl::registerGlobalShortcut(const QKeySequence &shortcut, QA input()->registerShortcut(shortcut, action); } +void EffectsHandlerImpl::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) +{ + input()->registerPointerShortcut(modifiers, pointerButtons, action); +} + void* EffectsHandlerImpl::getProxy(QString name) { // All effects start with "kwin4_effect_", prepend it to the name diff --git a/effects.h b/effects.h index d09c6b2fed..3ff4df4fd3 100644 --- a/effects.h +++ b/effects.h @@ -119,6 +119,7 @@ public: void startMouseInterception(Effect *effect, Qt::CursorShape shape) override; void stopMouseInterception(Effect *effect) override; void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) override; + void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override; void* getProxy(QString name) override; void startMousePolling() override; void stopMousePolling() override; diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 5fe5a5d0ba..3908d01a6c 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -202,6 +202,7 @@ void CubeEffect::reconfigure(ReconfigureFlags) KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList() << Qt::CTRL + Qt::Key_F11); KGlobalAccel::self()->setShortcut(cubeAction, QList() << Qt::CTRL + Qt::Key_F11); effects->registerGlobalShortcut(Qt::CTRL + Qt::Key_F11, cubeAction); + effects->registerPointerShortcut(Qt::ControlModifier | Qt::AltModifier, Qt::LeftButton, cubeAction); cubeShortcut = KGlobalAccel::self()->shortcut(cubeAction); QAction* cylinderAction = new QAction(this); cylinderAction->setObjectName(QStringLiteral("Cylinder")); diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 1038d9656e..c8aabce504 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -742,6 +742,14 @@ public: * @param action The action which gets triggered when the shortcut matches */ virtual void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) = 0; + /** + * @brief Registers a global pointer shortcut with the provided @p action. + * + * @param modifiers The keyboard modifiers which need to be holded + * @param pointerButtons The pointer buttons which need to be pressed + * @param action The action which gets triggered when the shortcut matches + **/ + virtual void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) = 0; /** * Retrieve the proxy class for an effect if it has one. Will return NULL if