diff --git a/src/globalshortcuts.cpp b/src/globalshortcuts.cpp index 8b18664608..b75095bfde 100644 --- a/src/globalshortcuts.cpp +++ b/src/globalshortcuts.cpp @@ -120,14 +120,8 @@ void GlobalShortcutsManager::objectDeleted(QObject *object) } } -bool GlobalShortcutsManager::addIfNotExists(GlobalShortcut sc, DeviceType device) +bool GlobalShortcutsManager::add(GlobalShortcut sc, DeviceType device) { - for (const auto &cs : std::as_const(m_shortcuts)) { - if (sc.shortcut() == cs.shortcut()) { - return false; - } - } - const auto &recognizer = device == DeviceType::Touchpad ? m_touchpadGestureRecognizer : m_touchscreenGestureRecognizer; if (std::holds_alternative(sc.shortcut())) { recognizer->registerSwipeGesture(sc.swipeGesture()); @@ -141,27 +135,27 @@ bool GlobalShortcutsManager::addIfNotExists(GlobalShortcut sc, DeviceType device void GlobalShortcutsManager::registerPointerShortcut(QAction *action, Qt::KeyboardModifiers modifiers, Qt::MouseButtons pointerButtons) { - addIfNotExists(GlobalShortcut(PointerButtonShortcut{modifiers, pointerButtons}, action)); + add(GlobalShortcut(PointerButtonShortcut{modifiers, pointerButtons}, action)); } void GlobalShortcutsManager::registerAxisShortcut(QAction *action, Qt::KeyboardModifiers modifiers, PointerAxisDirection axis) { - addIfNotExists(GlobalShortcut(PointerAxisShortcut{modifiers, axis}, action)); + add(GlobalShortcut(PointerAxisShortcut{modifiers, axis}, action)); } void GlobalShortcutsManager::registerTouchpadSwipe(SwipeDirection direction, uint32_t fingerCount, QAction *action, std::function progressCallback) { - addIfNotExists(GlobalShortcut(RealtimeFeedbackSwipeShortcut{DeviceType::Touchpad, direction, progressCallback, fingerCount}, action), DeviceType::Touchpad); + add(GlobalShortcut(RealtimeFeedbackSwipeShortcut{DeviceType::Touchpad, direction, progressCallback, fingerCount}, action), DeviceType::Touchpad); } void GlobalShortcutsManager::registerTouchpadPinch(PinchDirection direction, uint32_t fingerCount, QAction *action, std::function progressCallback) { - addIfNotExists(GlobalShortcut(RealtimeFeedbackPinchShortcut{direction, progressCallback, fingerCount}, action), DeviceType::Touchpad); + add(GlobalShortcut(RealtimeFeedbackPinchShortcut{direction, progressCallback, fingerCount}, action), DeviceType::Touchpad); } void GlobalShortcutsManager::registerTouchscreenSwipe(SwipeDirection direction, uint32_t fingerCount, QAction *action, std::function progressCallback) { - addIfNotExists(GlobalShortcut(RealtimeFeedbackSwipeShortcut{DeviceType::Touchscreen, direction, progressCallback, fingerCount}, action), DeviceType::Touchscreen); + add(GlobalShortcut(RealtimeFeedbackSwipeShortcut{DeviceType::Touchscreen, direction, progressCallback, fingerCount}, action), DeviceType::Touchscreen); } void GlobalShortcutsManager::forceRegisterTouchscreenSwipe(SwipeDirection direction, uint32_t fingerCount, QAction *action, std::function progressCallback) diff --git a/src/globalshortcuts.h b/src/globalshortcuts.h index 7ed3b7e378..5002baab6c 100644 --- a/src/globalshortcuts.h +++ b/src/globalshortcuts.h @@ -113,7 +113,7 @@ public: private: void objectDeleted(QObject *object); - bool addIfNotExists(GlobalShortcut sc, DeviceType device = DeviceType::Touchpad); + bool add(GlobalShortcut sc, DeviceType device = DeviceType::Touchpad); QVector m_shortcuts;