aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keymap/KeymapEvaluator.cpp6
-rw-r--r--src/widgets/MainWindow.cpp24
-rw-r--r--src/widgets/WebView.cpp6
-rw-r--r--src/widgets/WebViewStack.cpp5
4 files changed, 37 insertions, 4 deletions
diff --git a/src/keymap/KeymapEvaluator.cpp b/src/keymap/KeymapEvaluator.cpp
new file mode 100644
index 0000000..cca10e8
--- /dev/null
+++ b/src/keymap/KeymapEvaluator.cpp
@@ -0,0 +1,6 @@
+#include <QWidget>
+#include <QtCore>
+
+#include "keymap/KeymapEvaluator.hpp"
+
+KeymapEvaluator::KeymapEvaluator() : QObject() {}
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;
+}
diff --git a/src/widgets/WebView.cpp b/src/widgets/WebView.cpp
new file mode 100644
index 0000000..e00be1f
--- /dev/null
+++ b/src/widgets/WebView.cpp
@@ -0,0 +1,6 @@
+#include <QWidget>
+#include <QtCore>
+
+#include "widgets/WebView.hpp"
+
+WebView::WebView(QWebEngineProfile *profile) : QWebEngineView(profile) {}
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp
index d89db6e..f915d9e 100644
--- a/src/widgets/WebViewStack.cpp
+++ b/src/widgets/WebViewStack.cpp
@@ -1,6 +1,5 @@
#include <QStackedLayout>
#include <QWebEngineNewWindowRequest>
-#include <QWebEngineView>
#include "widgets/WebViewStack.hpp"
@@ -31,8 +30,8 @@ void WebViewStack::openUrl(QUrl url, OpenType openType) {
}
}
-QWebEngineView *WebViewStack::createNewWebView(QUrl url, bool focus) {
- auto webview = new QWebEngineView(profile);
+WebView *WebViewStack::createNewWebView(QUrl url, bool focus) {
+ auto webview = new WebView(profile);
webview->setUrl(url);
layout->addWidget(webview);
webViewList.append(webview);