From 323dd162f5326b998e1c92ab4cfec8a63574023f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Dec 2018 22:45:38 +0100 Subject: cmake: decruft, disable deprecated Qt functions --- gui/keyboard.cpp | 50 +++++++++++++++++++++++++++----------------------- gui/keyboard.h | 10 +++++++--- 2 files changed, 34 insertions(+), 26 deletions(-) (limited to 'gui') diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index dbc3ab3a..90849bab 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -1,39 +1,43 @@ +#undef NDEBUG +#include + #include "keyboard.h" #include #ifdef _WIN32 -auto keyboard_listener::make_token() + +void keyboard_listener::receive_key(const Key& k) { - return [this](const Key& k) { - if(!k.guid.isEmpty()) - { - int mods = 0; - if (k.alt) mods |= Qt::AltModifier; - if (k.shift) mods |= Qt::ShiftModifier; - if (k.ctrl) mods |= Qt::ControlModifier; - emit joystick_button_pressed(k.guid, k.keycode | mods, k.held); - } - else - { - Qt::KeyboardModifiers m; - QKeySequence k_; - if (win_key::to_qt(k, k_, m)) - emit key_pressed({ int(m) | int(k_) }); - } - }; + if(!k.guid.isEmpty()) + { + int mods = 0; + if (k.alt) mods |= Qt::AltModifier; + if (k.shift) mods |= Qt::ShiftModifier; + if (k.ctrl) mods |= Qt::ControlModifier; + + emit joystick_button_pressed(k.guid, k.keycode | mods, k.held); + } + else + { + Qt::KeyboardModifiers m; + QKeySequence k_; + + if (win_key::to_qt(k, k_, m)) + for (unsigned i = 0; i < (unsigned)k_.count(); i++) + emit key_pressed(QKeySequence(int(m) | k_[i])); + } } #endif -keyboard_listener::keyboard_listener(QWidget* parent) : - QDialog(parent) -#ifdef _WIN32 - , token(make_token()) -#endif +keyboard_listener::keyboard_listener(QWidget* parent) : QDialog(parent) { ui.setupUi(this); setFocusPolicy(Qt::StrongFocus); +#ifdef _WIN32 + (void)token; +#endif } #if !defined _WIN32 diff --git a/gui/keyboard.h b/gui/keyboard.h index 0a06a3af..ea35d372 100644 --- a/gui/keyboard.h +++ b/gui/keyboard.h @@ -22,13 +22,17 @@ class OTR_GUI_EXPORT keyboard_listener : public QDialog { Q_OBJECT - Ui_keyboard_listener ui; + #ifdef _WIN32 - auto make_token(); - KeybindingWorker::Token token; + void receive_key(const Key& k); + + KeybindingWorker::Token token{[this](const Key& k) {receive_key(k);}}; #else void keyPressEvent(QKeyEvent* event) override; #endif + + Ui_keyboard_listener ui; + public: keyboard_listener(QWidget* parent = nullptr); signals: -- cgit v1.2.3