1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

LibVT: Properly populate context menu with open actions

We would previously overwrite m_hovered_href with tooltip texts instead
of leaving it as an url as was expected by the context menu event
handler.
This commit is contained in:
networkException 2022-02-17 11:26:04 +01:00 committed by Andreas Kling
parent 17f5eb558c
commit 3052c0578c

View file

@ -827,23 +827,21 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
if (attribute.href_id != m_hovered_href_id) { if (attribute.href_id != m_hovered_href_id) {
if (m_active_href_id.is_null() || m_active_href_id == attribute.href_id) { if (m_active_href_id.is_null() || m_active_href_id == attribute.href_id) {
m_hovered_href_id = attribute.href_id; m_hovered_href_id = attribute.href_id;
m_hovered_href = attribute.href;
auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href); auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href);
if (!handlers.is_empty()) { if (!handlers.is_empty()) {
auto path = URL(attribute.href).path(); auto path = URL(attribute.href).path();
auto name = LexicalPath::basename(path); auto name = LexicalPath::basename(path);
if (path == handlers[0]) { if (path == handlers[0])
m_hovered_href = String::formatted("Execute {}", name); set_tooltip(String::formatted("Execute {}", name));
} else { else
m_hovered_href = String::formatted("Open {} with {}", name, LexicalPath::basename(handlers[0])); set_tooltip(String::formatted("Open {} with {}", name, LexicalPath::basename(handlers[0])));
}
} else {
m_hovered_href = attribute.href;
} }
} else { } else {
m_hovered_href_id = {}; m_hovered_href_id = {};
m_hovered_href = {}; m_hovered_href = {};
} }
set_tooltip(m_hovered_href);
show_or_hide_tooltip(); show_or_hide_tooltip();
if (!m_hovered_href.is_empty()) if (!m_hovered_href.is_empty())
set_override_cursor(Gfx::StandardCursor::Arrow); set_override_cursor(Gfx::StandardCursor::Arrow);