diff options
author | Linus Groh <mail@linusgroh.de> | 2021-03-07 16:04:59 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-07 16:19:36 +0100 |
commit | a0362d827cd5c1bbda5c19335063d9d9bd6adb8e (patch) | |
tree | 2bdf7ef1056bb1bcf73adf352428e8fd8ee7a549 /Userland/Applications | |
parent | 1ccf9de6b9c10013dea663bc6315b8b819bcb478 (diff) | |
download | serenity-a0362d827cd5c1bbda5c19335063d9d9bd6adb8e.zip |
FileManager: Disable view change actions when directory is unreadable
Closes #3556.
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.cpp | 4 | ||||
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.h | 2 | ||||
-rw-r--r-- | Userland/Applications/FileManager/main.cpp | 7 |
3 files changed, 8 insertions, 5 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index ceb27dce10..d5972146d8 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -169,7 +169,7 @@ void DirectoryView::setup_model() add_path_to_history(model().root_path()); if (on_path_change) - on_path_change(failed_path, false); + on_path_change(failed_path, false, false); }; m_model->on_complete = [this] { @@ -186,7 +186,7 @@ void DirectoryView::setup_model() m_touch_action->set_enabled(can_write_in_path); if (on_path_change) - on_path_change(model().root_path(), can_write_in_path); + on_path_change(model().root_path(), true, can_write_in_path); }; m_model->register_client(*this); diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h index 1ac3b7417b..7c71191fe7 100644 --- a/Userland/Applications/FileManager/DirectoryView.h +++ b/Userland/Applications/FileManager/DirectoryView.h @@ -81,7 +81,7 @@ public: void launch(const URL&, const LauncherHandler&) const; - Function<void(const StringView& path, bool can_write_in_path)> on_path_change; + Function<void(const StringView& path, bool can_read_in_path, bool can_write_in_path)> on_path_change; Function<void(GUI::AbstractView&)> on_selection_change; Function<void(const GUI::ModelIndex&, const GUI::ContextMenuEvent&)> on_context_menu_request; Function<void(const StringView&)> on_status_message; diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 47d8f93074..2e46600856 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -835,7 +835,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio main_toolbar.add_action(*view_as_table_action); main_toolbar.add_action(*view_as_columns_action); - directory_view.on_path_change = [&](const String& new_path, bool can_write_in_path) { + directory_view.on_path_change = [&](const String& new_path, bool can_read_in_path, bool can_write_in_path) { auto icon = GUI::FileIconProvider::icon_for_path(new_path); auto* bitmap = icon.bitmap_for_size(16); window->set_icon(bitmap); @@ -897,9 +897,12 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio go_forward_action->set_enabled(directory_view.path_history_position() < directory_view.path_history_size() - 1); go_back_action->set_enabled(directory_view.path_history_position() > 0); open_parent_directory_action->set_enabled(new_path != "/"); + view_as_table_action->set_enabled(can_read_in_path); + view_as_icons_action->set_enabled(can_read_in_path); + view_as_columns_action->set_enabled(can_read_in_path); }; - directory_view.on_accepted_drop = [&]() { + directory_view.on_accepted_drop = [&] { refresh_tree_view(); }; |