From f5cf41eb5dabba687100271aeb559eda45aaadb5 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Mon, 6 Feb 2023 15:42:13 +0000 Subject: [PATCH] LibGUI+FileManager: Move `has_{parent,child}_segment` logic into BCB --- Userland/Applications/FileManager/main.cpp | 4 ++-- Userland/Libraries/LibGUI/Breadcrumbbar.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 0fcabe2b8f..4f3b96a657 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -1155,8 +1155,8 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr paste_action->set_enabled(can_write_in_path && GUI::Clipboard::the().fetch_mime_type() == "text/uri-list"); 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 != "/"); - open_child_directory_action->set_enabled(breadcrumbbar.selected_segment().has_value() && *breadcrumbbar.selected_segment() < breadcrumbbar.segment_count() - 1); + open_parent_directory_action->set_enabled(breadcrumbbar.has_parent_segment()); + open_child_directory_action->set_enabled(breadcrumbbar.has_child_segment()); directory_view->view_as_table_action().set_enabled(can_read_in_path); directory_view->view_as_icons_action().set_enabled(can_read_in_path); directory_view->view_as_columns_action().set_enabled(can_read_in_path); diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.h b/Userland/Libraries/LibGUI/Breadcrumbbar.h index 1d1cefe9df..96e11bd84e 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.h +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.h @@ -29,6 +29,9 @@ public: void set_selected_segment(Optional index); Optional selected_segment() const { return m_selected_segment; } + bool has_parent_segment() const { return m_selected_segment.has_value() && m_selected_segment.value() > 0; } + bool has_child_segment() const { return m_selected_segment.has_value() && m_selected_segment.value() < m_segments.size() - 1; } + Function index)> on_segment_change; Function on_segment_click; Function on_segment_drop;