mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
SpaceAnalyzer: Consolidate the node context menus
Instead of having two separate context menus and popping up either the "file" or "directory" one depending on the selected node, we now have a single context menu and update it (before popping it up) to show the context-appropriate actions. This is achieved by simply updating the visibility of the actions. This takes care of one TODO! :^)
This commit is contained in:
parent
49f5767789
commit
a3a5d2b27d
1 changed files with 11 additions and 11 deletions
|
@ -391,15 +391,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
|
||||
}
|
||||
});
|
||||
// TODO: Both these menus could've been implemented as one, but it's impossible to change action text after it's shown once.
|
||||
auto folder_node_context_menu = GUI::Menu::construct();
|
||||
folder_node_context_menu->add_action(*open_folder_action);
|
||||
folder_node_context_menu->add_action(*copy_path_action);
|
||||
folder_node_context_menu->add_action(*delete_action);
|
||||
auto file_node_context_menu = GUI::Menu::construct();
|
||||
file_node_context_menu->add_action(*open_containing_folder_action);
|
||||
file_node_context_menu->add_action(*copy_path_action);
|
||||
file_node_context_menu->add_action(*delete_action);
|
||||
|
||||
auto context_menu = GUI::Menu::construct();
|
||||
context_menu->add_action(*open_folder_action);
|
||||
context_menu->add_action(*open_containing_folder_action);
|
||||
context_menu->add_action(*copy_path_action);
|
||||
context_menu->add_action(*delete_action);
|
||||
|
||||
// Configure event handlers.
|
||||
breadcrumbbar.on_segment_click = [&](size_t index) {
|
||||
|
@ -438,10 +435,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
delete_action->set_enabled(is_removable(selected_node_path));
|
||||
if (Core::File::is_directory(selected_node_path)) {
|
||||
folder_node_context_menu->popup(event.screen_position());
|
||||
open_folder_action->set_visible(true);
|
||||
open_containing_folder_action->set_visible(false);
|
||||
} else {
|
||||
file_node_context_menu->popup(event.screen_position());
|
||||
open_folder_action->set_visible(false);
|
||||
open_containing_folder_action->set_visible(true);
|
||||
}
|
||||
context_menu->popup(event.screen_position());
|
||||
};
|
||||
|
||||
// At startup automatically do an analysis of root.
|
||||
|
|
Loading…
Add table
Reference in a new issue