diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-10-25 03:11:42 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-10-25 03:11:42 +0200 |
commit | 0a1a0e9df00f37a210b67a11cf8f99550cafeeaf (patch) | |
tree | 35da3c9a2d6464025dc324647253966d4a63a351 /gui/keyboard.cpp | |
parent | a4c9807acacc87f323f31d252a37c0ed2029ee5b (diff) |
cleanups only
Diffstat (limited to 'gui/keyboard.cpp')
-rw-r--r-- | gui/keyboard.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index b9964ecb..aa8f67a3 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -2,11 +2,11 @@ #include <QDebug> -keyboard_listener::keyboard_listener(QWidget* parent) : - QDialog(parent) -#if defined _WIN32 - , token([this](const Key& k) { - if(k.guid != "") +#ifdef _WIN32 +auto keyboard_listener::make_token() +{ + return [this](const Key& k) { + if(!k.guid.isEmpty()) { int mods = 0; if (k.alt) mods |= Qt::AltModifier; @@ -19,10 +19,17 @@ keyboard_listener::keyboard_listener(QWidget* parent) : Qt::KeyboardModifiers m; QKeySequence k_; if (win_key::to_qt(k, k_, m)) - emit key_pressed(static_cast<QVariant>(k_).toInt() | m); + emit key_pressed({ int(m), int(k_) }); } - }) -// token initializer ends, real ctor body begins + }; +} + +#endif + +keyboard_listener::keyboard_listener(QWidget* parent) : + QDialog(parent) +#ifdef _WIN32 + , token(make_token()) #endif { ui.setupUi(this); |