mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibVT: Handle non file urls in on hover tooltips
Previously we would simply compute the basename of the hovered url's path and display it as the resource that will be opened. This patch adds a fallback for non file urls to simply show the full url, making http urls show up properly.
This commit is contained in:
parent
4abb4317aa
commit
b29fbe96dd
1 changed files with 15 additions and 6 deletions
|
@ -831,13 +831,22 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
|
||||||
|
|
||||||
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 url = URL(attribute.href);
|
||||||
auto name = LexicalPath::basename(path);
|
auto path = url.path();
|
||||||
if (path == handlers[0]) {
|
|
||||||
set_tooltip(String::formatted("Execute {}", name));
|
auto app_file = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
|
||||||
|
auto app_name = app_file->is_valid() ? app_file->name() : LexicalPath::basename(handlers[0]);
|
||||||
|
|
||||||
|
if (url.scheme() == "file") {
|
||||||
|
auto file_name = LexicalPath::basename(path);
|
||||||
|
|
||||||
|
if (path == handlers[0]) {
|
||||||
|
set_tooltip(String::formatted("Execute {}", app_name));
|
||||||
|
} else {
|
||||||
|
set_tooltip(String::formatted("Open {} with {}", file_name, app_name));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auto af = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
|
set_tooltip(String::formatted("Open {} with {}", attribute.href, app_name));
|
||||||
set_tooltip(String::formatted("Open {} with {}", name, af->is_valid() ? af->name() : LexicalPath::basename(handlers[0])));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue