LibVT: Show action of double click in tooltip

When hovering an item in Terminal we now show what application will
handle it, e.g "Open app-catdog.png in ImageViewer".

If the file is its own handler, i.e an executable, it will show
"Execute myscript.sh"
This commit is contained in:
David Lindbom 2021-11-12 22:53:39 +01:00 committed by Andreas Kling
parent f6ab63993a
commit 3c98a9430b
Notes: sideshowbarker 2024-07-18 01:10:45 +09:00

View file

@ -822,7 +822,18 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
if (attribute.href_id != m_hovered_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 = attribute.href;
auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href);
if (!handlers.is_empty()) {
auto path = URL(attribute.href).path();
auto name = LexicalPath::basename(path);
if (path == handlers[0]) {
m_hovered_href = String::formatted("Execute {}", name);
} else {
m_hovered_href = String::formatted("Open {} with {}", name, LexicalPath::basename(handlers[0]));
}
} else {
m_hovered_href = attribute.href;
}
} else {
m_hovered_href_id = {};
m_hovered_href = {};