Преглед на файлове

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.
Lucas CHOLLET преди 1 година
родител
ревизия
cb669675f1
променени са 2 файла, в които са добавени 31 реда и са изтрити 0 реда
  1. 20 0
      Userland/Applications/FileManager/PropertiesWindow.cpp
  2. 11 0
      Userland/Applications/FileManager/PropertiesWindowImageTab.gml

+ 20 - 0
Userland/Applications/FileManager/PropertiesWindow.cpp

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

+ 11 - 0
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
+        }
+    }
 }