LibGUI+Base: Add a hard-disk icon and use it for the path "/"
This commit is contained in:
parent
17ae1c37bb
commit
31b65145b6
Notes:
sideshowbarker
2024-07-19 02:22:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/31b65145b66
3 changed files with 7 additions and 0 deletions
BIN
Base/res/icons/16x16/hard-disk.png
Normal file
BIN
Base/res/icons/16x16/hard-disk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 192 B |
|
@ -57,6 +57,7 @@ namespace GUI {
|
|||
ENUMERATE_FILETYPES(__ENUMERATE_FILETYPE)
|
||||
#undef __ENUMERATE_FILETYPE
|
||||
|
||||
static Icon s_hard_disk_icon;
|
||||
static Icon s_directory_icon;
|
||||
static Icon s_directory_open_icon;
|
||||
static Icon s_home_directory_icon;
|
||||
|
@ -71,6 +72,7 @@ static void initialize_if_needed()
|
|||
static bool s_initialized = false;
|
||||
if (s_initialized)
|
||||
return;
|
||||
s_hard_disk_icon = Icon::default_icon("hard-disk");
|
||||
s_directory_icon = Icon::default_icon("filetype-folder");
|
||||
s_directory_open_icon = Icon::default_icon("filetype-folder-open");
|
||||
s_home_directory_icon = Icon::default_icon("home-directory");
|
||||
|
@ -129,6 +131,8 @@ Icon FileIconProvider::icon_for_path(const String& path)
|
|||
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))
|
||||
return s_directory_icon;
|
||||
if (S_ISLNK(mode))
|
||||
|
|
|
@ -463,6 +463,9 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
|
|||
|
||||
Icon FileSystemModel::icon_for(const Node& node) const
|
||||
{
|
||||
if (node.full_path() == "/")
|
||||
return FileIconProvider::icon_for_path("/");
|
||||
|
||||
if (Gfx::Bitmap::is_path_a_supported_image_format(node.name.to_lowercase())) {
|
||||
if (!node.thumbnail) {
|
||||
if (!const_cast<FileSystemModel*>(this)->fetch_thumbnail_for(node))
|
||||
|
|
Loading…
Add table
Reference in a new issue