diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index d5e402196e3..c5ba32f83d9 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -310,6 +310,14 @@ Tab::Tab() auto& help_menu = m_menubar->add_menu("Help"); help_menu.add_action(WindowActions::the().about_action()); + + m_tab_context_menu = GUI::Menu::construct(); + m_tab_context_menu->add_action(GUI::Action::create("Reload Tab", [this](auto&) { + m_reload_action->activate(); + })); + m_tab_context_menu->add_action(GUI::Action::create("Close Tab", [this](auto&) { + on_tab_close_request(*this); + })); } Tab::~Tab() @@ -369,4 +377,9 @@ void Tab::did_become_active() GUI::Application::the().set_menubar(m_menubar); } +void Tab::context_menu_requested(const Gfx::Point& screen_position) +{ + m_tab_context_menu->popup(screen_position); +} + } diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index 4f26e55a984..78abe4ddc8c 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -43,6 +43,7 @@ public: void load(const URL&); void did_become_active(); + void context_menu_requested(const Gfx::Point& screen_position); Function on_title_change; Function on_tab_open_request; @@ -73,6 +74,8 @@ private: RefPtr m_link_context_menu; String m_link_context_menu_href; + RefPtr m_tab_context_menu; + String m_title; RefPtr m_icon; diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 0f5872fab2c..ab93e88c9a5 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -121,6 +121,11 @@ int main(int argc, char** argv) tab.on_tab_close_request(tab); }; + tab_widget.on_context_menu_request = [&](auto& clicked_widget, const GUI::ContextMenuEvent& context_menu_event) { + auto& tab = static_cast(clicked_widget); + tab.context_menu_requested(context_menu_event.screen_position()); + }; + Browser::WindowActions window_actions(*window); Function create_new_tab;