summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-10-25 03:11:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-10-25 03:11:42 +0200
commit0a1a0e9df00f37a210b67a11cf8f99550cafeeaf (patch)
tree35da3c9a2d6464025dc324647253966d4a63a351 /gui
parenta4c9807acacc87f323f31d252a37c0ed2029ee5b (diff)
cleanups only
Diffstat (limited to 'gui')
-rw-r--r--gui/init.cpp2
-rw-r--r--gui/keyboard.cpp23
-rw-r--r--gui/keyboard.h6
3 files changed, 19 insertions, 12 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index 09b0e909..a3932047 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -97,7 +97,7 @@ static void set_qt_style()
static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QString &msg)
{
const unsigned short* const str_ = msg.utf16();
- auto str = reinterpret_cast<const wchar_t* const>(str_);
+ const auto str = reinterpret_cast<wchar_t const*>(str_);
static_assert(sizeof(*str_) == sizeof(*str));
std::fflush(stderr);
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);
diff --git a/gui/keyboard.h b/gui/keyboard.h
index 19d29e75..0a06a3af 100644
--- a/gui/keyboard.h
+++ b/gui/keyboard.h
@@ -24,13 +24,13 @@ class OTR_GUI_EXPORT keyboard_listener : public QDialog
Q_OBJECT
Ui_keyboard_listener ui;
#ifdef _WIN32
+ auto make_token();
KeybindingWorker::Token token;
+#else
+ void keyPressEvent(QKeyEvent* event) override;
#endif
public:
keyboard_listener(QWidget* parent = nullptr);
-#ifndef _WIN32
- void keyPressEvent(QKeyEvent* event) override;
-#endif
signals:
void key_pressed(QKeySequence k);
void joystick_button_pressed(QString guid, int idx, bool held);