From d89cad7c571184a75a99e0be154f702f6e3510b9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Sep 2020 21:05:49 +0200 Subject: [PATCH] LibGUI: Use FileIconProvider in the FilePicker dialog --- Libraries/LibGUI/FileIconProvider.cpp | 6 +++++- Libraries/LibGUI/FilePicker.cpp | 9 ++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Libraries/LibGUI/FileIconProvider.cpp b/Libraries/LibGUI/FileIconProvider.cpp index c9cc9dd29b4..7698b3222cd 100644 --- a/Libraries/LibGUI/FileIconProvider.cpp +++ b/Libraries/LibGUI/FileIconProvider.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include @@ -133,8 +134,11 @@ Icon FileIconProvider::icon_for_path(const String& path, mode_t mode) initialize_if_needed(); if (path == "/") return s_hard_disk_icon; - if (S_ISDIR(mode)) + if (S_ISDIR(mode)) { + if (path == Core::StandardPaths::home_directory()) + return s_home_directory_icon; return s_directory_icon; + } if (S_ISLNK(mode)) return s_symlink_icon; if (S_ISSOCK(mode)) diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp index 3c3a03132c5..31fcecdb42d 100644 --- a/Libraries/LibGUI/FilePicker.cpp +++ b/Libraries/LibGUI/FilePicker.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -341,11 +342,9 @@ bool FilePicker::file_exists(const StringView& path) void FilePicker::set_path(const String& path) { - if (path == Core::StandardPaths::home_directory()) - m_location_textbox->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/home-directory.png")); - else - m_location_textbox->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png")); - m_model->set_root_path(path); + auto new_path = LexicalPath(path).string(); + m_location_textbox->set_icon(FileIconProvider::icon_for_path(new_path).bitmap_for_size(16)); + m_model->set_root_path(new_path); } }