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.
This commit is contained in:
Lucas CHOLLET 2023-12-28 19:26:34 -05:00 committed by Andrew Kaster
parent 383be5e49c
commit cb669675f1
2 changed files with 31 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include <LibGUI/CheckBox.h>
#include <LibGUI/FileIconProvider.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/GroupBox.h>
#include <LibGUI/IconView.h>
#include <LibGUI/LinkLabel.h>
#include <LibGUI/MessageBox.h>
@ -453,6 +454,25 @@ ErrorOr<void> 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<GUI::GroupBox>("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<GUI::Widget>();
widget.set_layout<GUI::HorizontalBoxLayout>();
auto& key_label = widget.add<GUI::Label>(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<GUI::Label>(field.value);
value_label.set_text_alignment(Gfx::TextAlignment::TopLeft);
}
}
return {};
}

View file

@ -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
}
}
}