summaryrefslogtreecommitdiff
path: root/Applications/Browser
diff options
context:
space:
mode:
Diffstat (limited to 'Applications/Browser')
-rw-r--r--Applications/Browser/Tab.cpp13
-rw-r--r--Applications/Browser/Tab.h3
-rw-r--r--Applications/Browser/main.cpp5
3 files changed, 21 insertions, 0 deletions
diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp
index d5e402196e..c5ba32f83d 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 4f26e55a98..78abe4ddc8 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<void(String)> on_title_change;
Function<void(const URL&)> on_tab_open_request;
@@ -73,6 +74,8 @@ private:
RefPtr<GUI::Menu> m_link_context_menu;
String m_link_context_menu_href;
+ RefPtr<GUI::Menu> m_tab_context_menu;
+
String m_title;
RefPtr<const Gfx::Bitmap> m_icon;
diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp
index 0f5872fab2..ab93e88c9a 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<Browser::Tab&>(clicked_widget);
+ tab.context_menu_requested(context_menu_event.screen_position());
+ };
+
Browser::WindowActions window_actions(*window);
Function<void(URL url, bool activate)> create_new_tab;