mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 19:35:06 +00:00
LibGUI: Use FileIconProvider in the FilePicker dialog
This commit is contained in:
parent
e1e58d5bc9
commit
d89cad7c57
2 changed files with 9 additions and 6 deletions
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGUI/FileIconProvider.h>
|
#include <LibGUI/FileIconProvider.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
|
@ -133,8 +134,11 @@ Icon FileIconProvider::icon_for_path(const String& path, mode_t mode)
|
||||||
initialize_if_needed();
|
initialize_if_needed();
|
||||||
if (path == "/")
|
if (path == "/")
|
||||||
return s_hard_disk_icon;
|
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;
|
return s_directory_icon;
|
||||||
|
}
|
||||||
if (S_ISLNK(mode))
|
if (S_ISLNK(mode))
|
||||||
return s_symlink_icon;
|
return s_symlink_icon;
|
||||||
if (S_ISSOCK(mode))
|
if (S_ISSOCK(mode))
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
|
#include <LibGUI/FileIconProvider.h>
|
||||||
#include <LibGUI/FilePicker.h>
|
#include <LibGUI/FilePicker.h>
|
||||||
#include <LibGUI/FileSystemModel.h>
|
#include <LibGUI/FileSystemModel.h>
|
||||||
#include <LibGUI/InputBox.h>
|
#include <LibGUI/InputBox.h>
|
||||||
|
@ -341,11 +342,9 @@ bool FilePicker::file_exists(const StringView& path)
|
||||||
|
|
||||||
void FilePicker::set_path(const String& path)
|
void FilePicker::set_path(const String& path)
|
||||||
{
|
{
|
||||||
if (path == Core::StandardPaths::home_directory())
|
auto new_path = LexicalPath(path).string();
|
||||||
m_location_textbox->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/home-directory.png"));
|
m_location_textbox->set_icon(FileIconProvider::icon_for_path(new_path).bitmap_for_size(16));
|
||||||
else
|
m_model->set_root_path(new_path);
|
||||||
m_location_textbox->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
|
|
||||||
m_model->set_root_path(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue