diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index 1ec8aaf8cf5..e48d935736c 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -27,10 +27,12 @@ #include "PropertiesDialog.h" #include #include +#include #include #include #include #include +#include #include #include #include @@ -116,14 +118,18 @@ PropertiesDialog::PropertiesDialog(const String& path, bool disable_rename, Wind auto properties = Vector(); properties.append({ "Type:", get_description(m_mode) }); - properties.append({ "Location:", path }); + auto parent_link = URL::create_with_file_protocol(m_parent_path); + properties.append(PropertyValuePair { "Location:", path, Optional(parent_link) }); if (S_ISLNK(m_mode)) { auto link_destination = Core::File::read_link(path); if (link_destination.is_null()) { perror("readlink"); } else { - properties.append({ "Link target:", link_destination }); + auto link_directory = LexicalPath(link_destination); + ASSERT(link_directory.is_valid()); + auto link_parent = URL::create_with_file_protocol(link_directory.dirname()); + properties.append({ "Link target:", link_destination, Optional(link_parent) }); } } @@ -279,7 +285,15 @@ void PropertiesDialog::make_property_value_pairs(const Vector label_property.set_text_alignment(Gfx::TextAlignment::CenterLeft); label_property.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); - label_container.add(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft); + if (!pair.link.has_value()) { + label_container.add(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft); + } else { + auto& link = label_container.add(pair.value); + link.set_text_alignment(Gfx::TextAlignment::CenterLeft); + link.on_click = [pair]() { + Desktop::Launcher::open(pair.link.value()); + }; + } max_width = max(max_width, label_property.font().width(pair.property)); property_labels.append(label_property); diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h index 0aefc1447f1..5c9b6072353 100644 --- a/Applications/FileManager/PropertiesDialog.h +++ b/Applications/FileManager/PropertiesDialog.h @@ -45,6 +45,7 @@ private: struct PropertyValuePair { String property; String value; + Optional link = {}; }; struct PermissionMasks {