diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | TODO.org | 57 | ||||
| -rw-r--r-- | config.lua | 72 | ||||
| -rw-r--r-- | lua/null-browser/api.lua | 2 | ||||
| -rw-r--r-- | lua/null-browser/extras/dmenu.lua | 4 | ||||
| -rw-r--r-- | spec/WebViewStackSpec.cpp | 40 | ||||
| -rw-r--r-- | src/Configuration.hpp | 4 | ||||
| -rw-r--r-- | src/LuaRuntime.cpp | 64 | ||||
| -rw-r--r-- | src/LuaRuntime.hpp | 20 | ||||
| -rw-r--r-- | src/WindowActionRouter.cpp | 2 | ||||
| -rw-r--r-- | src/WindowActionRouter.hpp | 2 | ||||
| -rw-r--r-- | src/events.hpp | 10 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/WebViewStack.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/WebViewStack.hpp | 4 |
15 files changed, 154 insertions, 148 deletions
@@ -32,8 +32,9 @@ clean: rm -rf build/ rm -f compile_commands.json +ARGS="" run: build-dev - ./build/null-browser + ./build/null-browser $(ARGS) debug: DEBUG=1 make build-dev @@ -5,11 +5,11 @@ - [X] event loop for async work - [X] example: trigger dmenu for simple selection - [X] Fix segfault on quit -- [X] Tab history navigation -- [X] Tab next/prev -- [X] Get tab list api -- [X] Assign ID to each tab (reference in lua api) -- [X] Tab select by id +- [X] view history navigation +- [X] view next/prev +- [X] Get view list api +- [X] Assign ID to each view (reference in lua api) +- [X] view select by id - [X] Multi-window - [X] New window on new window request - [X] Socket for opening window in current session (lua eval) @@ -18,8 +18,8 @@ - [X] Url changed event - [X] History storage - [X] History completion -- [X] Close window if last tab closed -- [ ] Rename terms: webview/tab to page? (also web.tabs) +- [X] Close window if last view closed +- [X] Rename terms: tab to view? (also web.tabs) - [ ] Configuration lua api - [ ] Switch to __internals - [ ] Respect cli args for main window @@ -27,7 +27,8 @@ - [ ] Log stdout, errors and results from lua somewhere - [ ] Downloading/download path config - [ ] Run JS in page -- [ ] Segfault on close +- [ ] INVESTIGATE: Segfault on close +- [ ] INVESTIGATE: Errors in keymap segfaults ** Next - [ ] Search text in page @@ -63,37 +64,37 @@ - [ ] Move modal keymap management into lua? ** Notes -- Tab = 0, nil, none: Current tab +- view = 0, nil, none: Current view - Win = 0: Current window - Win = nil, none: All windows or current window based on operation - Keep track of last focused window (current window is last focused) #+begin_src lua -web.tab.set_url(url) -- Set url for current tab -web.tab.set_url(url, { tab = 1 }) -- Set url for tab 1 -web.tab.set_url(url, { tab = 1, win = 1 }) -- Set url for tab 1 in win 1 -web.tab.set_url(url, { win = 1 }) -- Set url for current tab in win 1 +web.view.set_url(url) -- Set url for current view +web.view.set_url(url, { view = 1 }) -- Set url for view 1 +web.view.set_url(url, { view = 1, win = 1 }) -- Set url for view 1 in win 1 +web.view.set_url(url, { win = 1 }) -- Set url for current view in win 1 -web.tab.new(url, { win = 1 }) -- New tab in win 1 -web.tab.new(url) -- New tab in current window +web.view.new(url, { win = 1 }) -- New view in win 1 +web.view.new(url) -- New view in current window -web.tab.close({ tab = 1 }) -- Close tab 1 -web.tab.close() -- Close current tab in current window +web.view.close({ view = 1 }) -- Close view 1 +web.view.close() -- Close current view in current window -web.tab.list({ win = nil }) -- List all tabs -web.tab.list({ win = 1 }) -- List win 1 tabs +web.view.list({ win = nil }) -- List all tabs +web.view.list({ win = 1 }) -- List win 1 tabs -web.tab.select({ tab = 1, win = 1 }) -- Select win 1 tab -web.tab.select({ tab = 1, win = 0 }) -- Select tab 1 in current window -web.tab.select({ tab = 1 }) -- Select tab 1 +web.view.select({ view = 1, win = 1 }) -- Select win 1 view +web.view.select({ view = 1, win = 0 }) -- Select view 1 in current window +web.view.select({ view = 1 }) -- Select view 1 -web.tab.current({ win = 1 }) -- Current tab in win 1 -web.tab.current() -- Current tab in current win +web.view.current({ win = 1 }) -- Current view in win 1 +web.view.current() -- Current view in current win -web.history.back(1) -- Back for current tab in current window -web.history.back(1, { tab = 1 }) -- Back for tab 1 -web.history.back(1, { win = 1 }) -- Back for current tab in win 1 +web.history.back(1) -- Back for current view in current window +web.history.back(1, { view = 1 }) -- Back for view 1 +web.history.back(1, { win = 1 }) -- Back for current view in win 1 -web.keymap.set('n', '<c-r>', ..., { tab = 1 }) -- Set keymap for tab 1 +web.keymap.set('n', '<c-r>', ..., { view = 1 }) -- Set keymap for view 1 web.keymap.set('n', '<c-r>', ..., { win = 1 }) -- Set keymap for win 1 web.opt.new_tab_url = 'https://duckduckgo.com' #+end_src @@ -5,10 +5,10 @@ web = web --- @type table uv = uv -local function get_current_tab_index() - local currentTab = web.tabs.current(); - for index, tab in ipairs(web.tabs.list()) do - if tab.id == currentTab then +local function get_current_view_index() + local currentView = web.view.current(); + for index, view in ipairs(web.view.list()) do + if view.id == currentView then return index end end @@ -36,18 +36,18 @@ local function to_url(url) return "https://" .. trim(url) end --- Open in new tab +-- Open in new view web.keymap.set('n', 'o', function() - dmenu.select(history.list(), { prompt = 'Open tab:' }, function(err, result) + dmenu.select(history.list(), { prompt = 'Open view:' }, function(err, result) if err or not result then return end - web.tabs.new(to_url(result)) + web.view.new(to_url(result)) end) end) --- Open in current tab +-- Open in current view web.keymap.set('n', '<s-o>', function() dmenu.select(history.list(), { prompt = 'Open:' }, function(err, result) if err or not result then return end - web.tabs.set_url(to_url(result)) + web.view.set_url(to_url(result)) end) end) -- Delete from history @@ -59,12 +59,12 @@ web.keymap.set('n', '<c-h>d', function() end) -- Update current url web.keymap.set('n', '<c-l>', function() - local tabs = web.tabs.list() - local tab = tabs[get_current_tab_index()]; - if tab == nil then return end - dmenu.select(history.list(), { prompt = 'Set url:', input = tab.url }, function(err, result) + local views = web.view.list() + local view = views[get_current_view_index()]; + if view == nil then return end + dmenu.select(history.list(), { prompt = 'Set url:', input = view.url }, function(err, result) if err or not result then return end - web.tabs.set_url(trim(result)) + web.view.set_url(trim(result)) end) end) @@ -82,42 +82,42 @@ end) web.keymap.set('n', '<s-h>', function() web.history.back(); end) web.keymap.set('n', '<s-l>', function() web.history.forward(); end) --- Close tab -web.keymap.set('n', '<c-w>', function() web.tabs.close(); end) +-- Close view +web.keymap.set('n', '<c-w>', function() web.view.close(); end) --- Tab select +-- view select web.keymap.set('n', 'b', function() - local tabs_list = {} - local tabs = web.tabs.list() - for index, tab in ipairs(web.tabs.list()) do - table.insert(tabs_list, index .. ': ' .. tab.title .. ' (' .. tab.url .. ')') + local views_list = {} + local views = web.view.list() + for index, view in ipairs(web.view.list()) do + table.insert(views_list, index .. ': ' .. view.title .. ' (' .. view.url .. ')') end - dmenu.select(tabs_list, { prompt = 'Tab:' }, function(err, result) + dmenu.select(views_list, { prompt = 'Views:' }, function(err, result) if err or not result then return end local index_str, _ = trim(result):gsub('%s*:.*$', '') local index = tonumber(index_str) - if tabs[index] then - web.tabs.select(tabs[index].id) + if views[index] then + web.view.select(views[index].id) end end) end) --- Next tab +-- Next view web.keymap.set('n', 'tn', function() - local tabs = web.tabs.list() - if #tabs <= 1 then return end - local index = get_current_tab_index() + 1; - if index > #tabs then index = 1 end - web.tabs.select(tabs[index].id) + local views = web.view.list() + if #views <= 1 then return end + local index = get_current_view_index() + 1; + if index > #views then index = 1 end + web.view.select(views[index].id) end) --- Prev tab +-- Prev view web.keymap.set('n', 'tp', function() - local tabs = web.tabs.list() - if #tabs <= 1 then return end - local index = get_current_tab_index() - 1; - if index <= 0 then index = #tabs end - web.tabs.select(tabs[index].id) + local views = web.views.list() + if #views <= 1 then return end + local index = get_current_view_index() - 1; + if index <= 0 then index = #views end + web.views.select(views[index].id) end) print('ending...') diff --git a/lua/null-browser/api.lua b/lua/null-browser/api.lua index 6db0da9..3949fbc 100644 --- a/lua/null-browser/api.lua +++ b/lua/null-browser/api.lua @@ -18,7 +18,7 @@ else end -- web.keymap = web.keymap or {} --- web.tab = web.tab or {} +-- web.view = web.view or {} web.event = web.event or {} --- Listen to events from the browser diff --git a/lua/null-browser/extras/dmenu.lua b/lua/null-browser/extras/dmenu.lua index 164533b..c7a941f 100644 --- a/lua/null-browser/extras/dmenu.lua +++ b/lua/null-browser/extras/dmenu.lua @@ -12,6 +12,10 @@ function dmenu.select(list, opts, callback) table.insert(args, '-p') table.insert(args, opts.prompt) end + if opts.input then + table.insert(args, '-it') + table.insert(args, opts.input) + end uv.spawn('dmenu', { args = args, stdio = { stdin, stdout, nil } }, function(code) uv.close(stdout) diff --git a/spec/WebViewStackSpec.cpp b/spec/WebViewStackSpec.cpp index 0563a5f..fb3add0 100644 --- a/spec/WebViewStackSpec.cpp +++ b/spec/WebViewStackSpec.cpp @@ -29,7 +29,7 @@ private slots: WebViewStack webview_stack(&configuration); QCOMPARE(webview_stack.count(), 0); - QCOMPARE(webview_stack.current_url(), configuration.new_tab_url); + QCOMPARE(webview_stack.current_url(), configuration.new_view_url); } } @@ -49,11 +49,11 @@ private slots: } context("when openUrl is called with webviews open"); - it("replaces current tab url with newtab url") { + it("replaces current view url with newview url") { Configuration configuration; WebViewStack webview_stack(&configuration); webview_stack.open_url(QUrl("http://a.com")); - webview_stack.open_url(QUrl("http://b.com"), OpenType::OpenUrlInTab); + webview_stack.open_url(QUrl("http://b.com"), OpenType::OpenUrlInView); QCOMPARE(webview_stack.count(), 2); QCOMPARE(webview_stack.current_webview_index(), 1); @@ -68,13 +68,13 @@ private slots: QCOMPARE(webview_stack.current_url(), QUrl("http://new-b.com")); } - context("when openurl is called with OpenUrlInBgTab"); + context("when openurl is called with OpenUrlInBgView"); it("opens the given url in background") { Configuration configuration; WebViewStack webview_stack(&configuration); webview_stack.open_url(QUrl("http://a.com")); - webview_stack.open_url(QUrl("https://duckduckgo.com"), OpenType::OpenUrlInBgTab); + webview_stack.open_url(QUrl("https://duckduckgo.com"), OpenType::OpenUrlInBgView); QCOMPARE(webview_stack.count(), 2); QCOMPARE(webview_stack.urls(), @@ -83,13 +83,13 @@ private slots: QCOMPARE(webview_stack.current_url(), QUrl("http://a.com")); } - context("when openurl is called with OpenUrlInTab"); + context("when openurl is called with OpenUrlInView"); it("opens the given url as current view") { Configuration configuration; WebViewStack webview_stack(&configuration); webview_stack.open_url(QUrl("http://a.com")); - webview_stack.open_url(QUrl("https://duckduckgo.com"), OpenType::OpenUrlInTab); + webview_stack.open_url(QUrl("https://duckduckgo.com"), OpenType::OpenUrlInView); QCOMPARE(webview_stack.count(), 2); QCOMPARE(webview_stack.urls(), @@ -131,7 +131,7 @@ private slots: } context("when close is called on current webview"); - context("- and there is only 1 tab"); + context("- and there is only 1 view"); it("requests closing window") { Configuration configuration; WebViewStack webview_stack(&configuration); @@ -146,14 +146,14 @@ private slots: } context("when close is called"); - context("- with the current tab id"); - context("- and there are some tabs after"); - it("closes the tab and focuses the next tab") { + context("- with the current view id"); + context("- and there are some views after"); + it("closes the view and focuses the next view") { Configuration configuration; WebViewStack webview_stack(&configuration); webview_stack.open_url(QUrl("https://a0.com")); - webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInTab); - webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab); + webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInView); + webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInBgView); QCOMPARE(webview_stack.count(), 3); QCOMPARE(webview_stack.current_webview_index(), 1); @@ -167,14 +167,14 @@ private slots: } context("when close is called"); - context("- with the current tab id"); - context("- which is the last tab"); - it("closes the tab and focuses previous tab") { + context("- with the current view id"); + context("- which is the last view"); + it("closes the view and focuses previous view") { Configuration configuration; WebViewStack webview_stack(&configuration); webview_stack.open_url(QUrl("https://a0.com")); - webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInBgTab); - webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInTab); + webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInBgView); + webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInView); QCOMPARE(webview_stack.count(), 3); QCOMPARE(webview_stack.current_webview_index(), 2); @@ -190,7 +190,7 @@ private slots: void test_new_window_request_signal() { context("when webview emits a newWindowRequested signal"); - context("- of type new tab"); + context("- of type new view"); it("opens a new web view and focuses it") { Configuration configuration; WebViewStack webview_stack(&configuration); @@ -210,7 +210,7 @@ private slots: } context("when webview emits a newWindowRequested signal"); - context("- of type new background tab"); + context("- of type new background view"); it("opens a new web view in the background") { Configuration configuration; WebViewStack webview_stack(&configuration); diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 837e3e6..c1744e6 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -8,7 +8,7 @@ class Configuration : public QObject { public: using QObject::QObject; - QUrl new_tab_url = QUrl("https://lite.duckduckgo.com"); + QUrl new_view_url = QUrl("https://lite.duckduckgo.com"); - bool close_window_when_no_tabs = true; + bool close_window_when_no_views = true; }; diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp index d54bb37..036f47f 100644 --- a/src/LuaRuntime.cpp +++ b/src/LuaRuntime.cpp @@ -154,18 +154,18 @@ void LuaRuntime::init_web_lib() { luaL_newlib(state, webkeymap); lua_setfield(state, -2, "keymap"); - // Tab actions (web.tabs) - luaL_Reg webtabs[] = { - {"close", &LuaRuntime::lua_tab_close}, - {"new", &LuaRuntime::lua_tab_create}, - {"current", &LuaRuntime::lua_tab_current}, - {"list", &LuaRuntime::lua_tab_list}, - {"select", &LuaRuntime::lua_tab_select}, + // View actions (web.view) + luaL_Reg webviews[] = { + {"close", &LuaRuntime::lua_view_close}, + {"new", &LuaRuntime::lua_view_create}, + {"current", &LuaRuntime::lua_view_current}, + {"list", &LuaRuntime::lua_view_list}, + {"select", &LuaRuntime::lua_view_select}, {"set_url", &LuaRuntime::lua_open_url}, {nullptr, nullptr}, }; - luaL_newlib(state, webtabs); - lua_setfield(state, -2, "tabs"); + luaL_newlib(state, webviews); + lua_setfield(state, -2, "view"); // History navigation luaL_Reg webhistory[] = { @@ -197,16 +197,16 @@ QVariant LuaRuntime::get_lua_value(int idx, QVariant default_value) { int LuaRuntime::lua_open_url(lua_State *state) { const char *url = lua_tostring(state, 1); - WebViewId tab_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); + WebViewId view_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); auto &runtime = LuaRuntime::instance(); - emit runtime.url_opened(url, OpenType::OpenUrl, tab_id); + emit runtime.url_opened(url, OpenType::OpenUrl, view_id); return 1; } -int LuaRuntime::lua_tab_create(lua_State *state) { +int LuaRuntime::lua_view_create(lua_State *state) { const char *url = luaL_optstring(state, 1, ""); auto &runtime = LuaRuntime::instance(); - emit runtime.url_opened(url, OpenType::OpenUrlInTab, 0); + emit runtime.url_opened(url, OpenType::OpenUrlInView, 0); return 1; } @@ -233,32 +233,32 @@ int LuaRuntime::lua_keymap_set(lua_State *state) { return 1; } -int LuaRuntime::lua_tab_current(lua_State *state) { +int LuaRuntime::lua_view_current(lua_State *state) { auto &router = WindowActionRouter::instance(); - auto tab_id = router.fetch_current_tab_id(); - lua_pushinteger(state, tab_id); + auto view_id = router.fetch_current_view_id(); + lua_pushinteger(state, view_id); return 1; } -int LuaRuntime::lua_tab_list(lua_State *state) { +int LuaRuntime::lua_view_list(lua_State *state) { auto &router = WindowActionRouter::instance(); - auto tabs = router.fetch_webview_data_list(); + auto views = router.fetch_webview_data_list(); lua_newtable(state); int index = 1; // 1-indexed - for (auto &tab : tabs) { + for (auto &view : views) { lua_newtable(state); lua_pushstring(state, "id"); - lua_pushinteger(state, tab.id); + lua_pushinteger(state, view.id); lua_settable(state, -3); lua_pushstring(state, "url"); - lua_pushstring(state, tab.url.toStdString().c_str()); + lua_pushstring(state, view.url.toStdString().c_str()); lua_settable(state, -3); lua_pushstring(state, "title"); - lua_pushstring(state, tab.title.toStdString().c_str()); + lua_pushstring(state, view.title.toStdString().c_str()); lua_settable(state, -3); lua_rawseti(state, -2, index); @@ -273,9 +273,9 @@ int LuaRuntime::lua_history_back(lua_State *state) { qsizetype history_index = lua_isnoneornil(state, 1) ? 1 : lua_tointeger(state, 1); - WebViewId tab_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); + WebViewId view_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); - emit runtime.history_back_requested(tab_id, history_index); + emit runtime.history_back_requested(view_id, history_index); return 1; } @@ -284,28 +284,28 @@ int LuaRuntime::lua_history_forward(lua_State *state) { qsizetype history_index = lua_isnoneornil(state, 1) ? 1 : lua_tointeger(state, 1); - WebViewId tab_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); + WebViewId view_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); - emit runtime.history_forward_requested(tab_id, history_index); + emit runtime.history_forward_requested(view_id, history_index); return 1; } -int LuaRuntime::lua_tab_close(lua_State *state) { +int LuaRuntime::lua_view_close(lua_State *state) { auto &runtime = LuaRuntime::instance(); - WebViewId tab_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); - emit runtime.webview_closed(tab_id); + emit runtime.webview_closed(view_id); return 1; } -int LuaRuntime::lua_tab_select(lua_State *state) { +int LuaRuntime::lua_view_select(lua_State *state) { if (lua_isnoneornil(state, 1)) return 1; // TODO: return nil (for others too) auto &runtime = LuaRuntime::instance(); - WebViewId tab_id = lua_tointeger(state, 1); - emit runtime.webview_selected(tab_id); + WebViewId view_id = lua_tointeger(state, 1); + emit runtime.webview_selected(view_id); return 1; } diff --git a/src/LuaRuntime.hpp b/src/LuaRuntime.hpp index e73650c..64bb1f1 100644 --- a/src/LuaRuntime.hpp +++ b/src/LuaRuntime.hpp @@ -14,11 +14,11 @@ #define PROJECT_LUA_PATH "" #endif -#define preserve_top(STATE, BODY) \ - { \ - const int __top = lua_gettop(STATE); \ - BODY; \ - lua_settop(STATE, __top); \ +#define preserve_top(STATE, BODY) \ + { \ + const int __top = lua_gettop(STATE); \ + BODY; \ + lua_settop(STATE, __top); \ }; class LuaRuntime : public QObject { @@ -66,11 +66,11 @@ protected: static int lua_event_register(lua_State *state); static int lua_keymap_set(lua_State *state); static int lua_open_url(lua_State *state); - static int lua_tab_close(lua_State *state); - static int lua_tab_create(lua_State *state); - static int lua_tab_current(lua_State *state); - static int lua_tab_list(lua_State *state); - static int lua_tab_select(lua_State *state); + static int lua_view_close(lua_State *state); + static int lua_view_create(lua_State *state); + static int lua_view_current(lua_State *state); + static int lua_view_list(lua_State *state); + static int lua_view_select(lua_State *state); private: lua_State *state; diff --git a/src/WindowActionRouter.cpp b/src/WindowActionRouter.cpp index d1cd816..51e24e9 100644 --- a/src/WindowActionRouter.cpp +++ b/src/WindowActionRouter.cpp @@ -74,7 +74,7 @@ void WindowActionRouter::add_keymap(const QString &mode_string, const QString &k keymap_evaluator.add_keymap(mode, keyseq, std::move(action)); } -WebViewId WindowActionRouter::fetch_current_tab_id(WindowId win_id) { +WebViewId WindowActionRouter::fetch_current_view_id(WindowId win_id) { const std::lock_guard<std::mutex> lock(window_map_mutex); for (auto &pair : window_map) { auto *win = pair.second; diff --git a/src/WindowActionRouter.hpp b/src/WindowActionRouter.hpp index 3c82b28..cfb25da 100644 --- a/src/WindowActionRouter.hpp +++ b/src/WindowActionRouter.hpp @@ -32,7 +32,7 @@ public: void add_window(BrowserWindow *window); const WindowMap &windows(); - WebViewId fetch_current_tab_id(WindowId win_id = 0); + WebViewId fetch_current_view_id(WindowId win_id = 0); QList<WebViewData> fetch_webview_data_list(WindowId win_id = 0); DELEGATE((&event_queue), dispatch_event, dispatch_event); diff --git a/src/events.hpp b/src/events.hpp index 96b9008..ffa4f8b 100644 --- a/src/events.hpp +++ b/src/events.hpp @@ -7,9 +7,9 @@ #include "widgets/BrowserWindow.hpp" #include "widgets/WebViewStack.hpp" -#define SET_FIELD(NAME, TYPE, VALUE) \ - lua_pushstring(state, NAME); \ - lua_push##TYPE(state, VALUE); \ +#define SET_FIELD(NAME, TYPE, VALUE) \ + lua_pushstring(state, NAME); \ + lua_push##TYPE(state, VALUE); \ lua_settable(state, -3); class BrowserEvent { @@ -33,8 +33,8 @@ public: void lua_push(lua_State *state) const override { lua_newtable(state); - SET_FIELD("tab", integer, webview_id) - SET_FIELD("win", integer, win_id) + SET_FIELD("view_id", integer, webview_id) + SET_FIELD("win_id", integer, win_id) SET_FIELD("url", string, url.toStdString().c_str()) } }; diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp index f1b786b..cc3c6a8 100644 --- a/src/widgets/BrowserWindow.cpp +++ b/src/widgets/BrowserWindow.cpp @@ -27,10 +27,10 @@ BrowserWindow::BrowserWindow(const Configuration &configuration, const QStringLi // Open webviews for given urls if (urls.isEmpty()) { - webview_stack->open_url(configuration.new_tab_url.toString()); + webview_stack->open_url(configuration.new_view_url.toString()); } else { for (const auto &url : urls) { - webview_stack->open_url(url, OpenType::OpenUrlInTab); + webview_stack->open_url(url, OpenType::OpenUrlInView); } } diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index 8c432f1..d43c9b5 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -28,10 +28,10 @@ void WebViewStack::open_url(const QUrl &url, OpenType open_type, WebViewId webvi case OpenType::OpenUrl: set_webview_url(url, webview_id); break; - case OpenType::OpenUrlInTab: + case OpenType::OpenUrlInView: create_new_webview(url, true); break; - case OpenType::OpenUrlInBgTab: + case OpenType::OpenUrlInBgView: create_new_webview(url, false); break; case OpenType::OpenUrlInWindow: @@ -81,10 +81,10 @@ QList<WebViewData> WebViewStack::get_webview_list() { void WebViewStack::on_new_webview_request(const QWebEngineNewWindowRequest &request) { switch (request.destination()) { case QWebEngineNewWindowRequest::InNewTab: - open_url(request.requestedUrl(), OpenType::OpenUrlInTab); + open_url(request.requestedUrl(), OpenType::OpenUrlInView); break; case QWebEngineNewWindowRequest::InNewBackgroundTab: - open_url(request.requestedUrl(), OpenType::OpenUrlInBgTab); + open_url(request.requestedUrl(), OpenType::OpenUrlInBgView); break; case QWebEngineNewWindowRequest::InNewWindow: case QWebEngineNewWindowRequest::InNewDialog: @@ -126,10 +126,10 @@ void WebViewStack::close(WebViewId webview_id) { webview->deleteLater(); if (webview_list.isEmpty()) { - if (configuration->close_window_when_no_tabs) { + if (configuration->close_window_when_no_views) { emit close_window_requested(); } else { - create_new_webview(configuration->new_tab_url, true); + create_new_webview(configuration->new_view_url, true); } } } @@ -204,7 +204,7 @@ QUrl WebViewStack::current_url() { auto *webview = current_webview(); if (webview == nullptr) { qDebug() << "No current webview"; - return configuration->new_tab_url; + return configuration->new_view_url; } return webview->url(); diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp index 7cc2143..b36c389 100644 --- a/src/widgets/WebViewStack.hpp +++ b/src/widgets/WebViewStack.hpp @@ -12,8 +12,8 @@ using WebViewId = qsizetype; enum OpenType : uint8_t { OpenUrl, - OpenUrlInTab, - OpenUrlInBgTab, + OpenUrlInView, + OpenUrlInBgView, OpenUrlInWindow, }; |
