summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--opentrack/win32-shortcuts.cpp17
-rw-r--r--opentrack/win32-shortcuts.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp
index d4107949..bd51ae88 100644
--- a/opentrack/win32-shortcuts.cpp
+++ b/opentrack/win32-shortcuts.cpp
@@ -111,6 +111,23 @@ QList<win_key> windows_key_sequences =
win_key(DIK_SPACE, Qt::Key::Key_Space),
});
+bool win_key::to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods)
+{
+ for (auto& wk : windows_key_sequences)
+ {
+ if (wk.win == k.keycode)
+ {
+ qt_ = wk.qt;
+ mods = Qt::NoModifier;
+ if (k.ctrl) mods |= Qt::ControlModifier;
+ if (k.shift) mods |= Qt::ShiftModifier;
+ if (k.alt) mods |= Qt::AltModifier;
+ return true;
+ }
+ }
+ return false;
+}
+
bool win_key::from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers& mods)
{
auto qt = static_cast<QVariant>(qt_).toInt();
diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h
index 3e824b89..fe92ae53 100644
--- a/opentrack/win32-shortcuts.h
+++ b/opentrack/win32-shortcuts.h
@@ -3,6 +3,7 @@
#ifdef _WIN32
#include <QKeySequence>
+#include "opentrack/shortcuts.h"
struct win_key;
@@ -15,6 +16,7 @@ struct win_key
int win;
Qt::Key qt;
static bool from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers &mods);
+ static bool to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods);
};
#endif