diff options
author | Jannis Weis <31143295+weisJ@users.noreply.github.com> | 2022-08-21 21:32:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-22 12:48:11 +0200 |
commit | 8b395ffcc5186ac53301a68048fbf05c9729cf05 (patch) | |
tree | 13345f0939d05db23701be3ece194b1f3519a567 /Userland/Applications/FileManager | |
parent | a00fa793b37550a8b44122192346eeeb1d692bf9 (diff) | |
download | serenity-8b395ffcc5186ac53301a68048fbf05c9729cf05.zip |
FileManager: Respond to all selection changes in the Breadcrumbbar
Use Breadcrumbbars on_segment_change instead of on_segment_click.
This allows us to remove the manual handler invokation in the
open_child_directory_action
Diffstat (limited to 'Userland/Applications/FileManager')
-rw-r--r-- | Userland/Applications/FileManager/main.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 6d85735f7a..da95128187 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -672,8 +672,6 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& if (!segment_index.has_value() || *segment_index >= breadcrumbbar.segment_count() - 1) return; breadcrumbbar.set_selected_segment(*segment_index + 1); - if (breadcrumbbar.on_segment_click) - breadcrumbbar.on_segment_click(*segment_index + 1); }); RefPtr<GUI::Action> layout_toolbar_action; @@ -1073,6 +1071,20 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& (void)TRY(main_toolbar.try_add_action(directory_view->view_as_table_action())); (void)TRY(main_toolbar.try_add_action(directory_view->view_as_columns_action())); + breadcrumbbar.on_segment_change = [&](auto segment_index) { + if (!segment_index.has_value()) + return; + auto selected_path = breadcrumbbar.segment_data(*segment_index); + if (Core::File::is_directory(selected_path)) { + directory_view->open(selected_path); + } else { + dbgln("Breadcrumb path '{}' doesn't exist", selected_path); + breadcrumbbar.remove_end_segments(*segment_index); + auto existing_path_segment = breadcrumbbar.find_segment_with_data(directory_view->path()); + breadcrumbbar.set_selected_segment(existing_path_segment.value()); + } + }; + directory_view->on_path_change = [&](String const& 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); @@ -1112,18 +1124,6 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& } breadcrumbbar.set_selected_segment(breadcrumbbar.segment_count() - 1); - - breadcrumbbar.on_segment_click = [&](size_t segment_index) { - auto selected_path = breadcrumbbar.segment_data(segment_index); - if (Core::File::is_directory(selected_path)) { - directory_view->open(selected_path); - } else { - dbgln("Breadcrumb path '{}' doesn't exist", selected_path); - breadcrumbbar.remove_end_segments(segment_index); - auto existing_path_segment = breadcrumbbar.find_segment_with_data(directory_view->path()); - breadcrumbbar.set_selected_segment(existing_path_segment.value()); - } - }; } } |