summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/keyboard.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-25 02:50:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-25 02:51:44 +0200
commit95114eccc774bbb0fbeade8904aafa4f9b6d143d (patch)
treee80f681b8374a91579ebd0fbfff9ecd48402e136 /facetracknoir/keyboard.h
parent7d0c58540103e9182ba584b440b91068df03a49c (diff)
initial impl of arbitrary keybindings
Issue: #118 Linux and OSX likely broken for now.
Diffstat (limited to 'facetracknoir/keyboard.h')
-rw-r--r--facetracknoir/keyboard.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h
new file mode 100644
index 00000000..65f5c58e
--- /dev/null
+++ b/facetracknoir/keyboard.h
@@ -0,0 +1,33 @@
+#pragma once
+#include "ui_keyboard_listener.h"
+#include <QLabel>
+#include <QKeyEvent>
+
+class KeyboardListener : public QLabel
+{
+ Q_OBJECT
+ Ui_keyboard_listener ui;
+public:
+ KeyboardListener(QWidget* parent = nullptr) : QLabel(parent)
+ {
+ ui.setupUi(this);
+ setFocusPolicy(Qt::StrongFocus);
+ }
+ void keyPressEvent(QKeyEvent* event) override
+ {
+ {
+ switch (event->key() | event->modifiers())
+ {
+ case 83886113: // ctrl
+ case 50331680: // shift
+ case 150994979: // alt
+ case 16777250: // meta
+ return;
+ default: break;
+ }
+ }
+ emit key_pressed(QKeySequence(event->key()));
+ }
+signals:
+ void key_pressed(QKeySequence k);
+};