summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/FileSystemModel.cpp
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2020-07-10 09:51:15 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-10 19:44:18 +0200
commitdeceb91c489279921cc97f1bcfd88bde520a53ba (patch)
treec4d7d4180aeda10375f725457b8e8e629552010a /Libraries/LibGUI/FileSystemModel.cpp
parente6ddc7e0226b7432c3360f1e11dd605fecdb4bab (diff)
downloadserenity-deceb91c489279921cc97f1bcfd88bde520a53ba.zip
FileManager: Show an open folder icon for the selected directory
The currently selected directory now displays an open folder icon in the directory tree.
Diffstat (limited to 'Libraries/LibGUI/FileSystemModel.cpp')
-rw-r--r--Libraries/LibGUI/FileSystemModel.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp
index 0d9fad32a0..88ea294cb8 100644
--- a/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Libraries/LibGUI/FileSystemModel.cpp
@@ -204,6 +204,7 @@ FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode)
, m_mode(mode)
{
m_directory_icon = Icon::default_icon("filetype-folder");
+ m_directory_open_icon = Icon::default_icon("filetype-folder-open");
m_file_icon = Icon::default_icon("filetype-unknown");
m_symlink_icon = Icon::default_icon("filetype-symlink");
m_socket_icon = Icon::default_icon("filetype-socket");
@@ -284,6 +285,19 @@ static String permission_string(mode_t mode)
return builder.to_string();
}
+void FileSystemModel::Node::set_selected(bool selected)
+{
+ if (m_selected == selected)
+ return;
+ m_selected = selected;
+}
+
+void FileSystemModel::update_node_on_selection(const ModelIndex& index, const bool selected)
+{
+ Node& node = const_cast<Node&>(this->node(index));
+ node.set_selected(selected);
+}
+
void FileSystemModel::set_root_path(const StringView& root_path)
{
m_root_path = LexicalPath::canonicalized_path(root_path);
@@ -470,6 +484,11 @@ Icon FileSystemModel::icon_for(const Node& node) const
return GUI::Icon(m_filetype_image_icon.bitmap_for_size(16), *node.thumbnail);
}
+ if (node.is_directory()) {
+ if (node.is_selected())
+ return m_directory_open_icon;
+ }
+
return icon_for_file(node.mode, node.name);
}