diff options
author | Andres Vieira <anvieiravazquez@gmail.com> | 2020-04-27 19:03:13 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-28 10:00:12 +0200 |
commit | cb118111b66c74a665ede1bce0e9f30feb492acc (patch) | |
tree | ef4064920b36250887bbc538a75951af724df07f /Applications/FileManager | |
parent | 1d874c03af840eee2be12884d3a20c402e75b577 (diff) | |
download | serenity-cb118111b66c74a665ede1bce0e9f30feb492acc.zip |
FileManager: Deny rename in PropertiesDialog if user can't write in path
The FileManager PropertiesDialog always let the user change the name of
files and folders to then be prompted with write permissions error.
Now it checks for write permissions on the containing folder so it can
"disable" the TextBox input. We can't really disable TextBox right now,
hence the quotes.
Diffstat (limited to 'Applications/FileManager')
-rw-r--r-- | Applications/FileManager/main.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 3bd9755e5c..08e16e32ad 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -428,13 +428,16 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio = 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; if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) { path = directory_view.path(); + container_dir_path = path; selected = selected_file_paths(); } else { path = directories_model->full_path(tree_view.selection().first()); + container_dir_path = FileSystemPath(path).basename(); selected = tree_view_selected_file_paths(); } @@ -442,7 +445,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio if (selected.is_empty()) { properties = window->add<PropertiesDialog>(model, path, true); } else { - properties = window->add<PropertiesDialog>(model, selected.first(), false); + properties = window->add<PropertiesDialog>(model, selected.first(), access(container_dir_path.characters(), W_OK) != 0); } properties->exec(); |