From cb669675f14bb832507bd3cb97f7f44a31c38e4b Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Thu, 28 Dec 2023 19:26:34 -0500 Subject: [PATCH] FileManager: Start displaying basic metadata for images Let's add a new group in the Image tab of the properties window. The goal is to provide generic metadata, only a few tags are displayed here. --- .../FileManager/PropertiesWindow.cpp | 20 +++++++++++++++++++ .../FileManager/PropertiesWindowImageTab.gml | 11 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 6b2678ac68..74ba4d9283 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -453,6 +454,25 @@ ErrorOr PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non hide_icc_group("None"_string); } + auto const& basic_metadata = image_decoder->metadata(); + if (basic_metadata.has_value() && !basic_metadata->main_tags().is_empty()) { + auto& metadata_group = *tab.find_descendant_of_type_named("image_basic_metadata"); + metadata_group.set_visible(true); + + auto const& tags = basic_metadata->main_tags(); + for (auto const& field : tags) { + auto& widget = metadata_group.add(); + widget.set_layout(); + + auto& key_label = widget.add(String::from_utf8(field.key).release_value_but_fixme_should_propagate_errors()); + key_label.set_text_alignment(Gfx::TextAlignment::TopLeft); + key_label.set_fixed_width(80); + + auto& value_label = widget.add(field.value); + value_label.set_text_alignment(Gfx::TextAlignment::TopLeft); + } + } + return {}; } diff --git a/Userland/Applications/FileManager/PropertiesWindowImageTab.gml b/Userland/Applications/FileManager/PropertiesWindowImageTab.gml index 61f2e993ac..b0f0cbe1d9 100644 --- a/Userland/Applications/FileManager/PropertiesWindowImageTab.gml +++ b/Userland/Applications/FileManager/PropertiesWindowImageTab.gml @@ -169,4 +169,15 @@ } } } + + @GUI::GroupBox { + name: "image_basic_metadata" + title: "Basic Metadata" + preferred_height: "shrink" + visible: false + layout: @GUI::VerticalBoxLayout { + margins: [12, 8, 0] + spacing: 2 + } + } }