aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-07-26 18:43:45 +0530
committerAkshay Nair <phenax5@gmail.com>2025-07-26 18:55:10 +0530
commitf13a1a1c4eab8bdef3760dd71cd7e2b3cc68a3e8 (patch)
treec431eeb6b2de06778c2888d25a1fe5fd67608fec /src
parente8dfd7aa6b0aa37b2260e4593d475f25bbe2bdc4 (diff)
downloadnull-browser-f13a1a1c4eab8bdef3760dd71cd7e2b3cc68a3e8.tar.gz
null-browser-f13a1a1c4eab8bdef3760dd71cd7e2b3cc68a3e8.zip
Add ModeChanged event and display mode in bottom decoration
Diffstat (limited to 'src')
-rw-r--r--src/WindowActionRouter.cpp8
-rw-r--r--src/events/ModeChangedEvent.hpp19
-rw-r--r--src/widgets/EdgeDecoration.cpp5
-rw-r--r--src/widgets/EdgeDecoration.hpp2
4 files changed, 29 insertions, 5 deletions
diff --git a/src/WindowActionRouter.cpp b/src/WindowActionRouter.cpp
index 3aeabc7..d0cc6d0 100644
--- a/src/WindowActionRouter.cpp
+++ b/src/WindowActionRouter.cpp
@@ -4,6 +4,7 @@
#include <unordered_map>
#include "LuaRuntime.hpp"
+#include "events/ModeChangedEvent.hpp"
#include "keymap/KeymapEvaluator.hpp"
#include "widgets/BrowserWindow.hpp"
@@ -19,8 +20,11 @@ void WindowActionRouter::initialize(Configuration *config) {
configuration = config;
connect(&runtime, &LuaRuntime::keymap_add_requested, this, &WindowActionRouter::add_keymap);
- connect(&runtime, &LuaRuntime::keymap_mode_update_requested, this,
- [](const QString &mode) { KeymapEvaluator::instance().set_current_mode(mode); });
+ connect(&runtime, &LuaRuntime::keymap_mode_update_requested, this, [](const QString &mode) {
+ KeymapEvaluator::instance().set_current_mode(mode);
+ auto *event = new ModeChangedEvent(mode);
+ WindowActionRouter::instance().dispatch_event(event);
+ });
// Configuration
connect(&runtime, &LuaRuntime::config_updated, configuration, &Configuration::set_config);
diff --git a/src/events/ModeChangedEvent.hpp b/src/events/ModeChangedEvent.hpp
new file mode 100644
index 0000000..fcb7dd2
--- /dev/null
+++ b/src/events/ModeChangedEvent.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <QtCore>
+#include <lua.hpp>
+
+#include "events/Event.hpp"
+#include "keymap/KeymapEvaluator.hpp"
+
+class ModeChangedEvent : public Event {
+public:
+ const KeyMode mode;
+
+ ModeChangedEvent(KeyMode mode) : mode(std::move(mode)) { kind = "ModeChanged"; }
+
+ void lua_push(lua_State *state) const override {
+ Event::lua_push(state);
+ SET_FIELD("mode", string, mode.toStdString().c_str())
+ }
+};
diff --git a/src/widgets/EdgeDecoration.cpp b/src/widgets/EdgeDecoration.cpp
index ed48857..7351552 100644
--- a/src/widgets/EdgeDecoration.cpp
+++ b/src/widgets/EdgeDecoration.cpp
@@ -4,7 +4,6 @@
#include <qlabel.h>
#include <qwebengineview.h>
-#include "LuaRuntime.hpp"
#include "widgets/WebView.hpp"
#include "widgets/WebViewStack.hpp"
@@ -28,9 +27,11 @@ QString default_html_layout = R"HTML(
:where(html, body) {
margin: 0;
padding: 0;
- background: #333;
+ background: #111;
color: white;
overflow: hidden;
+ text-size: 12px;
+ font-family: monospace;
}
</style>
diff --git a/src/widgets/EdgeDecoration.hpp b/src/widgets/EdgeDecoration.hpp
index 2af567c..3c90cfb 100644
--- a/src/widgets/EdgeDecoration.hpp
+++ b/src/widgets/EdgeDecoration.hpp
@@ -32,7 +32,7 @@ private:
QWebEngineProfile *profile;
bool enabled = false;
QString html_content = "";
- uint16_t size = 24;
+ uint16_t size = 20;
void setup_webview();
};