aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/MainWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/MainWindow.cpp')
-rw-r--r--src/widgets/MainWindow.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp
index d2b1578..7d045bc 100644
--- a/src/widgets/MainWindow.cpp
+++ b/src/widgets/MainWindow.cpp
@@ -1,8 +1,9 @@
#include <QKeyEvent>
#include <QStackedLayout>
#include <QVBoxLayout>
-#include <QWebEngineView>
+#include <QtCore/qcoreevent.h>
#include <QtCore/qnamespace.h>
+#include <QtWidgets/qapplication.h>
#include "InputMediator.hpp"
#include "widgets/InputLine.hpp"
@@ -13,6 +14,8 @@ MainWindow::MainWindow() {
setStyleSheet("background-color: #000; color: #fff;");
setCentralWidget(new QWidget()); // TODO: manage widget memory
+ qApp->installEventFilter(this);
+
// Root stacked layout
auto layout = new QStackedLayout();
layout->setContentsMargins(0, 0, 0, 0);
@@ -31,6 +34,9 @@ MainWindow::MainWindow() {
inputMediator =
new InputMediator(inputLine, webViewStack, LuaRuntime::instance());
+
+ keymapEvaluator.addKeymap("default", "<c-t>a", "Stuff");
+ keymapEvaluator.addKeymap("default", "<c-t>b", "Other stuff");
}
void MainWindow::keyPressEvent(QKeyEvent *event) {
@@ -57,3 +63,19 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
inputMediator->closeCurrentWebView();
}
}
+
+bool MainWindow::eventFilter(QObject *object, QEvent *event) {
+ if (event->type() != QEvent::KeyPress && event->type() != QEvent::KeyRelease)
+ return false;
+
+ if (auto keyEvent = dynamic_cast<QKeyEvent *>(event)) {
+ if (keyEvent->type() == QEvent::KeyPress)
+ keymapEvaluator.evaluate(keyEvent->modifiers(), (Qt::Key)keyEvent->key());
+
+ // qDebug() << "EV SELF: " << (object == this) << " | " << event->type();
+ // qDebug() << "Key: " << keyEvent->modifiers() << keyEvent->key();
+ return true;
+ }
+
+ return false;
+}