mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00:00
LibVT+Terminal: Mark default action in context menu
This commit is contained in:
parent
f36c67c960
commit
e59c415ae3
1 changed files with 10 additions and 4 deletions
|
@ -806,6 +806,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context_menu_for_hyperlink = GUI::Menu::construct();
|
m_context_menu_for_hyperlink = GUI::Menu::construct();
|
||||||
|
RefPtr<GUI::Action> context_menu_default_action;
|
||||||
|
|
||||||
// Go through the list of handlers and see if we can find a nice display name + icon for them.
|
// Go through the list of handlers and see if we can find a nice display name + icon for them.
|
||||||
// Then add them to the context menu.
|
// Then add them to the context menu.
|
||||||
|
@ -817,10 +818,15 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||||
auto handler_icon = af->read_entry("Icons", "16x16", {});
|
auto handler_icon = af->read_entry("Icons", "16x16", {});
|
||||||
|
|
||||||
auto icon = Gfx::Bitmap::load_from_file(handler_icon);
|
auto icon = Gfx::Bitmap::load_from_file(handler_icon);
|
||||||
|
auto action = GUI::Action::create(String::format("Open in %s", handler_name.characters()), move(icon), [this, handler](auto&) {
|
||||||
m_context_menu_for_hyperlink->add_action(GUI::Action::create(String::format("Open in %s", handler_name.characters()), move(icon), [this, handler](auto&) {
|
|
||||||
Desktop::Launcher::open(m_context_menu_href, handler);
|
Desktop::Launcher::open(m_context_menu_href, handler);
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
if (context_menu_default_action.is_null()) {
|
||||||
|
context_menu_default_action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_context_menu_for_hyperlink->add_action(action);
|
||||||
}
|
}
|
||||||
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy URL", [this](auto&) {
|
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy URL", [this](auto&) {
|
||||||
GUI::Clipboard::the().set_data(m_context_menu_href);
|
GUI::Clipboard::the().set_data(m_context_menu_href);
|
||||||
|
@ -829,7 +835,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||||
m_context_menu_for_hyperlink->add_action(copy_action());
|
m_context_menu_for_hyperlink->add_action(copy_action());
|
||||||
m_context_menu_for_hyperlink->add_action(paste_action());
|
m_context_menu_for_hyperlink->add_action(paste_action());
|
||||||
|
|
||||||
m_context_menu_for_hyperlink->popup(event.screen_position());
|
m_context_menu_for_hyperlink->popup(event.screen_position(), context_menu_default_action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue