diff options
author | Linus Groh <mail@linusgroh.de> | 2020-11-13 00:34:09 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-14 10:11:26 +0100 |
commit | 826096bac37a240157fb75188749648d4825489d (patch) | |
tree | d51633ddfcecea06d4da06c80a0d8931c4289ea8 | |
parent | f0c2ee3c567afa00e66c1a448bf7b792b49c4bd2 (diff) | |
download | serenity-826096bac37a240157fb75188749648d4825489d.zip |
LibGUI: Make FileIconProvider aware of all supported image formats
By using Gfx::Bitmap::is_path_a_supported_image_format() we can
automatically provide the image icon for all supported image formats,
without keeping a second list of image file extensions.
-rw-r--r-- | Libraries/LibGUI/FileIconProvider.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Libraries/LibGUI/FileIconProvider.cpp b/Libraries/LibGUI/FileIconProvider.cpp index 8b4c0c6695..b836923eb8 100644 --- a/Libraries/LibGUI/FileIconProvider.cpp +++ b/Libraries/LibGUI/FileIconProvider.cpp @@ -39,7 +39,6 @@ namespace GUI { F(hackstudio, ".hsp") \ F(header, ".h", ".hpp", ".hxx", ".hh", ".h++") \ F(html, ".html", ".htm") \ - F(image, ".png") \ F(java, ".java") \ F(javascript, ".js", ".mjs") \ F(library, ".so", ".a") \ @@ -68,6 +67,7 @@ static Icon s_file_icon; static Icon s_symlink_icon; static Icon s_socket_icon; static Icon s_executable_icon; +static Icon s_filetype_image_icon; static void initialize_if_needed() { @@ -84,6 +84,7 @@ static void initialize_if_needed() s_symlink_icon = Icon::default_icon("filetype-symlink"); s_socket_icon = Icon::default_icon("filetype-socket"); s_executable_icon = Icon::default_icon("filetype-executable"); + s_filetype_image_icon = Icon::default_icon("filetype-image"); #define __ENUMERATE_FILETYPE(filetype_name, ...) \ s_filetype_##filetype_name##_icon = Icon::default_icon("filetype-" #filetype_name); @@ -150,6 +151,9 @@ Icon FileIconProvider::icon_for_path(const String& path, mode_t mode) if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) return s_executable_icon; + if (Gfx::Bitmap::is_path_a_supported_image_format(path.view())) + return s_filetype_image_icon; + #define __ENUMERATE_FILETYPE(filetype_name, filetype_extensions...) \ for (auto& extension : { filetype_extensions }) { \ if (path.ends_with(extension, CaseSensitivity::CaseInsensitive)) \ |