Userland: Construct Menus with name using the non-deprecated String

This commit is contained in:
Karol Kosek 2023-04-15 17:18:45 +02:00 committed by Andreas Kling
parent c4c1df7621
commit 956f4d9205
Notes: sideshowbarker 2024-07-17 18:38:54 +09:00
9 changed files with 15 additions and 21 deletions

View File

@ -261,7 +261,7 @@ void BookmarksBarWidget::update_content_size()
} else {
// hide all items > m_last_visible_index and create new bookmarks menu for them
m_additional->set_visible(true);
m_additional_menu = GUI::Menu::construct("Additional Bookmarks");
m_additional_menu = GUI::Menu::construct("Additional Bookmarks"_string.release_value_but_fixme_should_propagate_errors());
m_additional->set_menu(m_additional_menu);
for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) {
auto& bookmark = m_bookmarks.at(i);

View File

@ -476,7 +476,7 @@ ErrorOr<int> run_in_desktop_mode()
paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0);
};
auto desktop_view_context_menu = TRY(GUI::Menu::try_create("Directory View"));
auto desktop_view_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View"_string)));
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [&](auto&) {
auto paths = directory_view->selected_file_paths();
@ -518,7 +518,7 @@ ErrorOr<int> run_in_desktop_mode()
TRY(desktop_view_context_menu->try_add_separator());
TRY(desktop_view_context_menu->try_add_action(display_properties_action));
auto desktop_context_menu = TRY(GUI::Menu::try_create("Directory View Directory"));
auto desktop_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View Directory"_string)));
TRY(desktop_context_menu->try_add_action(file_manager_action));
TRY(desktop_context_menu->try_add_action(open_terminal_action));
@ -541,7 +541,7 @@ ErrorOr<int> run_in_desktop_mode()
if (node.is_directory()) {
desktop_context_menu->popup(event.screen_position(), file_manager_action);
} else {
file_context_menu = GUI::Menu::construct("Directory View File");
file_context_menu = GUI::Menu::construct("Directory View File"_string.release_value_but_fixme_should_propagate_errors());
bool added_open_menu_items = add_launch_handler_actions_to_menu(file_context_menu, directory_view, node.full_path(), file_context_menu_action_default_action, current_file_handlers);
if (added_open_menu_items)
@ -690,9 +690,9 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
directory_view->refresh();
};
auto directory_context_menu = TRY(GUI::Menu::try_create("Directory View Directory"));
auto directory_view_context_menu = TRY(GUI::Menu::try_create("Directory View"));
auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create("Tree View Directory"));
auto directory_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View Directory"_string)));
auto directory_view_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View"_string)));
auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create(TRY("Tree View Directory"_string)));
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"sv)), [&](GUI::Action const&) {
directory_view->open_parent_directory();
@ -1210,7 +1210,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
folder_specific_paste_action->set_enabled(should_get_enabled);
directory_context_menu->popup(event.screen_position(), directory_open_action);
} else {
file_context_menu = GUI::Menu::construct("Directory View File");
file_context_menu = GUI::Menu::construct("Directory View File"_string.release_value_but_fixme_should_propagate_errors());
bool added_launch_file_handlers = add_launch_handler_actions_to_menu(file_context_menu, directory_view, node.full_path(), file_context_menu_action_default_action, current_file_handlers);
if (added_launch_file_handlers)

View File

@ -495,7 +495,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> HackStudioWidget::create_project_tree_view_con
m_tree_view_rename_action = GUI::CommonActions::make_rename_action([this](GUI::Action const&) {
m_project_tree_view->begin_editing(m_project_tree_view->cursor_index());
});
auto project_tree_view_context_menu = GUI::Menu::construct("Project Files");
auto project_tree_view_context_menu = GUI::Menu::construct(TRY("Project Files"_string));
auto& new_file_submenu = project_tree_view_context_menu->add_submenu("N&ew...");
for (auto& new_file_action : m_new_file_actions) {

View File

@ -128,7 +128,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
remote_process.set_inspected_object(remote_object->address);
};
auto properties_tree_view_context_menu = TRY(GUI::Menu::try_create("Properties Tree View"));
auto properties_tree_view_context_menu = TRY(GUI::Menu::try_create(TRY("Properties Tree View"_string)));
auto copy_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors();
auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) {

View File

@ -59,7 +59,7 @@ ErrorOr<NonnullRefPtr<Menu>> make_accessibility_menu(ColorFilterer& filterer)
group->add_action(*achromatomaly_accessibility_action);
(void)group.leak_ptr();
auto menu = TRY(Menu::try_create("&Accessibility"));
auto menu = TRY(Menu::try_create(TRY("&Accessibility"_string)));
menu->add_action(default_accessibility_action);
menu->add_action(pratanopia_accessibility_action);
menu->add_action(pratanomaly_accessibility_action);

View File

@ -38,11 +38,6 @@ Menu::Menu(String name)
{
}
Menu::Menu(DeprecatedString name)
: m_name(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors())
{
}
Menu::~Menu()
{
unrealize_menu();
@ -119,7 +114,7 @@ ErrorOr<NonnullRefPtr<Menu>> Menu::try_add_submenu(DeprecatedString name)
// NOTE: We grow the vector first, to get allocation failure handled immediately.
TRY(m_items.try_ensure_capacity(m_items.size() + 1));
auto submenu = TRY(Menu::try_create(name));
auto submenu = TRY(Menu::try_create(TRY(String::from_deprecated_string(name))));
auto item = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MenuItem(m_menu_id, submenu)));
submenu->set_parent(*this, m_items.size());

View File

@ -70,7 +70,6 @@ private:
friend class Menubar;
explicit Menu(String name = {});
explicit Menu(DeprecatedString name);
int realize_menu(RefPtr<Action> default_action = nullptr);
void unrealize_menu();

View File

@ -18,14 +18,14 @@ ErrorOr<void> Menubar::try_add_menu(Badge<Window>, NonnullRefPtr<Menu> menu)
ErrorOr<NonnullRefPtr<Menu>> Menubar::try_add_menu(Badge<Window>, DeprecatedString name)
{
auto menu = TRY(try_add<Menu>(move(name)));
auto menu = TRY(try_add<Menu>(TRY(String::from_deprecated_string(name))));
TRY(m_menus.try_append(menu));
return menu;
}
Menu& Menubar::add_menu(Badge<Window>, DeprecatedString name)
{
auto& menu = add<Menu>(move(name));
auto& menu = add<Menu>(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors());
m_menus.append(menu);
return menu;
}

View File

@ -117,7 +117,7 @@ ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
{
Vector<DeprecatedString> const sorted_app_categories = TRY(discover_apps_and_categories());
auto system_menu = TRY(GUI::Menu::try_create("\xE2\x9A\xA1")); // HIGH VOLTAGE SIGN
auto system_menu = TRY(GUI::Menu::try_create("\xE2\x9A\xA1"_short_string)); // HIGH VOLTAGE SIGN
system_menu->add_action(GUI::Action::create("&About SerenityOS", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladyball.png"sv)), [&](auto&) {
GUI::Process::spawn_or_show_error(&window, "/bin/About"sv);