From 7ed453de4a77266e7e29f2f944b285b4fe3b248b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 May 2016 12:30:35 +0200 Subject: api,gui: disable all keyboard shortcuts while binding a key Previous disallowed binding an already-bound key on Unix since Qxt doesn't pass through bound keys unlike the Windows implementation. Refactor some common code. The Windows implementation isn't even compile-tested. --- opentrack/shortcuts.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'opentrack/shortcuts.cpp') diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp index 2caa1790..e1087008 100644 --- a/opentrack/shortcuts.cpp +++ b/opentrack/shortcuts.cpp @@ -9,17 +9,30 @@ #include "shortcuts.h" #include "win32-shortcuts.h" -void Shortcuts::bind_keyboard_shortcut(K &key, const key_opts& k, unused(bool, held)) +void Shortcuts::free_binding(K& key) { -#if !defined(_WIN32) - using sh = QxtGlobalShortcut; +#ifndef _WIN32 if (key) { key->setEnabled(false); key->setShortcut(QKeySequence::UnknownKey); - std::shared_ptr tmp(nullptr); + std::shared_ptr tmp(nullptr); key.swap(tmp); } +#else + key.keycode = 0; + key.guid = ""; +#endif +} + +void Shortcuts::bind_keyboard_shortcut(K &key, const key_opts& k, unused(bool, held)) +{ +#if !defined(_WIN32) + using sh = QxtGlobalShortcut; + if (key) + { + free_binding(key); + } key = std::make_shared(); -- cgit v1.2.3