mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
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.
This commit is contained in:
parent
f0c2ee3c56
commit
826096bac3
Notes:
sideshowbarker
2024-07-19 02:29:08 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/826096bac37 Pull-request: https://github.com/SerenityOS/serenity/pull/4074
1 changed files with 5 additions and 1 deletions
|
@ -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)) \
|
||||
|
|
Loading…
Reference in a new issue