diff options
Diffstat (limited to '')
| -rw-r--r-- | src/LuaRuntime.hpp | 1 | ||||
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 9 | ||||
| -rw-r--r-- | src/WindowActionRouter.cpp | 3 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.cpp | 5 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.hpp | 1 | ||||
| -rw-r--r-- | src/widgets/Decorations.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/Decorations.hpp | 1 | ||||
| -rw-r--r-- | src/widgets/IWebViewMediator.hpp | 1 | ||||
| -rw-r--r-- | src/widgets/WebViewStack.cpp | 10 | ||||
| -rw-r--r-- | src/widgets/WebViewStack.hpp | 1 |
10 files changed, 33 insertions, 1 deletions
diff --git a/src/LuaRuntime.hpp b/src/LuaRuntime.hpp index 66572e4..d5cd12c 100644 --- a/src/LuaRuntime.hpp +++ b/src/LuaRuntime.hpp @@ -67,6 +67,7 @@ signals: void webview_js_eval_requested(const QString &js_code, WebViewId view_id); void schedule_for_next_tick(const std::function<void()> &action); void webview_rpc_action_defined(const QString &name, const RpcFunc &action, WebViewId view_id); + void webview_reload_requested(WebViewId webview_id); protected: LuaRuntime(); diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index 28ffd5f..0af1e9e 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -339,6 +339,14 @@ int lua_api_decorations_get_view(lua_State *state) { return 1; } +int lua_api_view_reload(lua_State *state) { + WebViewId webview_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.webview_reload_requested(webview_id); + lua_pushnil(state); + return 1; +} + // :: string -> (table -> nil) -> WebViewId -> nil int lua_api_view_expose(lua_State *state) { const char *name = lua_tostring(state, 1); @@ -390,6 +398,7 @@ static luaL_Reg internals_api[] = { luaL_Reg{"view_scroll", &lua_api_view_scroll}, luaL_Reg{"view_scroll_to_top", &lua_api_view_scroll_top}, luaL_Reg{"view_scroll_to_bottom", &lua_api_view_scroll_bottom}, + luaL_Reg{"view_reload", &lua_api_view_reload}, luaL_Reg{"view_expose", &lua_api_view_expose}, luaL_Reg{"history_back", &lua_history_back}, luaL_Reg{"history_forward", &lua_history_forward}, diff --git a/src/WindowActionRouter.cpp b/src/WindowActionRouter.cpp index 3db1cb3..558a46e 100644 --- a/src/WindowActionRouter.cpp +++ b/src/WindowActionRouter.cpp @@ -82,6 +82,9 @@ void WindowActionRouter::initialize(Configuration *config) { WITH_WEBVIEW_WINDOW(webview_id, window, { window->run_javascript(js_code, webview_id); }); }); + connect(&runtime, &LuaRuntime::webview_reload_requested, this, [this](WebViewId webview_id) { + WITH_WEBVIEW_WINDOW(webview_id, window, { window->reload(webview_id); }); + }); // Search connect(&runtime, &LuaRuntime::search_requested, this, diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp index 7852a66..87e315c 100644 --- a/src/widgets/BrowserWindow.cpp +++ b/src/widgets/BrowserWindow.cpp @@ -10,7 +10,6 @@ #include "WindowActionRouter.hpp" #include "events/KeyPressedEvent.hpp" #include "keymap/KeymapEvaluator.hpp" -#include "widgets/BrowserApp.hpp" #include "widgets/Decorations.hpp" #include "widgets/WebViewStack.hpp" @@ -111,3 +110,7 @@ void BrowserWindow::expose_rpc_function(const QString &name, const RpcFunc &acti WebViewId webview_id) { get_webview_mediator(webview_id)->expose_rpc_function(name, action, webview_id); } + +void BrowserWindow::reload(WebViewId webview_id) { + get_webview_mediator(webview_id)->reload(webview_id); +} diff --git a/src/widgets/BrowserWindow.hpp b/src/widgets/BrowserWindow.hpp index bc6cea1..de48c6e 100644 --- a/src/widgets/BrowserWindow.hpp +++ b/src/widgets/BrowserWindow.hpp @@ -40,6 +40,7 @@ public: void set_html(const QString &html, WebViewId webview_id); void run_javascript(const QString &js_code, WebViewId webview_id); void expose_rpc_function(const QString &name, const RpcFunc &action, WebViewId webview_id); + void reload(WebViewId webview_id); bool on_window_key_event(QObject *target, QKeyEvent *event); diff --git a/src/widgets/Decorations.cpp b/src/widgets/Decorations.cpp index dc644d5..1cff3d4 100644 --- a/src/widgets/Decorations.cpp +++ b/src/widgets/Decorations.cpp @@ -101,3 +101,5 @@ void Decorations::expose_rpc_function(const QString &name, const RpcFunc &action if (decoration.has_value()) decoration.value()->expose_rpc_function(name, action); } + +void Decorations::reload(WebViewId /* unused */) { qDebug() << "TODO: Impl"; } diff --git a/src/widgets/Decorations.hpp b/src/widgets/Decorations.hpp index 97e0415..108b13e 100644 --- a/src/widgets/Decorations.hpp +++ b/src/widgets/Decorations.hpp @@ -32,6 +32,7 @@ public: void run_javascript(const QString &js_code, WebViewId webview_id) override; void expose_rpc_function(const QString &name, const RpcFunc &action, WebViewId webview_id) override; + void reload(WebViewId webview_id) override; private: EdgeDecoration *decoration_top; diff --git a/src/widgets/IWebViewMediator.hpp b/src/widgets/IWebViewMediator.hpp index 9c64e53..a7007f2 100644 --- a/src/widgets/IWebViewMediator.hpp +++ b/src/widgets/IWebViewMediator.hpp @@ -13,4 +13,5 @@ public: virtual void expose_rpc_function(const QString &name, const RpcFunc &action, WebViewId webview_id) = 0; virtual void run_javascript(const QString &js_code, WebViewId webview_id) = 0; + virtual void reload(WebViewId webview_id) = 0; }; diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index 37532ff..ab5808f 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -356,3 +356,13 @@ void WebViewStack::expose_rpc_function(const QString &name, const RpcFunc & /* u WebViewId /* unused */) { qDebug() << "expose_rpc_function: NOT IMPLEMENTED" << name; } + +void WebViewStack::reload(WebViewId webview_id) { + auto *webview = get_webview(webview_id); + if (webview == nullptr) { + qDebug() << "Webview does not exist"; + return; + } + + webview->reload(); +} diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp index 5a88266..bbee44c 100644 --- a/src/widgets/WebViewStack.hpp +++ b/src/widgets/WebViewStack.hpp @@ -65,6 +65,7 @@ public slots: void run_javascript(const QString &js_code, WebViewId webview_id) override; void expose_rpc_function(const QString &name, const RpcFunc &action, WebViewId webview_id) override; + void reload(WebViewId webview_id) override; protected slots: void on_new_webview_request(QWebEngineNewWindowRequest &request); |
