diff options
Diffstat (limited to '')
| -rw-r--r-- | src/widgets/BrowserApp.cpp | 5 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.cpp | 5 | ||||
| -rw-r--r-- | src/widgets/WebView.cpp | 13 | ||||
| -rw-r--r-- | src/widgets/WebView.hpp | 4 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/widgets/BrowserApp.cpp b/src/widgets/BrowserApp.cpp index 922c5cc..d6f274b 100644 --- a/src/widgets/BrowserApp.cpp +++ b/src/widgets/BrowserApp.cpp @@ -41,6 +41,11 @@ BrowserApp::BrowserApp(Configuration &configuration) : configuration(configurati setup_profile(profile); } + // Default keymaps + auto &keymap = KeymapEvaluator::instance(); + keymap.define_mode("n", {.passthrough = false}); + keymap.define_mode("i", {.passthrough = true}); + connect(&window_action_router, &WindowActionRouter::new_window_requested, this, [this](const QUrl &url) { create_window({url.toString()}); }); }; diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp index 1fcf0c0..5d78360 100644 --- a/src/widgets/BrowserWindow.cpp +++ b/src/widgets/BrowserWindow.cpp @@ -37,11 +37,6 @@ BrowserWindow::BrowserWindow(const Configuration &configuration, QWebEngineProfi } } - // Default keymaps - auto &keymap = KeymapEvaluator::instance(); - keymap.define_mode("n", {.passthrough = false}); - keymap.define_mode("i", {.passthrough = true}); - // Update window title when webview changes connect(webview_stack, &WebViewStack::current_webview_title_changed, this, [this](int index) { auto webviews = webview_stack->get_webview_list(); diff --git a/src/widgets/WebView.cpp b/src/widgets/WebView.cpp index 604a502..2941e8d 100644 --- a/src/widgets/WebView.cpp +++ b/src/widgets/WebView.cpp @@ -5,8 +5,8 @@ #include <qwebenginepage.h> #include <qwebengineprofile.h> -#include "LuaRuntime.hpp" #include "schemes/NullRpcSchemeHandler.hpp" + #include "widgets/WebView.hpp" WebView::WebView(uint32_t webview_id, QWebEngineProfile *profile, QWidget *parent_node) @@ -50,6 +50,7 @@ void WebView::scroll_to_bottom() { } void WebView::enable_rpc_api() { + rpc_enabled = true; auto &nullrpc = NullRPCSchemeHandler::instance(); connect(&nullrpc, &NullRPCSchemeHandler::message_received, this, &WebView::on_rpc_message); } @@ -58,16 +59,14 @@ void WebView::expose_rpc_function(const QString &name, const RpcFunc &action) { exposed_functions.insert({name, action}); } -void WebView::on_rpc_message(const QString &action, const QUrlQuery ¶ms) { - if (!exposed_functions.contains(action)) { - qDebug() << "function not defined:" << action; +void WebView::on_rpc_message(const NullRPCMessage &message) { + if (!rpc_enabled || !exposed_functions.contains(message.name)) return; - } RpcArgs args; - for (auto pair : params.queryItems()) + for (auto pair : message.params.queryItems()) args.insert(pair); - auto func = exposed_functions.at(action); + auto func = exposed_functions.at(message.name); func(args); } diff --git a/src/widgets/WebView.hpp b/src/widgets/WebView.hpp index 5be9831..7a767d3 100644 --- a/src/widgets/WebView.hpp +++ b/src/widgets/WebView.hpp @@ -12,6 +12,7 @@ #include <qurlquery.h> #include <unordered_map> +#include "schemes/NullRpcSchemeHandler.hpp" #include "utils.hpp" #include "widgets/DevtoolsWindow.hpp" @@ -36,6 +37,7 @@ private: uint32_t id; DevtoolsWindow *devtools_window = nullptr; std::unordered_map<QString, RpcFunc> exposed_functions; + bool rpc_enabled = false; - void on_rpc_message(const QString &action, const QUrlQuery ¶ms); + void on_rpc_message(const NullRPCMessage &message); }; |
