summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-12 19:29:02 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-12 20:41:13 +0200
commitaae296ef08a8c03f82ec5a9baaa89633525221b6 (patch)
treed0e50d56466f7799aca21c10cdd70099024cc214
parent3dd15da7b16a8b6d1e10d85e74d16cdc4ffca14c (diff)
downloadserenity-aae296ef08a8c03f82ec5a9baaa89633525221b6.zip
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.
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp8
-rw-r--r--Applications/FileManager/PropertiesDialog.h9
-rw-r--r--Applications/FileManager/main.cpp5
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 <AK/StringBuilder.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/CheckBox.h>
+#include <LibGUI/FileIconProvider.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/TabWidget.h>
@@ -39,9 +40,8 @@
#include <string.h>
#include <unistd.h>
-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<GUI::Button> m_apply_button;
RefPtr<GUI::TextBox> m_name_box;
RefPtr<GUI::ImageWidget> 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<Core::ConfigFile> 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<String> selected;
@@ -496,9 +495,9 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
RefPtr<PropertiesDialog> properties;
if (selected.is_empty()) {
- properties = window->add<PropertiesDialog>(model, path, true);
+ properties = window->add<PropertiesDialog>(path, true);
} else {
- properties = window->add<PropertiesDialog>(model, selected.first(), access(container_dir_path.characters(), W_OK) != 0);
+ properties = window->add<PropertiesDialog>(selected.first(), access(container_dir_path.characters(), W_OK) != 0);
}
properties->exec();