From aae296ef08a8c03f82ec5a9baaa89633525221b6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 12 Aug 2020 19:29:02 +0200 Subject: [PATCH] FileManager: Use FileIconProvider in the properties dialog This removes the need for the properties dialog to access the internal data model used by the directory view. --- Applications/FileManager/PropertiesDialog.cpp | 8 ++++---- Applications/FileManager/PropertiesDialog.h | 9 ++++----- Applications/FileManager/main.cpp | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index f4aa7f9f04..c972316e51 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -39,9 +40,8 @@ #include #include -PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, bool disable_rename, Window* parent_window) +PropertiesDialog::PropertiesDialog(const String& path, bool disable_rename, Window* parent_window) : Dialog(parent_window) - , m_model(model) { auto lexical_path = LexicalPath(path); ASSERT(lexical_path.is_valid()); @@ -170,7 +170,7 @@ PropertiesDialog::~PropertiesDialog() { } void PropertiesDialog::update() { - auto bitmap = m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32); + auto bitmap = GUI::FileIconProvider::icon_for_path(m_name, m_mode).bitmap_for_size(32); m_icon->set_bitmap(bitmap); set_title(String::format("%s - Properties", m_name.characters())); } @@ -187,7 +187,7 @@ void PropertiesDialog::permission_changed(mode_t mask, bool set) m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty); } -String PropertiesDialog::make_full_path(String name) +String PropertiesDialog::make_full_path(const String& name) { return String::format("%s/%s", m_parent_path.characters(), name.characters()); } diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h index 424dba58a8..0aefc1447f 100644 --- a/Applications/FileManager/PropertiesDialog.h +++ b/Applications/FileManager/PropertiesDialog.h @@ -40,7 +40,7 @@ public: virtual ~PropertiesDialog() override; private: - PropertiesDialog(GUI::FileSystemModel&, String, bool disable_rename, Window* parent = nullptr); + PropertiesDialog(const String& path, bool disable_rename, Window* parent = nullptr); struct PropertyValuePair { String property; @@ -82,17 +82,16 @@ private: void permission_changed(mode_t mask, bool set); bool apply_changes(); void update(); - String make_full_path(String name); + String make_full_path(const String& name); - GUI::FileSystemModel& m_model; RefPtr m_apply_button; RefPtr m_name_box; RefPtr m_icon; String m_name; String m_parent_path; String m_path; - mode_t m_mode; - mode_t m_old_mode; + mode_t m_mode { 0 }; + mode_t m_old_mode { 0 }; bool m_permissions_dirty { false }; bool m_name_dirty { false }; }; diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 6920647040..0138c6be9a 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -480,7 +480,6 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio auto properties_action = GUI::Action::create( "Properties...", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) { - auto& model = directory_view.model(); String container_dir_path; String path; Vector selected; @@ -496,9 +495,9 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio RefPtr properties; if (selected.is_empty()) { - properties = window->add(model, path, true); + properties = window->add(path, true); } else { - properties = window->add(model, selected.first(), access(container_dir_path.characters(), W_OK) != 0); + properties = window->add(selected.first(), access(container_dir_path.characters(), W_OK) != 0); } properties->exec();