summaryrefslogtreecommitdiff
path: root/Libraries/LibVT
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-29 00:10:43 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-30 09:47:49 +0200
commite59c415ae34d428a9bbe95830656c8af6d93edf2 (patch)
tree5ecaf97cf20a338d3ef405addac7bd5b10390527 /Libraries/LibVT
parentf36c67c960b6e00f93a116a08da3cf79595639d5 (diff)
downloadserenity-e59c415ae34d428a9bbe95830656c8af6d93edf2.zip
LibVT+Terminal: Mark default action in context menu
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index 71aaa0b57f..115459a9a8 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -806,6 +806,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
}
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.
// 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 icon = Gfx::Bitmap::load_from_file(handler_icon);
-
- m_context_menu_for_hyperlink->add_action(GUI::Action::create(String::format("Open in %s", handler_name.characters()), move(icon), [this, handler](auto&) {
+ auto 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);
- }));
+ });
+
+ 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&) {
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(paste_action());
- m_context_menu_for_hyperlink->popup(event.screen_position());
+ m_context_menu_for_hyperlink->popup(event.screen_position(), context_menu_default_action);
}
}