mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 15:39:55 +00:00
Browser: Pop up a context menu when one is requested on a tab
Currently, the tab's context menu only has options to reload and close, but this patch allows for those options to be quickly expanded!
This commit is contained in:
parent
bf2e6325a4
commit
9241c3a957
Notes:
sideshowbarker
2024-07-19 06:16:24 +09:00
Author: https://github.com/FalseHonesty Commit: https://github.com/SerenityOS/serenity/commit/9241c3a957c Pull-request: https://github.com/SerenityOS/serenity/pull/2291 Reviewed-by: https://github.com/awesomekling
3 changed files with 21 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue