diff options
author | TheFightingCatfish <seekingblues@gmail.com> | 2021-08-07 00:21:14 +0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-06 21:03:34 +0200 |
commit | 9899addb1d5b85942720def1ca3e2bb1a401974a (patch) | |
tree | 26d9d2bd85f9bbe7e3d9d51560114212f5266e84 /Userland | |
parent | 8a0d465fbccf86b0fc6b6b90a2456043f73a4601 (diff) | |
download | serenity-9899addb1d5b85942720def1ca3e2bb1a401974a.zip |
Browser: Add more tab options
Add more tab options to Browser: "Duplicate Tab" and "Close Other Tabs".
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/Browser/BrowserWindow.cpp | 8 | ||||
-rw-r--r-- | Userland/Applications/Browser/Tab.cpp | 6 | ||||
-rw-r--r-- | Userland/Applications/Browser/Tab.h | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 9429f88fe0..4f2f3e6d91 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -542,6 +542,14 @@ void BrowserWindow::create_new_tab(URL url, bool activate) }); }; + new_tab.on_tab_close_other_request = [this](auto& tab) { + m_tab_widget->deferred_invoke([this, &tab](auto&) { + m_tab_widget->remove_all_tabs_except(tab); + VERIFY(m_tab_widget->children().size() == 1); + m_tab_widget->set_bar_visible(false); + }); + }; + new_tab.on_get_cookie = [this](auto& url, auto source) -> String { return m_cookie_jar.get_cookie(url, source); }; diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index aa7fe0bc53..b8f2527d56 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -337,6 +337,12 @@ Tab::Tab(BrowserWindow& window, Type type) m_tab_context_menu->add_action(GUI::Action::create("&Close Tab", [this](auto&) { on_tab_close_request(*this); })); + m_tab_context_menu->add_action(GUI::Action::create("&Duplicate Tab", [this](auto&) { + on_tab_open_request(url()); + })); + m_tab_context_menu->add_action(GUI::Action::create("Close &Other Tabs", [this](auto&) { + on_tab_close_other_request(*this); + })); m_page_context_menu = GUI::Menu::construct(); m_page_context_menu->add_action(window.go_back_action()); diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index 48f360f0fd..8e4cb93ee8 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -58,6 +58,7 @@ public: Function<void(const String&)> on_title_change; Function<void(const URL&)> on_tab_open_request; Function<void(Tab&)> on_tab_close_request; + Function<void(Tab&)> on_tab_close_other_request; Function<void(const Gfx::Bitmap&)> on_favicon_change; Function<String(const URL&, Web::Cookie::Source source)> on_get_cookie; Function<void(const URL&, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source)> on_set_cookie; |