mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
FileManager: Do not allow rename files that cannot be modified
Pressing the F2 key on files that the user doesn't have permission was opening the file name for editing. This patch fixes the issue disabling the file name editing when the user doesn't have permission to do it. To reproduce the issue: 1) Open the File Manager 2) Click on the /etc directory 3) Select any file 4) Press the F2 key 5) Update the file name
This commit is contained in:
parent
0a1b34c753
commit
9aa0cf3265
Notes:
sideshowbarker
2024-07-17 21:23:02 +09:00
Author: https://github.com/leonicolas 🔰 Commit: https://github.com/SerenityOS/serenity/commit/9aa0cf32651 Pull-request: https://github.com/SerenityOS/serenity/pull/11633 Reviewed-by: https://github.com/ADKaster
2 changed files with 9 additions and 3 deletions
|
@ -519,14 +519,18 @@ void DirectoryView::do_delete(bool should_confirm)
|
|||
delete_paths(paths, should_confirm, window());
|
||||
}
|
||||
|
||||
bool DirectoryView::can_modify_current_selection()
|
||||
{
|
||||
return !current_view().selection().is_empty() && access(path().characters(), W_OK) == 0;
|
||||
}
|
||||
|
||||
void DirectoryView::handle_selection_change()
|
||||
{
|
||||
update_statusbar();
|
||||
|
||||
bool can_modify = !current_view().selection().is_empty() && access(path().characters(), W_OK) == 0;
|
||||
bool can_modify = can_modify_current_selection();
|
||||
m_delete_action->set_enabled(can_modify);
|
||||
m_force_delete_action->set_enabled(can_modify);
|
||||
m_rename_action->set_enabled(can_modify);
|
||||
|
||||
if (on_selection_change)
|
||||
on_selection_change(current_view());
|
||||
|
@ -578,7 +582,8 @@ void DirectoryView::setup_actions()
|
|||
|
||||
m_delete_action = GUI::CommonActions::make_delete_action([this](auto&) { do_delete(true); }, window());
|
||||
m_rename_action = GUI::CommonActions::make_rename_action([this](auto&) {
|
||||
current_view().begin_editing(current_view().cursor_index());
|
||||
if (can_modify_current_selection())
|
||||
current_view().begin_editing(current_view().cursor_index());
|
||||
},
|
||||
window());
|
||||
|
||||
|
|
|
@ -158,6 +158,7 @@ private:
|
|||
|
||||
void set_status_message(StringView);
|
||||
void update_statusbar();
|
||||
bool can_modify_current_selection();
|
||||
|
||||
Mode m_mode { Mode::Normal };
|
||||
ViewMode m_view_mode { Invalid };
|
||||
|
|
Loading…
Reference in a new issue