Skip to content

Commit

Permalink
LibGUI: Use FileIconProvider in the FilePicker dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Sep 16, 2020
1 parent e1e58d5 commit d89cad7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Libraries/LibGUI/FileIconProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include <AK/String.h>
#include <LibCore/StandardPaths.h>
#include <LibGUI/FileIconProvider.h>
#include <LibGUI/Icon.h>
#include <LibGfx/Bitmap.h>
Expand Down Expand Up @@ -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))
Expand Down
9 changes: 4 additions & 5 deletions Libraries/LibGUI/FilePicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <LibGUI/Action.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/FileIconProvider.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/FileSystemModel.h>
#include <LibGUI/InputBox.h>
Expand Down Expand Up @@ -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);
}

}

0 comments on commit d89cad7

Please sign in to comment.