FileManager: Disable view change actions when directory is unreadable

Closes #3556.
This commit is contained in:
Linus Groh 2021-03-07 16:04:59 +01:00 committed by Andreas Kling
parent 1ccf9de6b9
commit a0362d827c
Notes: sideshowbarker 2024-07-18 21:38:51 +09:00
3 changed files with 8 additions and 5 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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();
};