From cb118111b66c74a665ede1bce0e9f30feb492acc Mon Sep 17 00:00:00 2001 From: Andres Vieira Date: Mon, 27 Apr 2020 19:03:13 +0200 Subject: 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. --- Applications/FileManager/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Applications/FileManager') 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 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 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 config, String initial_locatio if (selected.is_empty()) { properties = window->add(model, path, true); } else { - properties = window->add(model, selected.first(), false); + properties = window->add(model, selected.first(), access(container_dir_path.characters(), W_OK) != 0); } properties->exec(); -- cgit v1.2.3