mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGUI: Remove Window::try_add_menu()
And fall back to the infallible add_menu().
This commit is contained in:
parent
5300896095
commit
bd61e75e0b
Notes:
sideshowbarker
2024-07-17 20:19:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bd61e75e0b Pull-request: https://github.com/SerenityOS/serenity/pull/20571
51 changed files with 294 additions and 302 deletions
|
@ -372,9 +372,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
time.set_x(widget->width() - time.width() - 6);
|
||||
widget->set_stat_label(time);
|
||||
|
||||
auto& file_menu = window->add_menu("&File"_string);
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
|
||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = { { GUI::FileTypeFilter { "Object Files", { { "obj" } } }, GUI::FileTypeFilter::all_files() } },
|
||||
};
|
||||
|
@ -385,17 +385,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto file = response.release_value();
|
||||
widget->load_file(file.filename(), file.release_stream());
|
||||
}));
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_separator();
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& view_menu = window->add_menu("&View"_string);
|
||||
view_menu.add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
view_menu->add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
}));
|
||||
|
||||
auto rotation_axis_menu = view_menu.add_submenu("Rotation &Axis"_string);
|
||||
auto rotation_axis_menu = view_menu->add_submenu("Rotation &Axis"_string);
|
||||
auto rotation_x_action = GUI::Action::create_checkable("&X", [&widget](auto&) {
|
||||
widget->toggle_rotate_x();
|
||||
});
|
||||
|
@ -413,7 +413,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
rotation_x_action->set_checked(true);
|
||||
rotation_z_action->set_checked(true);
|
||||
|
||||
auto rotation_speed_menu = view_menu.add_submenu("Rotation &Speed"_string);
|
||||
auto rotation_speed_menu = view_menu->add_submenu("Rotation &Speed"_string);
|
||||
GUI::ActionGroup rotation_speed_actions;
|
||||
rotation_speed_actions.set_exclusive(true);
|
||||
|
||||
|
@ -446,17 +446,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
widget->toggle_show_frame_rate();
|
||||
});
|
||||
|
||||
view_menu.add_action(*show_frame_rate_action);
|
||||
view_menu->add_action(*show_frame_rate_action);
|
||||
|
||||
auto& texture_menu = window->add_menu("&Texture"_string);
|
||||
auto texture_menu = window->add_menu("&Texture"_string);
|
||||
|
||||
auto texture_enabled_action = GUI::Action::create_checkable("&Enable Texture", [&widget](auto& action) {
|
||||
widget->set_texture_enabled(action.is_checked());
|
||||
});
|
||||
texture_enabled_action->set_checked(true);
|
||||
texture_menu.add_action(texture_enabled_action);
|
||||
texture_menu->add_action(texture_enabled_action);
|
||||
|
||||
auto wrap_u_menu = texture_menu.add_submenu("Wrap &S"_string);
|
||||
auto wrap_u_menu = texture_menu->add_submenu("Wrap &S"_string);
|
||||
GUI::ActionGroup wrap_s_actions;
|
||||
wrap_s_actions.set_exclusive(true);
|
||||
|
||||
|
@ -480,7 +480,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
wrap_u_repeat_action->set_checked(true);
|
||||
|
||||
auto wrap_t_menu = texture_menu.add_submenu("Wrap &T"_string);
|
||||
auto wrap_t_menu = texture_menu->add_submenu("Wrap &T"_string);
|
||||
GUI::ActionGroup wrap_t_actions;
|
||||
wrap_t_actions.set_exclusive(true);
|
||||
|
||||
|
@ -504,7 +504,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
wrap_t_repeat_action->set_checked(true);
|
||||
|
||||
auto texture_scale_menu = texture_menu.add_submenu("S&cale"_string);
|
||||
auto texture_scale_menu = texture_menu->add_submenu("S&cale"_string);
|
||||
GUI::ActionGroup texture_scale_actions;
|
||||
texture_scale_actions.set_exclusive(true);
|
||||
|
||||
|
@ -542,7 +542,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
texture_scale_1_action->set_checked(true);
|
||||
|
||||
auto texture_mag_filter_menu = texture_menu.add_submenu("Mag Filter"_string);
|
||||
auto texture_mag_filter_menu = texture_menu->add_submenu("Mag Filter"_string);
|
||||
GUI::ActionGroup texture_mag_filter_actions;
|
||||
texture_mag_filter_actions.set_exclusive(true);
|
||||
|
||||
|
@ -562,9 +562,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
texture_mag_filter_nearest_action->set_checked(true);
|
||||
|
||||
auto& help_menu = window->add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("3D File Viewer", app_icon, window));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("3D File Viewer", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
|
|
@ -151,26 +151,26 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
|
|||
|
||||
void BrowserWindow::build_menus()
|
||||
{
|
||||
auto& file_menu = add_menu("&File"_string);
|
||||
file_menu.add_action(WindowActions::the().create_new_tab_action());
|
||||
file_menu.add_action(WindowActions::the().create_new_window_action());
|
||||
auto file_menu = add_menu("&File"_string);
|
||||
file_menu->add_action(WindowActions::the().create_new_tab_action());
|
||||
file_menu->add_action(WindowActions::the().create_new_window_action());
|
||||
|
||||
auto close_tab_action = GUI::CommonActions::make_close_tab_action([this](auto&) {
|
||||
active_tab().on_tab_close_request(active_tab());
|
||||
},
|
||||
this);
|
||||
file_menu.add_action(close_tab_action);
|
||||
file_menu->add_action(close_tab_action);
|
||||
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_separator();
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& view_menu = add_menu("&View"_string);
|
||||
view_menu.add_action(WindowActions::the().show_bookmarks_bar_action());
|
||||
view_menu.add_action(WindowActions::the().vertical_tabs_action());
|
||||
view_menu.add_separator();
|
||||
m_zoom_menu = view_menu.add_submenu("&Zoom"_string);
|
||||
auto view_menu = add_menu("&View"_string);
|
||||
view_menu->add_action(WindowActions::the().show_bookmarks_bar_action());
|
||||
view_menu->add_action(WindowActions::the().vertical_tabs_action());
|
||||
view_menu->add_separator();
|
||||
m_zoom_menu = view_menu->add_submenu("&Zoom"_string);
|
||||
m_zoom_menu->add_action(GUI::CommonActions::make_zoom_in_action(
|
||||
[this](auto&) {
|
||||
auto& tab = active_tab();
|
||||
|
@ -192,8 +192,8 @@ void BrowserWindow::build_menus()
|
|||
update_displayed_zoom_level();
|
||||
},
|
||||
this));
|
||||
view_menu.add_separator();
|
||||
view_menu.add_action(GUI::CommonActions::make_fullscreen_action(
|
||||
view_menu->add_separator();
|
||||
view_menu->add_action(GUI::CommonActions::make_fullscreen_action(
|
||||
[this](auto&) {
|
||||
auto& tab = active_tab();
|
||||
set_fullscreen(!is_fullscreen());
|
||||
|
@ -217,12 +217,12 @@ void BrowserWindow::build_menus()
|
|||
m_reload_action = GUI::CommonActions::make_reload_action([this](auto&) { active_tab().reload(); }, this);
|
||||
m_reload_action->set_status_tip("Reload current page"_string);
|
||||
|
||||
auto& go_menu = add_menu("&Go"_string);
|
||||
go_menu.add_action(*m_go_back_action);
|
||||
go_menu.add_action(*m_go_forward_action);
|
||||
go_menu.add_action(*m_go_home_action);
|
||||
go_menu.add_separator();
|
||||
go_menu.add_action(*m_reload_action);
|
||||
auto go_menu = add_menu("&Go"_string);
|
||||
go_menu->add_action(*m_go_back_action);
|
||||
go_menu->add_action(*m_go_forward_action);
|
||||
go_menu->add_action(*m_go_home_action);
|
||||
go_menu->add_separator();
|
||||
go_menu->add_action(*m_reload_action);
|
||||
|
||||
m_copy_selection_action = GUI::CommonActions::make_copy_action([this](auto&) {
|
||||
auto& tab = active_tab();
|
||||
|
@ -256,9 +256,9 @@ void BrowserWindow::build_menus()
|
|||
this);
|
||||
m_inspect_dom_node_action->set_status_tip("Open inspector for this element"_string);
|
||||
|
||||
auto& inspect_menu = add_menu("&Inspect"_string);
|
||||
inspect_menu.add_action(*m_view_source_action);
|
||||
inspect_menu.add_action(*m_inspect_dom_tree_action);
|
||||
auto inspect_menu = add_menu("&Inspect"_string);
|
||||
inspect_menu->add_action(*m_view_source_action);
|
||||
inspect_menu->add_action(*m_inspect_dom_tree_action);
|
||||
|
||||
auto js_console_action = GUI::Action::create(
|
||||
"Open &JS Console", { Mod_Ctrl, Key_I }, g_icon_bag.filetype_javascript, [this](auto&) {
|
||||
|
@ -266,7 +266,7 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
js_console_action->set_status_tip("Open JavaScript console for this page"_string);
|
||||
inspect_menu.add_action(js_console_action);
|
||||
inspect_menu->add_action(js_console_action);
|
||||
|
||||
auto storage_window_action = GUI::Action::create(
|
||||
"Open S&torage Inspector", g_icon_bag.cookie, [this](auto&) {
|
||||
|
@ -274,7 +274,7 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
storage_window_action->set_status_tip("Show Storage inspector for this page"_string);
|
||||
inspect_menu.add_action(storage_window_action);
|
||||
inspect_menu->add_action(storage_window_action);
|
||||
|
||||
auto history_window_action = GUI::Action::create(
|
||||
"Open &History Window", g_icon_bag.history, [this](auto&) {
|
||||
|
@ -282,9 +282,9 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
storage_window_action->set_status_tip("Show History inspector for this tab"_string);
|
||||
inspect_menu.add_action(history_window_action);
|
||||
inspect_menu->add_action(history_window_action);
|
||||
|
||||
auto& settings_menu = add_menu("&Settings"_string);
|
||||
auto settings_menu = add_menu("&Settings"_string);
|
||||
|
||||
m_change_homepage_action = GUI::Action::create(
|
||||
"Set Homepage URL...", g_icon_bag.go_home, [this](auto&) {
|
||||
|
@ -300,14 +300,14 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
|
||||
settings_menu.add_action(*m_change_homepage_action);
|
||||
settings_menu->add_action(*m_change_homepage_action);
|
||||
|
||||
auto load_search_engines_result = load_search_engines(settings_menu);
|
||||
if (load_search_engines_result.is_error()) {
|
||||
dbgln("Failed to open search-engines file: {}", load_search_engines_result.error());
|
||||
}
|
||||
|
||||
auto color_scheme_menu = settings_menu.add_submenu("&Color Scheme"_string);
|
||||
auto color_scheme_menu = settings_menu->add_submenu("&Color Scheme"_string);
|
||||
color_scheme_menu->set_icon(g_icon_bag.color_chooser);
|
||||
{
|
||||
auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, Browser::default_color_scheme));
|
||||
|
@ -331,74 +331,74 @@ void BrowserWindow::build_menus()
|
|||
add_color_scheme_action("Dark", Web::CSS::PreferredColorScheme::Dark);
|
||||
}
|
||||
|
||||
settings_menu.add_separator();
|
||||
settings_menu->add_separator();
|
||||
auto open_settings_action = GUI::Action::create("Browser &Settings", Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
[this](auto&) {
|
||||
GUI::Process::spawn_or_show_error(this, "/bin/BrowserSettings"sv);
|
||||
});
|
||||
settings_menu.add_action(move(open_settings_action));
|
||||
settings_menu->add_action(move(open_settings_action));
|
||||
|
||||
auto& debug_menu = add_menu("&Debug"_string);
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
auto debug_menu = add_menu("&Debug"_string);
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump &DOM Tree", g_icon_bag.dom_tree, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-dom-tree");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump &Layout Tree", g_icon_bag.layout, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-layout-tree");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump &Paint Tree", g_icon_bag.layout, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-paint-tree");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump S&tacking Context Tree", g_icon_bag.layers, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-stacking-context-tree");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump &Style Sheets", g_icon_bag.filetype_css, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-style-sheets");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create(
|
||||
debug_menu->add_action(GUI::Action::create(
|
||||
"Dump &All Resolved Styles", g_icon_bag.filetype_css, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-all-resolved-styles");
|
||||
},
|
||||
this));
|
||||
debug_menu.add_action(GUI::Action::create("Dump &History", { Mod_Ctrl, Key_H }, g_icon_bag.history, [this](auto&) {
|
||||
debug_menu->add_action(GUI::Action::create("Dump &History", { Mod_Ctrl, Key_H }, g_icon_bag.history, [this](auto&) {
|
||||
active_tab().m_history.dump();
|
||||
}));
|
||||
debug_menu.add_action(GUI::Action::create("Dump C&ookies", g_icon_bag.cookie, [this](auto&) {
|
||||
debug_menu->add_action(GUI::Action::create("Dump C&ookies", g_icon_bag.cookie, [this](auto&) {
|
||||
auto& tab = active_tab();
|
||||
if (tab.on_dump_cookies)
|
||||
tab.on_dump_cookies();
|
||||
}));
|
||||
debug_menu.add_action(GUI::Action::create("Dump Loc&al Storage", g_icon_bag.local_storage, [this](auto&) {
|
||||
debug_menu->add_action(GUI::Action::create("Dump Loc&al Storage", g_icon_bag.local_storage, [this](auto&) {
|
||||
active_tab().view().debug_request("dump-local-storage");
|
||||
}));
|
||||
debug_menu.add_separator();
|
||||
debug_menu->add_separator();
|
||||
auto line_box_borders_action = GUI::Action::create_checkable(
|
||||
"Line &Box Borders", [this](auto& action) {
|
||||
active_tab().view().debug_request("set-line-box-borders", action.is_checked() ? "on" : "off");
|
||||
},
|
||||
this);
|
||||
line_box_borders_action->set_checked(false);
|
||||
debug_menu.add_action(line_box_borders_action);
|
||||
debug_menu->add_action(line_box_borders_action);
|
||||
|
||||
debug_menu.add_separator();
|
||||
debug_menu.add_action(GUI::Action::create("Collect &Garbage", { Mod_Ctrl | Mod_Shift, Key_G }, g_icon_bag.trash_can, [this](auto&) {
|
||||
debug_menu->add_separator();
|
||||
debug_menu->add_action(GUI::Action::create("Collect &Garbage", { Mod_Ctrl | Mod_Shift, Key_G }, g_icon_bag.trash_can, [this](auto&) {
|
||||
active_tab().view().debug_request("collect-garbage");
|
||||
}));
|
||||
debug_menu.add_action(GUI::Action::create("Clear &Cache", { Mod_Ctrl | Mod_Shift, Key_C }, g_icon_bag.clear_cache, [this](auto&) {
|
||||
debug_menu->add_action(GUI::Action::create("Clear &Cache", { Mod_Ctrl | Mod_Shift, Key_C }, g_icon_bag.clear_cache, [this](auto&) {
|
||||
active_tab().view().debug_request("clear-cache");
|
||||
}));
|
||||
|
||||
m_user_agent_spoof_actions.set_exclusive(true);
|
||||
auto spoof_user_agent_menu = debug_menu.add_submenu("Spoof &User Agent"_string);
|
||||
auto spoof_user_agent_menu = debug_menu->add_submenu("Spoof &User Agent"_string);
|
||||
m_disable_user_agent_spoofing = GUI::Action::create_checkable("Disabled", [this](auto&) {
|
||||
active_tab().view().debug_request("spoof-user-agent", Web::default_user_agent);
|
||||
});
|
||||
|
@ -435,14 +435,14 @@ void BrowserWindow::build_menus()
|
|||
spoof_user_agent_menu->add_action(custom_user_agent);
|
||||
m_user_agent_spoof_actions.add_action(custom_user_agent);
|
||||
|
||||
debug_menu.add_separator();
|
||||
debug_menu->add_separator();
|
||||
auto scripting_enabled_action = GUI::Action::create_checkable(
|
||||
"Enable Scripting", [this](auto& action) {
|
||||
active_tab().view().debug_request("scripting", action.is_checked() ? "on" : "off");
|
||||
},
|
||||
this);
|
||||
scripting_enabled_action->set_checked(true);
|
||||
debug_menu.add_action(scripting_enabled_action);
|
||||
debug_menu->add_action(scripting_enabled_action);
|
||||
|
||||
auto block_pop_ups_action = GUI::Action::create_checkable(
|
||||
"Block Pop-ups", [this](auto& action) {
|
||||
|
@ -450,7 +450,7 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
block_pop_ups_action->set_checked(true);
|
||||
debug_menu.add_action(block_pop_ups_action);
|
||||
debug_menu->add_action(block_pop_ups_action);
|
||||
|
||||
auto same_origin_policy_action = GUI::Action::create_checkable(
|
||||
"Enable Same-Origin &Policy", [this](auto& action) {
|
||||
|
@ -458,11 +458,11 @@ void BrowserWindow::build_menus()
|
|||
},
|
||||
this);
|
||||
same_origin_policy_action->set_checked(false);
|
||||
debug_menu.add_action(same_origin_policy_action);
|
||||
debug_menu->add_action(same_origin_policy_action);
|
||||
|
||||
auto& help_menu = add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(this));
|
||||
help_menu.add_action(WindowActions::the().about_action());
|
||||
auto help_menu = add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(this));
|
||||
help_menu->add_action(WindowActions::the().about_action());
|
||||
}
|
||||
|
||||
ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
|
||||
|
|
|
@ -39,16 +39,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
auto& file_menu = window->add_menu("&File"_string);
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& edit_menu = window->add_menu("&Edit"_string);
|
||||
edit_menu.add_action(GUI::CommonActions::make_copy_action([&](auto&) {
|
||||
auto edit_menu = window->add_menu("&Edit"_string);
|
||||
edit_menu->add_action(GUI::CommonActions::make_copy_action([&](auto&) {
|
||||
GUI::Clipboard::the().set_plain_text(widget->get_entry());
|
||||
}));
|
||||
edit_menu.add_action(GUI::CommonActions::make_paste_action([&](auto&) {
|
||||
edit_menu->add_action(GUI::CommonActions::make_paste_action([&](auto&) {
|
||||
auto clipboard = GUI::Clipboard::the().fetch_data_and_type();
|
||||
if (clipboard.mime_type == "text/plain") {
|
||||
if (!clipboard.data.is_empty()) {
|
||||
|
@ -58,20 +58,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
}));
|
||||
|
||||
auto& constants_menu = window->add_menu("&Constants"_string);
|
||||
auto constants_menu = window->add_menu("&Constants"_string);
|
||||
auto const power = Crypto::NumberTheory::Power("10"_bigint, "10"_bigint);
|
||||
|
||||
constants_menu.add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/pi.png"sv)), [&](auto&) {
|
||||
constants_menu->add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/pi.png"sv)), [&](auto&) {
|
||||
widget->set_typed_entry(Crypto::BigFraction { Crypto::SignedBigInteger(31415926535), power });
|
||||
}));
|
||||
constants_menu.add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/eulers_number.png"sv)), [&](auto&) {
|
||||
constants_menu->add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/eulers_number.png"sv)), [&](auto&) {
|
||||
widget->set_typed_entry(Crypto::BigFraction { Crypto::SignedBigInteger(27182818284), power });
|
||||
}));
|
||||
constants_menu.add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/phi.png"sv)), [&](auto&) {
|
||||
constants_menu->add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::load_from_file("/res/icons/calculator/phi.png"sv)), [&](auto&) {
|
||||
widget->set_typed_entry(Crypto::BigFraction { Crypto::SignedBigInteger(16180339887), power });
|
||||
}));
|
||||
|
||||
auto& round_menu = window->add_menu("&Round"_string);
|
||||
auto round_menu = window->add_menu("&Round"_string);
|
||||
GUI::ActionGroup preview_actions;
|
||||
|
||||
static constexpr auto rounding_modes = Array { 0, 2, 4 };
|
||||
|
@ -85,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
});
|
||||
|
||||
preview_actions.add_action(*round_action);
|
||||
round_menu.add_action(*round_action);
|
||||
round_menu->add_action(*round_action);
|
||||
}
|
||||
|
||||
constexpr auto format { "&Custom - {}..."sv };
|
||||
|
@ -97,7 +97,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
widget->set_rounding_length(custom_rounding_length);
|
||||
last_rounding_mode.clear();
|
||||
} else if (last_rounding_mode.has_value())
|
||||
round_menu.action_at(last_rounding_mode.value())
|
||||
round_menu->action_at(last_rounding_mode.value())
|
||||
->activate();
|
||||
});
|
||||
|
||||
|
@ -116,14 +116,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
preview_actions.add_action(*round_custom);
|
||||
preview_actions.set_exclusive(true);
|
||||
round_menu.add_action(*round_custom);
|
||||
round_menu.add_action(*shrink_action);
|
||||
round_menu->add_action(*round_custom);
|
||||
round_menu->add_action(*shrink_action);
|
||||
|
||||
round_menu.action_at(last_rounding_mode.value())->activate();
|
||||
round_menu->action_at(last_rounding_mode.value())->activate();
|
||||
|
||||
auto& help_menu = window->add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Calculator", app_icon, window));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Calculator", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
|
|
@ -83,27 +83,27 @@ ErrorOr<NonnullRefPtr<CalendarWidget>> CalendarWidget::create(GUI::Window* paren
|
|||
auto save_as_action = widget->create_save_as_action();
|
||||
auto save_action = widget->create_save_action(save_as_action);
|
||||
|
||||
auto& file_menu = parent_window->add_menu("&File"_string);
|
||||
file_menu.add_action(open_settings_action);
|
||||
file_menu.add_action(new_calendar_action);
|
||||
file_menu.add_action(open_calendar_action);
|
||||
file_menu.add_action(save_as_action);
|
||||
file_menu.add_action(save_action);
|
||||
auto file_menu = parent_window->add_menu("&File"_string);
|
||||
file_menu->add_action(open_settings_action);
|
||||
file_menu->add_action(new_calendar_action);
|
||||
file_menu->add_action(open_calendar_action);
|
||||
file_menu->add_action(save_as_action);
|
||||
file_menu->add_action(save_action);
|
||||
|
||||
file_menu.add_separator();
|
||||
file_menu->add_separator();
|
||||
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto& event_menu = parent_window->add_menu("&Event"_string);
|
||||
event_menu.add_action(add_event_action);
|
||||
auto event_menu = parent_window->add_menu("&Event"_string);
|
||||
event_menu->add_action(add_event_action);
|
||||
|
||||
auto view_menu = TRY(parent_window->try_add_menu("&View"_string));
|
||||
auto view_menu = parent_window->add_menu("&View"_string);
|
||||
view_menu->add_action(*view_month_action);
|
||||
view_menu->add_action(*view_year_action);
|
||||
|
||||
auto help_menu = TRY(parent_window->try_add_menu("&Help"_string));
|
||||
auto help_menu = parent_window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(parent_window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Calendar", TRY(GUI::Icon::try_create_default_icon("app-calendar"sv)), parent_window));
|
||||
|
||||
|
|
|
@ -159,12 +159,12 @@ CharacterMapWidget::CharacterMapWidget()
|
|||
|
||||
ErrorOr<void> CharacterMapWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](GUI::Action&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([&](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/CharacterMap.md"), "/bin/Help");
|
||||
|
|
|
@ -1009,7 +1009,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
refresh_tree_view();
|
||||
});
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(mkdir_action);
|
||||
file_menu->add_action(touch_action);
|
||||
file_menu->add_action(focus_dependent_delete_action);
|
||||
|
@ -1021,7 +1021,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window->add_menu("&Edit"_string);
|
||||
edit_menu->add_action(cut_action);
|
||||
edit_menu->add_action(copy_action);
|
||||
edit_menu->add_action(paste_action);
|
||||
|
@ -1044,7 +1044,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
show_dotfiles_action->set_checked(show_dotfiles);
|
||||
show_dotfiles_in_view(show_dotfiles);
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
auto layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
layout_menu->add_action(*layout_toolbar_action);
|
||||
layout_menu->add_action(*layout_location_action);
|
||||
|
@ -1065,7 +1065,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
breadcrumbbar.show_location_text_box();
|
||||
});
|
||||
|
||||
auto go_menu = TRY(window->try_add_menu("&Go"_string));
|
||||
auto go_menu = window->add_menu("&Go"_string);
|
||||
go_menu->add_action(go_back_action);
|
||||
go_menu->add_action(go_forward_action);
|
||||
go_menu->add_action(open_parent_directory_action);
|
||||
|
@ -1075,7 +1075,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
|||
go_menu->add_separator();
|
||||
go_menu->add_action(directory_view->open_terminal_action());
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("File Manager"sv, GUI::Icon::default_icon("app-file-manager"sv), window));
|
||||
|
||||
|
|
|
@ -733,7 +733,7 @@ ErrorOr<void> MainWidget::initialize(StringView path, RefPtr<Gfx::BitmapFont>&&
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
@ -755,7 +755,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
|
@ -770,12 +770,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
|
||||
m_context_menu = edit_menu;
|
||||
|
||||
auto go_menu = TRY(window.try_add_menu("&Go"_string));
|
||||
auto go_menu = window.add_menu("&Go"_string);
|
||||
go_menu->add_action(*m_previous_glyph_action);
|
||||
go_menu->add_action(*m_next_glyph_action);
|
||||
go_menu->add_action(*m_go_to_glyph_action);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
auto layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
layout_menu->add_action(*m_show_toolbar_action);
|
||||
layout_menu->add_action(*m_show_statusbar_action);
|
||||
|
@ -793,7 +793,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
scale_menu->add_action(*m_scale_ten_action);
|
||||
scale_menu->add_action(*m_scale_fifteen_action);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/FontEditor.md"), "/bin/Help");
|
||||
|
|
|
@ -204,17 +204,17 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
|||
(void)TRY(m_toolbar->try_add_action(*m_go_forward_action));
|
||||
(void)TRY(m_toolbar->try_add_action(*m_go_home_action));
|
||||
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto go_menu = TRY(window.try_add_menu("&Go"_string));
|
||||
auto go_menu = window.add_menu("&Go"_string);
|
||||
go_menu->add_action(*m_go_back_action);
|
||||
go_menu->add_action(*m_go_forward_action);
|
||||
go_menu->add_action(*m_go_home_action);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
String help_page_path = TRY(TRY(try_make_ref_counted<Manual::PageNode>(Manual::sections[1 - 1], "Applications/Help"_string))->path());
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [this, help_page_path = move(help_page_path)](auto&) {
|
||||
|
|
|
@ -412,7 +412,7 @@ void HexEditorWidget::update_inspector_values(size_t position)
|
|||
|
||||
ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
@ -433,7 +433,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
|
@ -480,7 +480,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
|||
edit_menu->add_separator();
|
||||
edit_menu->add_action(*m_goto_offset_action);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
|
||||
auto show_toolbar = Config::read_bool("HexEditor"sv, "Layout"sv, "ShowToolbar"sv, true);
|
||||
m_layout_toolbar_action->set_checked(show_toolbar);
|
||||
|
@ -541,7 +541,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
|||
little_endian_mode->set_checked(use_little_endian);
|
||||
big_endian_mode->set_checked(!use_little_endian);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/HexEditor.md"), "/bin/Help");
|
||||
|
|
|
@ -306,7 +306,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
(void)TRY(main_toolbar->try_add_action(reset_zoom_action));
|
||||
(void)TRY(main_toolbar->try_add_action(zoom_out_action));
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(open_action);
|
||||
file_menu->add_action(delete_action);
|
||||
file_menu->add_separator();
|
||||
|
@ -323,7 +323,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
file_menu->add_action(quit_action);
|
||||
|
||||
auto image_menu = TRY(window->try_add_menu("&Image"_string));
|
||||
auto image_menu = window->add_menu("&Image"_string);
|
||||
image_menu->add_action(rotate_counterclockwise_action);
|
||||
image_menu->add_action(rotate_clockwise_action);
|
||||
image_menu->add_action(vertical_flip_action);
|
||||
|
@ -331,13 +331,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
image_menu->add_separator();
|
||||
image_menu->add_action(desktop_wallpaper_action);
|
||||
|
||||
auto navigate_menu = TRY(window->try_add_menu("&Navigate"_string));
|
||||
auto navigate_menu = window->add_menu("&Navigate"_string);
|
||||
navigate_menu->add_action(go_first_action);
|
||||
navigate_menu->add_action(go_back_action);
|
||||
navigate_menu->add_action(go_forward_action);
|
||||
navigate_menu->add_action(go_last_action);
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
view_menu->add_action(full_screen_action);
|
||||
view_menu->add_separator();
|
||||
view_menu->add_action(zoom_in_action);
|
||||
|
@ -364,7 +364,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
view_menu->add_separator();
|
||||
view_menu->add_action(hide_show_toolbar_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/ImageViewer.md"), "/bin/Help");
|
||||
|
|
|
@ -83,19 +83,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto_modifier_action->set_checkable(true);
|
||||
auto_modifier_action->set_checked(false);
|
||||
|
||||
auto& file_menu = window->add_menu("&File"_string);
|
||||
file_menu.add_action(open_action);
|
||||
file_menu.add_action(save_action);
|
||||
file_menu.add_action(save_as_action);
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(quit_action);
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(open_action);
|
||||
file_menu->add_action(save_action);
|
||||
file_menu->add_action(save_as_action);
|
||||
file_menu->add_separator();
|
||||
file_menu->add_action(quit_action);
|
||||
|
||||
auto& settings_menu = window->add_menu("&Settings"_string);
|
||||
settings_menu.add_action(auto_modifier_action);
|
||||
auto settings_menu = window->add_menu("&Settings"_string);
|
||||
settings_menu->add_action(auto_modifier_action);
|
||||
|
||||
auto& help_menu = window->add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Keyboard Mapper", app_icon, window));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Keyboard Mapper", app_icon, window));
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (keyboard_mapper_widget->request_close())
|
||||
|
|
|
@ -61,7 +61,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
auto magnifier = TRY(window->set_main_widget<MagnifierWidget>());
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
AK::DeprecatedString filename = "file for saving";
|
||||
auto do_save = [&]() -> ErrorOr<void> {
|
||||
|
@ -142,7 +142,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
size_action_group->add_action(eight_x_action);
|
||||
size_action_group->set_exclusive(true);
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
view_menu->add_action(two_x_action);
|
||||
view_menu->add_action(four_x_action);
|
||||
view_menu->add_action(eight_x_action);
|
||||
|
@ -154,7 +154,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
view_menu->add_action(show_grid_action);
|
||||
view_menu->add_action(choose_grid_color_action);
|
||||
|
||||
auto timeline_menu = TRY(window->try_add_menu("&Timeline"_string));
|
||||
auto timeline_menu = window->add_menu("&Timeline"_string);
|
||||
auto previous_frame_action = GUI::Action::create(
|
||||
"&Previous frame", { Key_Left }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) {
|
||||
pause_action->set_checked(true);
|
||||
|
@ -170,9 +170,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
timeline_menu->add_action(previous_frame_action);
|
||||
timeline_menu->add_action(next_frame_action);
|
||||
|
||||
TRY(window->try_add_menu(GUI::CommonMenus::make_accessibility_menu(magnifier)));
|
||||
window->add_menu(GUI::CommonMenus::make_accessibility_menu(magnifier));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/Magnifier.md"), "/bin/Help");
|
||||
|
|
|
@ -45,16 +45,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Mail");
|
||||
window->resize(640, 400);
|
||||
|
||||
auto& file_menu = window->add_menu("&File"_string);
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
mail_widget->on_window_close();
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& help_menu = window->add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Mail", app_icon, window));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Mail", app_icon, window));
|
||||
|
||||
window->on_close_request = [&] {
|
||||
mail_widget->on_window_close();
|
||||
|
|
|
@ -208,7 +208,7 @@ PDFViewerWidget::PDFViewerWidget()
|
|||
|
||||
ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = Vector {
|
||||
|
@ -230,7 +230,7 @@ ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
view_menu->add_action(*m_toggle_sidebar_action);
|
||||
view_menu->add_separator();
|
||||
auto view_mode_menu = view_menu->add_submenu("View &Mode"_string);
|
||||
|
@ -241,7 +241,7 @@ ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
|||
view_menu->add_action(*m_zoom_out_action);
|
||||
view_menu->add_action(*m_reset_zoom_action);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"sv), &window));
|
||||
return {};
|
||||
|
|
|
@ -80,12 +80,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
partition_table_view.set_model(partition_model);
|
||||
partition_table_view.set_focus(true);
|
||||
|
||||
auto& file_menu = window->add_menu("&File"_string);
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Partition Editor", app_icon, window));
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}));
|
||||
main_widget_updater->start();
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::Action::create("Export...", { Mod_Ctrl, Key_E }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/file-export.png"sv)), [&](const GUI::Action&) {
|
||||
save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav");
|
||||
if (!save_path.has_value())
|
||||
|
@ -83,10 +83,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window->add_menu("&Edit"_string);
|
||||
TRY(main_widget->add_track_actions(edit_menu));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Piano", app_icon, window));
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ static constexpr int s_zoom_level_fit_image = 10;
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
|
||||
m_new_image_action = GUI::Action::create(
|
||||
"&New Image...", { Mod_Ctrl, Key_N }, g_icon_bag.filetype_pixelpaint, [&](auto&) {
|
||||
|
@ -292,7 +292,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
m_edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
m_edit_menu = window.add_menu("&Edit"_string);
|
||||
|
||||
m_cut_action = GUI::CommonActions::make_cut_action([&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
|
@ -488,7 +488,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Writing color palette failed: {}", result.release_error())));
|
||||
}));
|
||||
|
||||
m_view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
m_view_menu = window.add_menu("&View"_string);
|
||||
|
||||
m_zoom_in_action = GUI::CommonActions::make_zoom_in_action(
|
||||
[&](auto&) {
|
||||
|
@ -604,14 +604,14 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
scopes_menu->add_action(histogram_action);
|
||||
scopes_menu->add_action(vectorscope_action);
|
||||
|
||||
m_tool_menu = TRY(window.try_add_menu("&Tool"_string));
|
||||
m_tool_menu = window.add_menu("&Tool"_string);
|
||||
m_toolbox->for_each_tool([&](auto& tool) {
|
||||
if (tool.action())
|
||||
m_tool_menu->add_action(*tool.action());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
m_image_menu = TRY(window.try_add_menu("&Image"_string));
|
||||
m_image_menu = window.add_menu("&Image"_string);
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"Flip Image &Vertically", g_icon_bag.edit_flip_vertical, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
|
@ -713,7 +713,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
editor->did_complete_action("Crop Image to Content"sv);
|
||||
}));
|
||||
|
||||
m_layer_menu = TRY(window.try_add_menu("&Layer"_string));
|
||||
m_layer_menu = window.add_menu("&Layer"_string);
|
||||
|
||||
m_layer_menu->on_visibility_change = [this](bool visible) {
|
||||
if (!visible)
|
||||
|
@ -1140,7 +1140,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
editor->did_complete_action("Crop Layer to Content"sv);
|
||||
}));
|
||||
|
||||
m_filter_menu = TRY(window.try_add_menu("&Filter"_string));
|
||||
m_filter_menu = window.add_menu("&Filter"_string);
|
||||
|
||||
m_filter_menu->add_action(GUI::Action::create("Filter &Gallery", g_icon_bag.filter, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
|
@ -1164,7 +1164,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
}
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"sv), &window));
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
{
|
||||
auto* window = this->window();
|
||||
// Set up the menu bar.
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
auto open_action = GUI::CommonActions::make_open_action([this](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = { { GUI::FileTypeFilter { "Presentation Files", { { "presenter" } } }, GUI::FileTypeFilter::all_files() } },
|
||||
|
@ -71,7 +71,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto presentation_menu = TRY(window->try_add_menu("&Presentation"_string));
|
||||
auto presentation_menu = window->add_menu("&Presentation"_string);
|
||||
m_next_slide_action = GUI::Action::create("&Next", { KeyCode::Key_Right }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv)), [this](auto&) {
|
||||
if (m_current_presentation) {
|
||||
m_current_presentation->next_frame();
|
||||
|
@ -98,7 +98,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
presentation_menu->add_action(*m_previous_slide_action);
|
||||
presentation_menu->add_action(*m_present_from_first_slide_action);
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
m_full_screen_action = GUI::Action::create("Toggle &Full Screen", { KeyModifier::Mod_Shift, KeyCode::Key_F5 }, { KeyCode::Key_F11 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/fullscreen.png"sv)), [this](auto&) {
|
||||
auto* window = this->window();
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
|
@ -117,7 +117,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
|
||||
update_slides_actions();
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Presenter", GUI::Icon::default_icon("app-presenter"sv)));
|
||||
|
||||
return {};
|
||||
|
|
|
@ -92,12 +92,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Settings");
|
||||
window->resize(420, 265);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Settings", app_icon, window));
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
player->set_loop_mode(Player::LoopMode::Playlist);
|
||||
}
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(window);
|
||||
if (path.has_value()) {
|
||||
|
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
app->quit();
|
||||
}));
|
||||
|
||||
auto playback_menu = TRY(window->try_add_menu("&Playback"_string));
|
||||
auto playback_menu = window->add_menu("&Playback"_string);
|
||||
GUI::ActionGroup loop_actions;
|
||||
loop_actions.set_exclusive(true);
|
||||
auto loop_none = GUI::Action::create_checkable("&No Loop", { Mod_Ctrl, Key_N }, [&](auto&) {
|
||||
|
@ -120,7 +120,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
});
|
||||
playback_menu->add_action(shuffle_mode);
|
||||
|
||||
auto visualization_menu = TRY(window->try_add_menu("&Visualization"_string));
|
||||
auto visualization_menu = window->add_menu("&Visualization"_string);
|
||||
GUI::ActionGroup visualization_actions;
|
||||
visualization_actions.set_exclusive(true);
|
||||
|
||||
|
@ -163,7 +163,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
selected_visualization_widget->set_checked(true);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Sound Player", app_icon, window));
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
tree_map_widget.set_focus(true);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::Action::create("&Analyze", { KeyCode::Key_F5 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
// FIXME: Just modify the tree in memory instead of traversing the entire file system
|
||||
if (auto result = tree_map_widget.analyze(statusbar); result.is_error()) {
|
||||
|
@ -79,7 +79,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
app->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window));
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
|
|||
|
||||
ErrorOr<void> SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
@ -737,7 +737,7 @@ ErrorOr<void> SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
|||
});
|
||||
file_menu->add_action(*m_quit_action);
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
|
@ -746,7 +746,7 @@ ErrorOr<void> SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
|||
edit_menu->add_action(*m_paste_action);
|
||||
edit_menu->add_action(*m_insert_emoji_action);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(*m_search_action);
|
||||
help_menu->add_action(*m_functions_help_action);
|
||||
help_menu->add_action(*m_about_action);
|
||||
|
|
|
@ -427,7 +427,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
},
|
||||
&process_table_view);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
@ -446,7 +446,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
process_context_menu->popup(event.screen_position(), process_properties_action);
|
||||
};
|
||||
|
||||
auto frequency_menu = TRY(window->try_add_menu("F&requency"_string));
|
||||
auto frequency_menu = window->add_menu("F&requency"_string);
|
||||
GUI::ActionGroup frequency_action_group;
|
||||
frequency_action_group.set_exclusive(true);
|
||||
|
||||
|
@ -466,7 +466,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(make_frequency_action(3));
|
||||
TRY(make_frequency_action(5));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("System Monitor", app_icon, window));
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
terminal->context_menu().add_separator();
|
||||
terminal->context_menu().add_action(open_settings_action);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"sv)), [&](auto&) {
|
||||
GUI::Process::spawn_or_show_error(window, "/bin/Terminal"sv);
|
||||
}));
|
||||
|
@ -384,7 +384,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window->add_menu("&Edit"_string);
|
||||
edit_menu->add_action(terminal->copy_action());
|
||||
edit_menu->add_action(terminal->paste_action());
|
||||
edit_menu->add_separator();
|
||||
|
@ -394,7 +394,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
find_window->move_to_front();
|
||||
}));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
view_menu->add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
}));
|
||||
|
@ -418,7 +418,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
adjust_font_size(-1);
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/Terminal.md"), "/bin/Help");
|
||||
|
|
|
@ -365,7 +365,7 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view()
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
@ -396,7 +396,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
edit_menu->add_action(m_editor->undo_action());
|
||||
edit_menu->add_action(m_editor->redo_action());
|
||||
edit_menu->add_separator();
|
||||
|
@ -460,7 +460,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
m_layout_ruler_action->set_checked(show_ruler);
|
||||
m_editor->set_ruler_visible(show_ruler);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
auto layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
layout_menu->add_action(*m_layout_toolbar_action);
|
||||
layout_menu->add_action(*m_layout_statusbar_action);
|
||||
|
@ -689,7 +689,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
syntax_actions.add_action(*m_sql_highlight);
|
||||
syntax_menu->add_action(*m_sql_highlight);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/TextEditor.md"), "/bin/Help");
|
||||
|
|
|
@ -245,7 +245,7 @@ MainWidget::MainWidget(NonnullRefPtr<AlignmentModel> alignment_model)
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
|
||||
return;
|
||||
|
@ -305,9 +305,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
TRY(window.try_add_menu(GUI::CommonMenus::make_accessibility_menu(*m_preview_widget)));
|
||||
window.add_menu(GUI::CommonMenus::make_accessibility_menu(*m_preview_widget));
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Theme Editor", GUI::Icon::default_icon("app-theme-editor"sv), &window));
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ void VideoPlayerWidget::set_sizing_mode(VideoSizingMode sizing_mode)
|
|||
ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
// File menu
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = { { GUI::FileTypeFilter { "Video Files", { { "mkv", "webm" } } }, GUI::FileTypeFilter::all_files() } },
|
||||
|
@ -399,7 +399,7 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
|||
}));
|
||||
|
||||
// Playback menu
|
||||
auto playback_menu = TRY(window.try_add_menu("&Playback"_string));
|
||||
auto playback_menu = window.add_menu("&Playback"_string);
|
||||
|
||||
// FIXME: Maybe seek mode should be in an options dialog instead. The playback menu may get crowded.
|
||||
// For now, leave it here for convenience.
|
||||
|
@ -408,7 +408,7 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
|||
set_seek_mode(Video::PlaybackManager::DEFAULT_SEEK_MODE);
|
||||
|
||||
// View menu
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
view_menu->add_action(*m_toggle_fullscreen_action);
|
||||
|
||||
auto sizing_mode_menu = view_menu->add_submenu("&Sizing Mode"_string);
|
||||
|
@ -427,7 +427,7 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
|||
sizing_mode_menu->add_action(*m_size_fullsize_action);
|
||||
|
||||
// Help menu
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Video Player", TRY(GUI::Icon::try_create_default_icon("app-video-player"sv)), &window));
|
||||
|
||||
return {};
|
||||
|
|
|
@ -84,12 +84,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
set_window_frame_enabled(!hide_window_frame);
|
||||
show_window_frame_action->set_checked(window_frame_enabled);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(move(show_window_frame_action));
|
||||
file_menu->add_separator();
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/Eyes.md"), "/bin/Help");
|
||||
|
|
|
@ -197,7 +197,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_resizable(false);
|
||||
window->resize(WIDTH, HEIGHT);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv));
|
||||
|
|
|
@ -116,7 +116,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_resizable(false);
|
||||
window->resize(WIDTH * 2, HEIGHT * 3);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv));
|
||||
|
|
|
@ -413,7 +413,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->resize(window->minimum_size() * 2);
|
||||
auto mandelbrot = TRY(window->set_main_widget<Mandelbrot>());
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
|
||||
auto export_submenu = file_menu->add_submenu("&Export"_string);
|
||||
|
||||
|
@ -469,12 +469,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto app_icon = GUI::Icon::default_icon("app-mandelbrot"sv);
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
view_menu->add_action(zoom_in_action);
|
||||
view_menu->add_action(reset_zoom_action);
|
||||
view_menu->add_action(zoom_out_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Mandelbrot Demo", app_icon, window));
|
||||
|
||||
|
|
|
@ -76,12 +76,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Screensaver");
|
||||
window->resize(360, 240);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Screensaver", app_icon, window));
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ void MainWidget::load_file(FileSystemAccessClient::File file)
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
|
||||
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
LexicalPath initial_path(m_file_path.is_empty() ? "Untitled.gml" : m_file_path);
|
||||
|
@ -206,7 +206,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
edit_menu->add_action(m_editor->undo_action());
|
||||
edit_menu->add_action(m_editor->redo_action());
|
||||
edit_menu->add_separator();
|
||||
|
@ -241,7 +241,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
vim_emulation_setting_action->set_checked(false);
|
||||
edit_menu->add_action(vim_emulation_setting_action);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
m_views_group.set_exclusive(true);
|
||||
m_views_group.set_unchecking_allowed(false);
|
||||
|
||||
|
@ -272,7 +272,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
m_view_frame_action->activate();
|
||||
};
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/GMLPlayground.md"), "/bin/Help");
|
||||
|
|
|
@ -1414,9 +1414,9 @@ void HackStudioWidget::update_recent_projects_submenu()
|
|||
|
||||
ErrorOr<void> HackStudioWidget::create_file_menu(GUI::Window& window)
|
||||
{
|
||||
auto& file_menu = window.add_menu("&File"_string);
|
||||
auto file_menu = window.add_menu("&File"_string);
|
||||
|
||||
auto new_submenu = file_menu.add_submenu("&New..."_string);
|
||||
auto new_submenu = file_menu->add_submenu("&New..."_string);
|
||||
new_submenu->add_action(*m_new_project_action);
|
||||
new_submenu->add_separator();
|
||||
for (auto& new_file_action : m_new_file_actions) {
|
||||
|
@ -1431,17 +1431,17 @@ ErrorOr<void> HackStudioWidget::create_file_menu(GUI::Window& window)
|
|||
new_submenu->add_separator();
|
||||
new_submenu->add_action(*m_new_directory_action);
|
||||
|
||||
file_menu.add_action(*m_open_action);
|
||||
m_recent_projects_submenu = file_menu.add_submenu("Open &Recent"_string);
|
||||
file_menu->add_action(*m_open_action);
|
||||
m_recent_projects_submenu = file_menu->add_submenu("Open &Recent"_string);
|
||||
{
|
||||
auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open-recent.png"sv));
|
||||
m_recent_projects_submenu->set_icon(icon);
|
||||
}
|
||||
update_recent_projects_submenu();
|
||||
file_menu.add_action(*m_save_action);
|
||||
file_menu.add_action(*m_save_as_action);
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
return {};
|
||||
|
@ -1449,14 +1449,14 @@ ErrorOr<void> HackStudioWidget::create_file_menu(GUI::Window& window)
|
|||
|
||||
ErrorOr<void> HackStudioWidget::create_edit_menu(GUI::Window& window)
|
||||
{
|
||||
auto& edit_menu = window.add_menu("&Edit"_string);
|
||||
auto edit_menu = window.add_menu("&Edit"_string);
|
||||
auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv));
|
||||
edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, icon, [this](auto&) {
|
||||
edit_menu->add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, icon, [this](auto&) {
|
||||
reveal_action_tab(*m_find_in_files_widget);
|
||||
m_find_in_files_widget->focus_textbox_and_select_all();
|
||||
}));
|
||||
|
||||
edit_menu.add_separator();
|
||||
edit_menu->add_separator();
|
||||
|
||||
auto vim_emulation_setting_action = GUI::Action::create_checkable("&Vim Emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [this](auto& action) {
|
||||
if (action.is_checked()) {
|
||||
|
@ -1468,22 +1468,22 @@ ErrorOr<void> HackStudioWidget::create_edit_menu(GUI::Window& window)
|
|||
}
|
||||
});
|
||||
vim_emulation_setting_action->set_checked(false);
|
||||
edit_menu.add_action(vim_emulation_setting_action);
|
||||
edit_menu->add_action(vim_emulation_setting_action);
|
||||
|
||||
edit_menu.add_separator();
|
||||
edit_menu.add_action(*m_open_project_configuration_action);
|
||||
edit_menu->add_separator();
|
||||
edit_menu->add_action(*m_open_project_configuration_action);
|
||||
return {};
|
||||
}
|
||||
|
||||
void HackStudioWidget::create_build_menu(GUI::Window& window)
|
||||
{
|
||||
auto& build_menu = window.add_menu("&Build"_string);
|
||||
build_menu.add_action(*m_build_action);
|
||||
build_menu.add_separator();
|
||||
build_menu.add_action(*m_run_action);
|
||||
build_menu.add_action(*m_stop_action);
|
||||
build_menu.add_separator();
|
||||
build_menu.add_action(*m_debug_action);
|
||||
auto build_menu = window.add_menu("&Build"_string);
|
||||
build_menu->add_action(*m_build_action);
|
||||
build_menu->add_separator();
|
||||
build_menu->add_action(*m_run_action);
|
||||
build_menu->add_action(*m_stop_action);
|
||||
build_menu->add_separator();
|
||||
build_menu->add_action(*m_debug_action);
|
||||
}
|
||||
|
||||
ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
|
||||
|
@ -1500,18 +1500,18 @@ ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
});
|
||||
show_dotfiles_action->set_checked(Config::read_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, false));
|
||||
|
||||
auto& view_menu = window.add_menu("&View"_string);
|
||||
view_menu.add_action(hide_action_tabs_action);
|
||||
view_menu.add_action(open_locator_action);
|
||||
view_menu.add_action(show_dotfiles_action);
|
||||
auto view_menu = window.add_menu("&View"_string);
|
||||
view_menu->add_action(hide_action_tabs_action);
|
||||
view_menu->add_action(open_locator_action);
|
||||
view_menu->add_action(show_dotfiles_action);
|
||||
m_toggle_semantic_highlighting_action = TRY(create_toggle_syntax_highlighting_mode_action());
|
||||
view_menu.add_action(*m_toggle_semantic_highlighting_action);
|
||||
view_menu->add_action(*m_toggle_semantic_highlighting_action);
|
||||
m_toggle_view_file_in_single_click_action = TRY(create_toggle_open_file_in_single_click_action());
|
||||
view_menu.add_action(*m_toggle_view_file_in_single_click_action);
|
||||
view_menu.add_separator();
|
||||
view_menu->add_action(*m_toggle_view_file_in_single_click_action);
|
||||
view_menu->add_separator();
|
||||
|
||||
m_wrapping_mode_actions.set_exclusive(true);
|
||||
auto wrapping_mode_menu = view_menu.add_submenu("&Wrapping Mode"_string);
|
||||
auto wrapping_mode_menu = view_menu->add_submenu("&Wrapping Mode"_string);
|
||||
m_no_wrapping_action = GUI::Action::create_checkable("&No Wrapping", [&](auto&) {
|
||||
m_wrapping_mode = GUI::TextEditor::WrappingMode::NoWrap;
|
||||
for (auto& wrapper : m_all_editor_wrappers)
|
||||
|
@ -1556,24 +1556,24 @@ ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
change_editor_font(picker->font());
|
||||
}
|
||||
});
|
||||
view_menu.add_action(*m_editor_font_action);
|
||||
view_menu->add_action(*m_editor_font_action);
|
||||
|
||||
view_menu.add_separator();
|
||||
view_menu.add_action(*m_add_editor_tab_widget_action);
|
||||
view_menu.add_action(*m_add_editor_action);
|
||||
view_menu.add_action(*m_remove_current_editor_action);
|
||||
view_menu.add_action(*m_add_terminal_action);
|
||||
view_menu.add_action(*m_remove_current_terminal_action);
|
||||
view_menu->add_separator();
|
||||
view_menu->add_action(*m_add_editor_tab_widget_action);
|
||||
view_menu->add_action(*m_add_editor_action);
|
||||
view_menu->add_action(*m_remove_current_editor_action);
|
||||
view_menu->add_action(*m_add_terminal_action);
|
||||
view_menu->add_action(*m_remove_current_terminal_action);
|
||||
|
||||
view_menu.add_separator();
|
||||
view_menu->add_separator();
|
||||
|
||||
TRY(create_location_history_actions());
|
||||
view_menu.add_action(*m_locations_history_back_action);
|
||||
view_menu.add_action(*m_locations_history_forward_action);
|
||||
view_menu->add_action(*m_locations_history_back_action);
|
||||
view_menu->add_action(*m_locations_history_forward_action);
|
||||
|
||||
view_menu.add_separator();
|
||||
view_menu->add_separator();
|
||||
|
||||
view_menu.add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
view_menu->add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
window.set_fullscreen(!window.is_fullscreen());
|
||||
}));
|
||||
return {};
|
||||
|
@ -1581,9 +1581,9 @@ ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
|
||||
void HackStudioWidget::create_help_menu(GUI::Window& window)
|
||||
{
|
||||
auto& help_menu = window.add_menu("&Help"_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"sv), &window));
|
||||
auto help_menu = window.add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"sv), &window));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_stop_action()
|
||||
|
|
|
@ -265,10 +265,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
filesystem_events_tree_view->set_selection_behavior(GUI::TreeView::SelectionBehavior::SelectRows);
|
||||
filesystem_events_tree_view->set_model(profile->file_event_model());
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
|
||||
auto invert_action = GUI::Action::create_checkable("&Invert Tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
|
||||
profile->set_inverted(action.is_checked());
|
||||
|
@ -294,7 +294,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
view_menu->add_action(disassembly_action);
|
||||
view_menu->add_action(source_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/Profiler.md"), "/bin/Help");
|
||||
|
|
|
@ -301,7 +301,7 @@ ErrorOr<void> MainWidget::setup()
|
|||
|
||||
ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
|
||||
{
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
auto file_menu = window->add_menu("&File"_string);
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
@ -312,7 +312,7 @@ ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
auto edit_menu = window->add_menu("&Edit"_string);
|
||||
edit_menu->add_action(*m_copy_action);
|
||||
edit_menu->add_action(*m_cut_action);
|
||||
edit_menu->add_action(*m_paste_action);
|
||||
|
@ -322,7 +322,7 @@ ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
|
|||
edit_menu->add_separator();
|
||||
edit_menu->add_action(*m_run_script_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/SQLStudio.md"), "/bin/Help");
|
||||
|
|
|
@ -165,7 +165,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
start_a_new_game();
|
||||
|
@ -197,7 +197,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/2048.md"), "/bin/Help");
|
||||
|
|
|
@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto game = TRY(window->set_main_widget<BrickGame>(app_name));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game->reset();
|
||||
|
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help");
|
||||
|
|
|
@ -89,7 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
widget->set_show_available_moves(Config::read_bool("Games"sv, "Chess"sv, "ShowAvailableMoves"sv, true));
|
||||
widget->set_highlight_checks(Config::read_bool("Games"sv, "Chess"sv, "HighlightChecks"sv, true));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&Resign", { Mod_None, Key_F3 }, [&](auto&) {
|
||||
widget->resign();
|
||||
|
@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto engine_menu = TRY(window->try_add_menu("&Engine"_string));
|
||||
auto engine_menu = window->add_menu("&Engine"_string);
|
||||
|
||||
GUI::ActionGroup engines_action_group;
|
||||
engines_action_group.set_exclusive(true);
|
||||
|
@ -193,7 +193,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
engine_submenu->add_action(*action);
|
||||
}
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/Chess.md"), "/bin/Help");
|
||||
|
|
|
@ -50,7 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto game = TRY(window->set_main_widget<ColorLines>(app_name));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game->reset();
|
||||
|
@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help");
|
||||
|
|
|
@ -55,12 +55,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return high_score;
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/FlappyBug.md"), "/bin/Help");
|
||||
|
|
|
@ -164,7 +164,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
start_a_new_game();
|
||||
|
@ -180,7 +180,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/Flood.md"), "/bin/Help");
|
||||
|
|
|
@ -132,7 +132,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
rotate_pattern_action->set_enabled(false);
|
||||
(void)TRY(main_toolbar.try_add_action(rotate_pattern_action));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(clear_board_action);
|
||||
game_menu->add_action(randomize_cells_action);
|
||||
|
@ -144,7 +144,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/GameOfLife.md"), "/bin/Help");
|
||||
|
|
|
@ -85,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::MessageBox::show(settings_dialog, "Settings have been successfully saved and will take effect in the next game."sv, "Settings Changed Successfully"sv, GUI::MessageBox::Type::Information);
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game.setup(player_name);
|
||||
|
@ -98,7 +98,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
game_menu->add_separator();
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/Hearts.md"), "/bin/Help");
|
||||
|
|
|
@ -66,7 +66,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
window->set_focused_widget(&game);
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game.reset();
|
||||
|
@ -77,7 +77,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto settings_menu = TRY(window->try_add_menu("&Settings"_string));
|
||||
auto settings_menu = window->add_menu("&Settings"_string);
|
||||
|
||||
settings_menu->add_action(GUI::Action::create("Set &Word Length...", [&](auto&) {
|
||||
auto word_length = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5);
|
||||
|
@ -104,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
toggle_check_guesses->set_checked(game.is_checking_guesses());
|
||||
settings_menu->add_action(toggle_check_guesses);
|
||||
|
||||
auto theme_menu = TRY(window->try_add_menu("&Theme"_string));
|
||||
auto theme_menu = window->add_menu("&Theme"_string);
|
||||
auto system_theme_action = GUI::Action::create("&System", [&](auto&) {
|
||||
game.set_use_system_theme(true);
|
||||
Config::write_bool("MasterWord"sv, ""sv, "use_system_theme"sv, true);
|
||||
|
@ -127,7 +127,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
theme_actions.add_action(system_theme_action);
|
||||
theme_actions.add_action(wordle_theme_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/MasterWord.md"), "/bin/Help");
|
||||
|
|
|
@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto field = TRY(Field::create(flag_label, time_label, face_button));
|
||||
TRY(widget->try_add_child(field));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
field->reset();
|
||||
|
@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto difficulty_menu = TRY(window->try_add_menu("&Difficulty"_string));
|
||||
auto difficulty_menu = window->add_menu("&Difficulty"_string);
|
||||
GUI::ActionGroup difficulty_actions;
|
||||
difficulty_actions.set_exclusive(true);
|
||||
|
||||
|
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/Minesweeper.md"), "/bin/Help");
|
||||
|
|
|
@ -83,7 +83,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return true;
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game.reset();
|
||||
|
@ -151,7 +151,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man6/Snake.md"), "/bin/Help");
|
||||
|
|
|
@ -197,7 +197,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
toggle_auto_collect_action->set_checked(game.is_auto_collecting());
|
||||
toggle_auto_collect_action->set_status_tip("Auto-collect to foundation piles"_string);
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (!confirm_end_current_game())
|
||||
|
@ -220,7 +220,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
game_menu->add_separator();
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window));
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
two_suit_action->set_checked(mode == Spider::Mode::TwoSuit);
|
||||
suit_actions.add_action(two_suit_action);
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (!confirm_end_current_game())
|
||||
return;
|
||||
|
@ -255,7 +255,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
game_menu->add_separator();
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto view_menu = window->add_menu("&View"_string);
|
||||
|
||||
GUI::ActionGroup statistic_display_actions;
|
||||
statistic_display_actions.set_exclusive(true);
|
||||
|
@ -277,7 +277,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
view_menu->add_action(high_score_action);
|
||||
view_menu->add_action(best_time_actions);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
auto help_menu = window->add_menu("&Help"_string);
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Spider", app_icon, window));
|
||||
|
||||
|
|
|
@ -1318,17 +1318,16 @@ Gfx::Bitmap* Window::back_bitmap()
|
|||
return m_back_store ? &m_back_store->bitmap() : nullptr;
|
||||
}
|
||||
|
||||
ErrorOr<void> Window::try_add_menu(NonnullRefPtr<Menu> menu)
|
||||
void Window::add_menu(NonnullRefPtr<Menu> menu)
|
||||
{
|
||||
m_menubar->add_menu({}, move(menu));
|
||||
if (m_window_id) {
|
||||
menu->realize_menu_if_needed();
|
||||
ConnectionToWindowServer::the().async_add_menu(m_window_id, menu->menu_id());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
|
||||
NonnullRefPtr<Menu> Window::add_menu(String name)
|
||||
{
|
||||
auto menu = m_menubar->add_menu({}, move(name));
|
||||
if (m_window_id) {
|
||||
|
@ -1338,12 +1337,6 @@ ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
|
|||
return menu;
|
||||
}
|
||||
|
||||
Menu& Window::add_menu(String name)
|
||||
{
|
||||
auto menu = MUST(try_add_menu(move(name)));
|
||||
return *menu;
|
||||
}
|
||||
|
||||
void Window::flash_menubar_menu_for(MenuItem const& menu_item)
|
||||
{
|
||||
if (!Desktop::the().system_effects().flash_menus())
|
||||
|
|
|
@ -219,9 +219,8 @@ public:
|
|||
|
||||
void did_disable_focused_widget(Badge<Widget>);
|
||||
|
||||
Menu& add_menu(String name);
|
||||
ErrorOr<NonnullRefPtr<Menu>> try_add_menu(String name);
|
||||
ErrorOr<void> try_add_menu(NonnullRefPtr<Menu> menu);
|
||||
[[nodiscard]] NonnullRefPtr<Menu> add_menu(String name);
|
||||
void add_menu(NonnullRefPtr<Menu> menu);
|
||||
void flash_menubar_menu_for(MenuItem const&);
|
||||
|
||||
void flush_pending_paints_immediately();
|
||||
|
|
Loading…
Reference in a new issue