mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibGUI: Remove Menu::try_add_action()
And fall back to the infallible add_action().
This commit is contained in:
parent
eec328e2ab
commit
f2faf2767f
Notes:
sideshowbarker
2024-07-16 19:17:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f2faf2767f Pull-request: https://github.com/SerenityOS/serenity/pull/20571
@ -85,10 +85,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
|
||||
auto entry_context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(entry_context_menu->try_add_action(delete_action));
|
||||
TRY(entry_context_menu->try_add_action(debug_dump_action));
|
||||
entry_context_menu->add_action(delete_action);
|
||||
entry_context_menu->add_action(debug_dump_action);
|
||||
entry_context_menu->add_separator();
|
||||
TRY(entry_context_menu->try_add_action(clear_action));
|
||||
entry_context_menu->add_action(clear_action);
|
||||
table_view->on_context_menu_request = [&](GUI::ModelIndex const&, GUI::ContextMenuEvent const& event) {
|
||||
delete_action->set_enabled(!table_view->selection().is_empty());
|
||||
debug_dump_action->set_enabled(!table_view->selection().is_empty());
|
||||
|
@ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
show_window_frame_action->set_checked(clock->show_window_frame());
|
||||
auto menu = TRY(GUI::Menu::try_create());
|
||||
TRY(menu->try_add_action(*show_window_frame_action));
|
||||
menu->add_action(*show_window_frame_action);
|
||||
|
||||
clock->on_context_menu_request = [&](auto& event) {
|
||||
menu->popup(event.screen_position());
|
||||
|
@ -92,20 +92,20 @@ ErrorOr<NonnullRefPtr<CalendarWidget>> CalendarWidget::create(GUI::Window* paren
|
||||
|
||||
file_menu.add_separator();
|
||||
|
||||
TRY(file_menu.try_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 view_menu = TRY(parent_window->try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(*view_month_action));
|
||||
TRY(view_menu->try_add_action(*view_year_action));
|
||||
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));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(parent_window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Calendar", TRY(GUI::Icon::try_create_default_icon("app-calendar"sv)), parent_window)));
|
||||
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));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
@ -160,16 +160,16 @@ CharacterMapWidget::CharacterMapWidget()
|
||||
ErrorOr<void> CharacterMapWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](GUI::Action&) {
|
||||
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));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -509,27 +509,27 @@ ErrorOr<int> run_in_desktop_mode()
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/bin/DisplaySettings"));
|
||||
});
|
||||
|
||||
TRY(desktop_view_context_menu->try_add_action(directory_view->mkdir_action()));
|
||||
TRY(desktop_view_context_menu->try_add_action(directory_view->touch_action()));
|
||||
TRY(desktop_view_context_menu->try_add_action(paste_action));
|
||||
desktop_view_context_menu->add_action(directory_view->mkdir_action());
|
||||
desktop_view_context_menu->add_action(directory_view->touch_action());
|
||||
desktop_view_context_menu->add_action(paste_action);
|
||||
desktop_view_context_menu->add_separator();
|
||||
TRY(desktop_view_context_menu->try_add_action(file_manager_action));
|
||||
TRY(desktop_view_context_menu->try_add_action(open_terminal_action));
|
||||
desktop_view_context_menu->add_action(file_manager_action);
|
||||
desktop_view_context_menu->add_action(open_terminal_action);
|
||||
desktop_view_context_menu->add_separator();
|
||||
TRY(desktop_view_context_menu->try_add_action(display_properties_action));
|
||||
desktop_view_context_menu->add_action(display_properties_action);
|
||||
|
||||
auto desktop_context_menu = TRY(GUI::Menu::try_create("Directory View Directory"_string));
|
||||
|
||||
TRY(desktop_context_menu->try_add_action(file_manager_action));
|
||||
TRY(desktop_context_menu->try_add_action(open_terminal_action));
|
||||
desktop_context_menu->add_action(file_manager_action);
|
||||
desktop_context_menu->add_action(open_terminal_action);
|
||||
desktop_context_menu->add_separator();
|
||||
TRY(desktop_context_menu->try_add_action(cut_action));
|
||||
TRY(desktop_context_menu->try_add_action(copy_action));
|
||||
TRY(desktop_context_menu->try_add_action(paste_action));
|
||||
TRY(desktop_context_menu->try_add_action(directory_view->delete_action()));
|
||||
TRY(desktop_context_menu->try_add_action(directory_view->rename_action()));
|
||||
desktop_context_menu->add_action(cut_action);
|
||||
desktop_context_menu->add_action(copy_action);
|
||||
desktop_context_menu->add_action(paste_action);
|
||||
desktop_context_menu->add_action(directory_view->delete_action());
|
||||
desktop_context_menu->add_action(directory_view->rename_action());
|
||||
desktop_context_menu->add_separator();
|
||||
TRY(desktop_context_menu->try_add_action(properties_action));
|
||||
desktop_context_menu->add_action(properties_action);
|
||||
|
||||
RefPtr<GUI::Menu> file_context_menu;
|
||||
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
|
||||
@ -1010,23 +1010,23 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
||||
});
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(mkdir_action));
|
||||
TRY(file_menu->try_add_action(touch_action));
|
||||
TRY(file_menu->try_add_action(focus_dependent_delete_action));
|
||||
TRY(file_menu->try_add_action(directory_view->rename_action()));
|
||||
file_menu->add_action(mkdir_action);
|
||||
file_menu->add_action(touch_action);
|
||||
file_menu->add_action(focus_dependent_delete_action);
|
||||
file_menu->add_action(directory_view->rename_action());
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(properties_action));
|
||||
file_menu->add_action(properties_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(cut_action));
|
||||
TRY(edit_menu->try_add_action(copy_action));
|
||||
TRY(edit_menu->try_add_action(paste_action));
|
||||
edit_menu->add_action(cut_action);
|
||||
edit_menu->add_action(copy_action);
|
||||
edit_menu->add_action(paste_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(select_all_action));
|
||||
edit_menu->add_action(select_all_action);
|
||||
|
||||
auto show_dotfiles_in_view = [&](bool show_dotfiles) {
|
||||
directory_view->set_should_show_dotfiles(show_dotfiles);
|
||||
@ -1046,18 +1046,18 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
auto layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
TRY(layout_menu->try_add_action(*layout_toolbar_action));
|
||||
TRY(layout_menu->try_add_action(*layout_location_action));
|
||||
TRY(layout_menu->try_add_action(*layout_statusbar_action));
|
||||
TRY(layout_menu->try_add_action(*layout_folderpane_action));
|
||||
layout_menu->add_action(*layout_toolbar_action);
|
||||
layout_menu->add_action(*layout_location_action);
|
||||
layout_menu->add_action(*layout_statusbar_action);
|
||||
layout_menu->add_action(*layout_folderpane_action);
|
||||
|
||||
view_menu->add_separator();
|
||||
|
||||
TRY(view_menu->try_add_action(directory_view->view_as_icons_action()));
|
||||
TRY(view_menu->try_add_action(directory_view->view_as_table_action()));
|
||||
TRY(view_menu->try_add_action(directory_view->view_as_columns_action()));
|
||||
view_menu->add_action(directory_view->view_as_icons_action());
|
||||
view_menu->add_action(directory_view->view_as_table_action());
|
||||
view_menu->add_action(directory_view->view_as_columns_action());
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(show_dotfiles_action));
|
||||
view_menu->add_action(show_dotfiles_action);
|
||||
|
||||
auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"sv)), [&](auto&) {
|
||||
toolbar_container.set_visible(true);
|
||||
@ -1066,18 +1066,18 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
||||
});
|
||||
|
||||
auto go_menu = TRY(window->try_add_menu("&Go"_string));
|
||||
TRY(go_menu->try_add_action(go_back_action));
|
||||
TRY(go_menu->try_add_action(go_forward_action));
|
||||
TRY(go_menu->try_add_action(open_parent_directory_action));
|
||||
TRY(go_menu->try_add_action(open_child_directory_action));
|
||||
TRY(go_menu->try_add_action(go_home_action));
|
||||
TRY(go_menu->try_add_action(go_to_location_action));
|
||||
go_menu->add_action(go_back_action);
|
||||
go_menu->add_action(go_forward_action);
|
||||
go_menu->add_action(open_parent_directory_action);
|
||||
go_menu->add_action(open_child_directory_action);
|
||||
go_menu->add_action(go_home_action);
|
||||
go_menu->add_action(go_to_location_action);
|
||||
go_menu->add_separator();
|
||||
TRY(go_menu->try_add_action(directory_view->open_terminal_action()));
|
||||
go_menu->add_action(directory_view->open_terminal_action());
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager"sv, GUI::Icon::default_icon("app-file-manager"sv), window)));
|
||||
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));
|
||||
|
||||
(void)TRY(main_toolbar.try_add_action(go_back_action));
|
||||
(void)TRY(main_toolbar.try_add_action(go_forward_action));
|
||||
@ -1174,42 +1174,42 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
|
||||
directory_view->open(directory_view->selected_file_paths().first());
|
||||
});
|
||||
|
||||
TRY(directory_context_menu->try_add_action(directory_open_action));
|
||||
TRY(directory_context_menu->try_add_action(open_in_new_window_action));
|
||||
TRY(directory_context_menu->try_add_action(open_in_new_terminal_action));
|
||||
directory_context_menu->add_action(directory_open_action);
|
||||
directory_context_menu->add_action(open_in_new_window_action);
|
||||
directory_context_menu->add_action(open_in_new_terminal_action);
|
||||
directory_context_menu->add_separator();
|
||||
TRY(directory_context_menu->try_add_action(cut_action));
|
||||
TRY(directory_context_menu->try_add_action(copy_action));
|
||||
TRY(directory_context_menu->try_add_action(copy_path_action));
|
||||
TRY(directory_context_menu->try_add_action(folder_specific_paste_action));
|
||||
TRY(directory_context_menu->try_add_action(directory_view->delete_action()));
|
||||
TRY(directory_context_menu->try_add_action(directory_view->rename_action()));
|
||||
TRY(directory_context_menu->try_add_action(shortcut_action));
|
||||
TRY(directory_context_menu->try_add_action(create_archive_action));
|
||||
directory_context_menu->add_action(cut_action);
|
||||
directory_context_menu->add_action(copy_action);
|
||||
directory_context_menu->add_action(copy_path_action);
|
||||
directory_context_menu->add_action(folder_specific_paste_action);
|
||||
directory_context_menu->add_action(directory_view->delete_action());
|
||||
directory_context_menu->add_action(directory_view->rename_action());
|
||||
directory_context_menu->add_action(shortcut_action);
|
||||
directory_context_menu->add_action(create_archive_action);
|
||||
directory_context_menu->add_separator();
|
||||
TRY(directory_context_menu->try_add_action(properties_action));
|
||||
directory_context_menu->add_action(properties_action);
|
||||
|
||||
TRY(directory_view_context_menu->try_add_action(mkdir_action));
|
||||
TRY(directory_view_context_menu->try_add_action(touch_action));
|
||||
TRY(directory_view_context_menu->try_add_action(paste_action));
|
||||
TRY(directory_view_context_menu->try_add_action(directory_view->open_terminal_action()));
|
||||
directory_view_context_menu->add_action(mkdir_action);
|
||||
directory_view_context_menu->add_action(touch_action);
|
||||
directory_view_context_menu->add_action(paste_action);
|
||||
directory_view_context_menu->add_action(directory_view->open_terminal_action());
|
||||
directory_view_context_menu->add_separator();
|
||||
TRY(directory_view_context_menu->try_add_action(show_dotfiles_action));
|
||||
directory_view_context_menu->add_action(show_dotfiles_action);
|
||||
directory_view_context_menu->add_separator();
|
||||
TRY(directory_view_context_menu->try_add_action(properties_action));
|
||||
directory_view_context_menu->add_action(properties_action);
|
||||
|
||||
TRY(tree_view_directory_context_menu->try_add_action(open_in_new_window_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(open_in_new_terminal_action));
|
||||
tree_view_directory_context_menu->add_action(open_in_new_window_action);
|
||||
tree_view_directory_context_menu->add_action(open_in_new_terminal_action);
|
||||
tree_view_directory_context_menu->add_separator();
|
||||
TRY(tree_view_directory_context_menu->try_add_action(mkdir_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(touch_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(cut_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(copy_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(copy_path_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(paste_action));
|
||||
TRY(tree_view_directory_context_menu->try_add_action(tree_view_delete_action));
|
||||
tree_view_directory_context_menu->add_action(mkdir_action);
|
||||
tree_view_directory_context_menu->add_action(touch_action);
|
||||
tree_view_directory_context_menu->add_action(cut_action);
|
||||
tree_view_directory_context_menu->add_action(copy_action);
|
||||
tree_view_directory_context_menu->add_action(copy_path_action);
|
||||
tree_view_directory_context_menu->add_action(paste_action);
|
||||
tree_view_directory_context_menu->add_action(tree_view_delete_action);
|
||||
tree_view_directory_context_menu->add_separator();
|
||||
TRY(tree_view_directory_context_menu->try_add_action(properties_action));
|
||||
tree_view_directory_context_menu->add_action(properties_action);
|
||||
|
||||
RefPtr<GUI::Menu> file_context_menu;
|
||||
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
|
||||
|
@ -734,10 +734,10 @@ 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));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->add_recent_files_list([this](auto& action) {
|
||||
if (!request_close())
|
||||
@ -749,56 +749,56 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (auto result = open_file(file.filename(), file.release_stream()); result.is_error())
|
||||
show_error(result.release_error(), "Opening"sv, file.filename());
|
||||
}));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(edit_menu->try_add_action(*m_redo_action));
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_cut_action));
|
||||
TRY(edit_menu->try_add_action(*m_copy_action));
|
||||
TRY(edit_menu->try_add_action(*m_paste_action));
|
||||
TRY(edit_menu->try_add_action(*m_delete_action));
|
||||
edit_menu->add_action(*m_cut_action);
|
||||
edit_menu->add_action(*m_copy_action);
|
||||
edit_menu->add_action(*m_paste_action);
|
||||
edit_menu->add_action(*m_delete_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_select_all_action));
|
||||
edit_menu->add_action(*m_select_all_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_copy_text_action));
|
||||
edit_menu->add_action(*m_copy_text_action);
|
||||
|
||||
m_context_menu = edit_menu;
|
||||
|
||||
auto go_menu = TRY(window.try_add_menu("&Go"_string));
|
||||
TRY(go_menu->try_add_action(*m_previous_glyph_action));
|
||||
TRY(go_menu->try_add_action(*m_next_glyph_action));
|
||||
TRY(go_menu->try_add_action(*m_go_to_glyph_action));
|
||||
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 layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
TRY(layout_menu->try_add_action(*m_show_toolbar_action));
|
||||
TRY(layout_menu->try_add_action(*m_show_statusbar_action));
|
||||
TRY(layout_menu->try_add_action(*m_show_metadata_action));
|
||||
TRY(layout_menu->try_add_action(*m_show_unicode_blocks_action));
|
||||
layout_menu->add_action(*m_show_toolbar_action);
|
||||
layout_menu->add_action(*m_show_statusbar_action);
|
||||
layout_menu->add_action(*m_show_metadata_action);
|
||||
layout_menu->add_action(*m_show_unicode_blocks_action);
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(*m_open_preview_action));
|
||||
view_menu->add_action(*m_open_preview_action);
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(*m_highlight_modifications_action));
|
||||
TRY(view_menu->try_add_action(*m_show_system_emoji_action));
|
||||
view_menu->add_action(*m_highlight_modifications_action);
|
||||
view_menu->add_action(*m_show_system_emoji_action);
|
||||
view_menu->add_separator();
|
||||
auto scale_menu = view_menu->add_submenu("&Scale"_string);
|
||||
scale_menu->set_icon(g_resources.scale_editor);
|
||||
TRY(scale_menu->try_add_action(*m_scale_five_action));
|
||||
TRY(scale_menu->try_add_action(*m_scale_ten_action));
|
||||
TRY(scale_menu->try_add_action(*m_scale_fifteen_action));
|
||||
scale_menu->add_action(*m_scale_five_action);
|
||||
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));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv)), &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv)), &window));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -205,30 +205,30 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
||||
(void)TRY(m_toolbar->try_add_action(*m_go_home_action));
|
||||
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto go_menu = TRY(window.try_add_menu("&Go"_string));
|
||||
TRY(go_menu->try_add_action(*m_go_back_action));
|
||||
TRY(go_menu->try_add_action(*m_go_forward_action));
|
||||
TRY(go_menu->try_add_action(*m_go_home_action));
|
||||
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));
|
||||
String help_page_path = TRY(TRY(try_make_ref_counted<Manual::PageNode>(Manual::sections[1 - 1], "Applications/Help"_string))->path());
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_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&) {
|
||||
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&) {
|
||||
open_page(help_page_path);
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window));
|
||||
|
||||
m_context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(m_context_menu->try_add_action(*m_go_back_action));
|
||||
TRY(m_context_menu->try_add_action(*m_go_forward_action));
|
||||
TRY(m_context_menu->try_add_action(*m_go_home_action));
|
||||
m_context_menu->add_action(*m_go_back_action);
|
||||
m_context_menu->add_action(*m_go_forward_action);
|
||||
m_context_menu->add_action(*m_go_home_action);
|
||||
m_context_menu->add_separator();
|
||||
TRY(m_context_menu->try_add_action(*m_copy_action));
|
||||
TRY(m_context_menu->try_add_action(*m_select_all_action));
|
||||
m_context_menu->add_action(*m_copy_action);
|
||||
m_context_menu->add_action(*m_select_all_action);
|
||||
|
||||
m_manual_model = TRY(ManualModel::create());
|
||||
m_browse_view->set_model(*m_manual_model);
|
||||
|
@ -413,10 +413,10 @@ 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));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
auto path = action.text();
|
||||
@ -427,28 +427,28 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
auto file = response.release_value();
|
||||
open_file(file.filename(), file.release_stream());
|
||||
}));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(edit_menu->try_add_action(*m_redo_action));
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(GUI::CommonActions::make_select_all_action([this](auto&) {
|
||||
edit_menu->add_action(GUI::CommonActions::make_select_all_action([this](auto&) {
|
||||
m_editor->select_all();
|
||||
m_editor->update();
|
||||
})));
|
||||
TRY(edit_menu->try_add_action(*m_fill_selection_action));
|
||||
}));
|
||||
edit_menu->add_action(*m_fill_selection_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_copy_hex_action));
|
||||
TRY(edit_menu->try_add_action(*m_copy_text_action));
|
||||
TRY(edit_menu->try_add_action(*m_copy_as_c_code_action));
|
||||
edit_menu->add_action(*m_copy_hex_action);
|
||||
edit_menu->add_action(*m_copy_text_action);
|
||||
edit_menu->add_action(*m_copy_as_c_code_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_find_action));
|
||||
TRY(edit_menu->try_add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png"sv)), [&](const GUI::Action&) {
|
||||
edit_menu->add_action(*m_find_action);
|
||||
edit_menu->add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png"sv)), [&](const GUI::Action&) {
|
||||
if (m_search_text.is_empty() || m_search_buffer.is_empty()) {
|
||||
GUI::MessageBox::show(&window, "Nothing to search for"sv, "Not Found"sv, GUI::MessageBox::Type::Warning);
|
||||
return;
|
||||
@ -461,9 +461,9 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
}
|
||||
m_editor->update();
|
||||
m_last_found_index = result.value();
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(edit_menu->try_add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_F }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)), [&](const GUI::Action&) {
|
||||
edit_menu->add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_F }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)), [&](const GUI::Action&) {
|
||||
int min_length = 4;
|
||||
auto matches = m_editor->find_all_strings(min_length);
|
||||
m_search_results->set_model(*new SearchResultsModel(move(matches)));
|
||||
@ -476,9 +476,9 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
|
||||
set_search_results_visible(true);
|
||||
m_editor->update();
|
||||
})));
|
||||
}));
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_goto_offset_action));
|
||||
edit_menu->add_action(*m_goto_offset_action);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
|
||||
@ -492,9 +492,9 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
auto show_value_inspector = Config::read_bool("HexEditor"sv, "Layout"sv, "ShowValueInspector"sv, false);
|
||||
set_value_inspector_visible(show_value_inspector);
|
||||
|
||||
TRY(view_menu->try_add_action(*m_layout_toolbar_action));
|
||||
TRY(view_menu->try_add_action(*m_layout_search_results_action));
|
||||
TRY(view_menu->try_add_action(*m_layout_value_inspector_action));
|
||||
view_menu->add_action(*m_layout_toolbar_action);
|
||||
view_menu->add_action(*m_layout_search_results_action);
|
||||
view_menu->add_action(*m_layout_value_inspector_action);
|
||||
view_menu->add_separator();
|
||||
|
||||
auto bytes_per_row = Config::read_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, 16);
|
||||
@ -510,7 +510,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
Config::write_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, i);
|
||||
});
|
||||
m_bytes_per_row_actions.add_action(action);
|
||||
TRY(bytes_per_row_menu->try_add_action(action));
|
||||
bytes_per_row_menu->add_action(action);
|
||||
if (i == bytes_per_row)
|
||||
action->set_checked(true);
|
||||
}
|
||||
@ -524,7 +524,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
Config::write_bool("HexEditor"sv, "Layout"sv, "UseLittleEndianInValueInspector"sv, m_value_inspector_little_endian);
|
||||
});
|
||||
m_value_inspector_mode_actions.add_action(little_endian_mode);
|
||||
TRY(inspector_mode_menu->try_add_action(little_endian_mode));
|
||||
inspector_mode_menu->add_action(little_endian_mode);
|
||||
|
||||
auto big_endian_mode = GUI::Action::create_checkable("&Big Endian", [this](auto& action) {
|
||||
m_value_inspector_little_endian = !action.is_checked();
|
||||
@ -533,7 +533,7 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
Config::write_bool("HexEditor"sv, "Layout"sv, "UseLittleEndianInValueInspector"sv, m_value_inspector_little_endian);
|
||||
});
|
||||
m_value_inspector_mode_actions.add_action(big_endian_mode);
|
||||
TRY(inspector_mode_menu->try_add_action(big_endian_mode));
|
||||
inspector_mode_menu->add_action(big_endian_mode);
|
||||
|
||||
auto use_little_endian = Config::read_bool("HexEditor"sv, "Layout"sv, "UseLittleEndianInValueInspector"sv, true);
|
||||
m_value_inspector_little_endian = use_little_endian;
|
||||
@ -542,11 +542,11 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
|
||||
big_endian_mode->set_checked(!use_little_endian);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"sv), &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"sv), &window));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -307,8 +307,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
(void)TRY(main_toolbar->try_add_action(zoom_out_action));
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(open_action));
|
||||
TRY(file_menu->try_add_action(delete_action));
|
||||
file_menu->add_action(open_action);
|
||||
file_menu->add_action(delete_action);
|
||||
file_menu->add_separator();
|
||||
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
@ -321,29 +321,29 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
widget->open_file(value.filename(), value.stream());
|
||||
}));
|
||||
|
||||
TRY(file_menu->try_add_action(quit_action));
|
||||
file_menu->add_action(quit_action);
|
||||
|
||||
auto image_menu = TRY(window->try_add_menu("&Image"_string));
|
||||
TRY(image_menu->try_add_action(rotate_counterclockwise_action));
|
||||
TRY(image_menu->try_add_action(rotate_clockwise_action));
|
||||
TRY(image_menu->try_add_action(vertical_flip_action));
|
||||
TRY(image_menu->try_add_action(horizontal_flip_action));
|
||||
image_menu->add_action(rotate_counterclockwise_action);
|
||||
image_menu->add_action(rotate_clockwise_action);
|
||||
image_menu->add_action(vertical_flip_action);
|
||||
image_menu->add_action(horizontal_flip_action);
|
||||
image_menu->add_separator();
|
||||
TRY(image_menu->try_add_action(desktop_wallpaper_action));
|
||||
image_menu->add_action(desktop_wallpaper_action);
|
||||
|
||||
auto navigate_menu = TRY(window->try_add_menu("&Navigate"_string));
|
||||
TRY(navigate_menu->try_add_action(go_first_action));
|
||||
TRY(navigate_menu->try_add_action(go_back_action));
|
||||
TRY(navigate_menu->try_add_action(go_forward_action));
|
||||
TRY(navigate_menu->try_add_action(go_last_action));
|
||||
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));
|
||||
TRY(view_menu->try_add_action(full_screen_action));
|
||||
view_menu->add_action(full_screen_action);
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(zoom_in_action));
|
||||
TRY(view_menu->try_add_action(reset_zoom_action));
|
||||
TRY(view_menu->try_add_action(fit_image_to_view_action));
|
||||
TRY(view_menu->try_add_action(zoom_out_action));
|
||||
view_menu->add_action(zoom_in_action);
|
||||
view_menu->add_action(reset_zoom_action);
|
||||
view_menu->add_action(fit_image_to_view_action);
|
||||
view_menu->add_action(zoom_out_action);
|
||||
view_menu->add_separator();
|
||||
|
||||
auto scaling_mode_menu = view_menu->add_submenu("&Scaling Mode"_string);
|
||||
@ -356,20 +356,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
scaling_mode_group->add_action(*bilinear_action);
|
||||
scaling_mode_group->add_action(*box_sampling_action);
|
||||
|
||||
TRY(scaling_mode_menu->try_add_action(nearest_neighbor_action));
|
||||
TRY(scaling_mode_menu->try_add_action(smooth_pixels_action));
|
||||
TRY(scaling_mode_menu->try_add_action(bilinear_action));
|
||||
TRY(scaling_mode_menu->try_add_action(box_sampling_action));
|
||||
scaling_mode_menu->add_action(nearest_neighbor_action);
|
||||
scaling_mode_menu->add_action(smooth_pixels_action);
|
||||
scaling_mode_menu->add_action(bilinear_action);
|
||||
scaling_mode_menu->add_action(box_sampling_action);
|
||||
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(hide_show_toolbar_action));
|
||||
view_menu->add_action(hide_show_toolbar_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Image Viewer", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Image Viewer", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto magnifier = TRY(window->set_main_widget<MagnifierWidget>());
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
AK::DeprecatedString filename = "file for saving";
|
||||
auto do_save = [&]() -> ErrorOr<void> {
|
||||
auto response = FileSystemAccessClient::Client::the().save_file(window, "Capture", "png");
|
||||
@ -82,11 +82,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
GUI::MessageBox::show(window, "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
warnln("Error saving bitmap to {}: {}", filename, result.error().string_literal());
|
||||
}
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto size_action_group = make<GUI::ActionGroup>();
|
||||
|
||||
@ -143,16 +143,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
size_action_group->set_exclusive(true);
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(two_x_action));
|
||||
TRY(view_menu->try_add_action(four_x_action));
|
||||
TRY(view_menu->try_add_action(eight_x_action));
|
||||
view_menu->add_action(two_x_action);
|
||||
view_menu->add_action(four_x_action);
|
||||
view_menu->add_action(eight_x_action);
|
||||
two_x_action->set_checked(true);
|
||||
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(pause_action));
|
||||
TRY(view_menu->try_add_action(lock_location_action));
|
||||
TRY(view_menu->try_add_action(show_grid_action));
|
||||
TRY(view_menu->try_add_action(choose_grid_color_action));
|
||||
view_menu->add_action(pause_action);
|
||||
view_menu->add_action(lock_location_action);
|
||||
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 previous_frame_action = GUI::Action::create(
|
||||
@ -167,17 +167,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
magnifier->pause_capture(true);
|
||||
magnifier->display_next_frame();
|
||||
});
|
||||
TRY(timeline_menu->try_add_action(previous_frame_action));
|
||||
TRY(timeline_menu->try_add_action(next_frame_action));
|
||||
timeline_menu->add_action(previous_frame_action);
|
||||
timeline_menu->add_action(next_frame_action);
|
||||
|
||||
TRY(window->try_add_menu(TRY(GUI::CommonMenus::make_accessibility_menu(magnifier))));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Magnifier", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Magnifier", app_icon, window));
|
||||
|
||||
window->show();
|
||||
window->set_always_on_top(true);
|
||||
|
@ -209,7 +209,7 @@ PDFViewerWidget::PDFViewerWidget()
|
||||
ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = Vector {
|
||||
GUI::FileTypeFilter { "PDF Files", { { "pdf" } } },
|
||||
@ -219,31 +219,31 @@ ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
||||
auto response = FileSystemAccessClient::Client::the().open_file(&window, options);
|
||||
if (!response.is_error())
|
||||
open_file(response.value().filename(), response.value().release_stream());
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
||||
if (!response.is_error())
|
||||
open_file(response.value().filename(), response.value().release_stream());
|
||||
}));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(*m_toggle_sidebar_action));
|
||||
view_menu->add_action(*m_toggle_sidebar_action);
|
||||
view_menu->add_separator();
|
||||
auto view_mode_menu = view_menu->add_submenu("View &Mode"_string);
|
||||
TRY(view_mode_menu->try_add_action(*m_page_view_mode_single));
|
||||
TRY(view_mode_menu->try_add_action(*m_page_view_mode_multiple));
|
||||
view_mode_menu->add_action(*m_page_view_mode_single);
|
||||
view_mode_menu->add_action(*m_page_view_mode_multiple);
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(*m_zoom_in_action));
|
||||
TRY(view_menu->try_add_action(*m_zoom_out_action));
|
||||
TRY(view_menu->try_add_action(*m_reset_zoom_action));
|
||||
view_menu->add_action(*m_zoom_in_action);
|
||||
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));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"sv), &window)));
|
||||
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 {};
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Partition Editor", app_icon, window)));
|
||||
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));
|
||||
|
||||
window->show();
|
||||
return app->exec();
|
||||
|
@ -93,15 +93,15 @@ ErrorOr<void> MainWidget::initialize()
|
||||
|
||||
ErrorOr<void> MainWidget::add_track_actions(GUI::Menu& menu)
|
||||
{
|
||||
TRY(menu.try_add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv)), [&](auto&) {
|
||||
menu.add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv)), [&](auto&) {
|
||||
m_player_widget->add_track();
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(menu.try_add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-last.png"sv)), [&](auto&) {
|
||||
menu.add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-last.png"sv)), [&](auto&) {
|
||||
turn_off_pressed_keys();
|
||||
m_player_widget->next_track();
|
||||
turn_on_pressed_keys();
|
||||
})));
|
||||
}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
main_widget_updater->start();
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_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&) {
|
||||
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())
|
||||
return;
|
||||
@ -76,19 +76,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
need_to_write_wav = true;
|
||||
wav_progress_window->set_filename(save_path.value());
|
||||
wav_progress_window->show();
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
TRY(main_widget->add_track_actions(edit_menu));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Piano", app_icon, window)));
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Piano", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -217,15 +217,15 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
GUI::Application::the()->set_most_recently_open_file(path_string);
|
||||
});
|
||||
|
||||
TRY(file_menu->try_add_action(*m_new_image_action));
|
||||
TRY(file_menu->try_add_action(*m_new_image_from_clipboard_action));
|
||||
TRY(file_menu->try_add_action(*m_open_image_action));
|
||||
TRY(file_menu->try_add_action(*m_save_image_action));
|
||||
TRY(file_menu->try_add_action(*m_save_image_as_action));
|
||||
file_menu->add_action(*m_new_image_action);
|
||||
file_menu->add_action(*m_new_image_from_clipboard_action);
|
||||
file_menu->add_action(*m_open_image_action);
|
||||
file_menu->add_action(*m_save_image_action);
|
||||
file_menu->add_action(*m_save_image_as_action);
|
||||
|
||||
m_export_submenu = file_menu->add_submenu("&Export"_string);
|
||||
|
||||
TRY(m_export_submenu->try_add_action(
|
||||
m_export_submenu->add_action(
|
||||
GUI::Action::create(
|
||||
"As &BMP...", [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
@ -237,9 +237,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
auto result = editor->image().export_bmp_to_file(response.value().release_stream(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes);
|
||||
if (result.is_error())
|
||||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Export to BMP failed: {}", result.release_error())));
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_export_submenu->try_add_action(
|
||||
m_export_submenu->add_action(
|
||||
GUI::Action::create(
|
||||
"As &PNG...", [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
@ -252,9 +252,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
auto result = editor->image().export_png_to_file(response.value().release_stream(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes);
|
||||
if (result.is_error())
|
||||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Export to PNG failed: {}", result.release_error())));
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_export_submenu->try_add_action(
|
||||
m_export_submenu->add_action(
|
||||
GUI::Action::create(
|
||||
"As &QOI...", [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
@ -265,7 +265,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
auto result = editor->image().export_qoi_to_file(response.value().release_stream());
|
||||
if (result.is_error())
|
||||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Export to QOI failed: {}", result.release_error())));
|
||||
})));
|
||||
}));
|
||||
|
||||
m_export_submenu->set_icon(g_icon_bag.file_export);
|
||||
|
||||
@ -285,12 +285,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_tab_widget->on_tab_close_click(*active_widget);
|
||||
});
|
||||
|
||||
TRY(file_menu->try_add_action(*m_close_image_action));
|
||||
file_menu->add_action(*m_close_image_action);
|
||||
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (request_close())
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
m_edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
|
||||
@ -407,16 +407,16 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->redo();
|
||||
});
|
||||
|
||||
TRY(m_edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(m_edit_menu->try_add_action(*m_redo_action));
|
||||
m_edit_menu->add_action(*m_undo_action);
|
||||
m_edit_menu->add_action(*m_redo_action);
|
||||
m_edit_menu->add_separator();
|
||||
TRY(m_edit_menu->try_add_action(*m_cut_action));
|
||||
TRY(m_edit_menu->try_add_action(*m_copy_action));
|
||||
TRY(m_edit_menu->try_add_action(*m_copy_merged_action));
|
||||
TRY(m_edit_menu->try_add_action(*m_paste_action));
|
||||
m_edit_menu->add_action(*m_cut_action);
|
||||
m_edit_menu->add_action(*m_copy_action);
|
||||
m_edit_menu->add_action(*m_copy_merged_action);
|
||||
m_edit_menu->add_action(*m_paste_action);
|
||||
m_edit_menu->add_separator();
|
||||
|
||||
TRY(m_edit_menu->try_add_action(GUI::CommonActions::make_select_all_action([&](auto&) {
|
||||
m_edit_menu->add_action(GUI::CommonActions::make_select_all_action([&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
if (!editor->active_layer())
|
||||
@ -424,39 +424,39 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
auto layer_rect = editor->active_layer()->relative_rect();
|
||||
editor->image().selection().merge(layer_rect.intersected(editor->image().rect()), PixelPaint::Selection::MergeMode::Set);
|
||||
editor->did_complete_action("Select All"sv);
|
||||
})));
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"Clear &Selection", g_icon_bag.clear_selection, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->image().selection().clear();
|
||||
editor->did_complete_action("Clear Selection"sv);
|
||||
})));
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"&Invert Selection", g_icon_bag.invert_selection, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->image().selection().invert();
|
||||
editor->did_complete_action("Invert Selection"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_edit_menu->add_separator();
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"S&wap Colors", { Mod_None, Key_X }, g_icon_bag.swap_colors, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
auto old_primary_color = editor->primary_color();
|
||||
editor->set_primary_color(editor->secondary_color());
|
||||
editor->set_secondary_color(old_primary_color);
|
||||
})));
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"&Default Colors", { Mod_None, Key_D }, g_icon_bag.default_colors, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->set_primary_color(Color::Black);
|
||||
editor->set_secondary_color(Color::White);
|
||||
})));
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"&Load Color Palette...", g_icon_bag.load_color_palette, [&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.window_title = "Load Color Palette"sv,
|
||||
@ -476,8 +476,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
}
|
||||
|
||||
m_palette_widget->display_color_list(result.value());
|
||||
})));
|
||||
TRY(m_edit_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"Sa&ve Color Palette...", g_icon_bag.save_color_palette, [&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().save_file(&window, "untitled", "palette");
|
||||
if (response.is_error())
|
||||
@ -486,7 +486,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
auto result = PixelPaint::PaletteWidget::save_palette_file(m_palette_widget->colors(), response.release_value().release_stream());
|
||||
if (result.is_error())
|
||||
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));
|
||||
|
||||
@ -533,25 +533,25 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
});
|
||||
m_show_guides_action->set_checked(Config::read_bool("PixelPaint"sv, "Guides"sv, "Show"sv, true));
|
||||
|
||||
TRY(m_view_menu->try_add_action(*m_zoom_in_action));
|
||||
TRY(m_view_menu->try_add_action(*m_zoom_out_action));
|
||||
TRY(m_view_menu->try_add_action(*m_reset_zoom_action));
|
||||
TRY(m_view_menu->try_add_action(GUI::Action::create(
|
||||
m_view_menu->add_action(*m_zoom_in_action);
|
||||
m_view_menu->add_action(*m_zoom_out_action);
|
||||
m_view_menu->add_action(*m_reset_zoom_action);
|
||||
m_view_menu->add_action(GUI::Action::create(
|
||||
"Fit Image To &View", g_icon_bag.fit_image_to_view, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->fit_image_to_view();
|
||||
})));
|
||||
}));
|
||||
m_view_menu->add_separator();
|
||||
TRY(m_view_menu->try_add_action(*m_add_guide_action));
|
||||
TRY(m_view_menu->try_add_action(*m_show_guides_action));
|
||||
m_view_menu->add_action(*m_add_guide_action);
|
||||
m_view_menu->add_action(*m_show_guides_action);
|
||||
|
||||
TRY(m_view_menu->try_add_action(GUI::Action::create(
|
||||
m_view_menu->add_action(GUI::Action::create(
|
||||
"&Clear Guides", g_icon_bag.clear_guides, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->clear_guides();
|
||||
})));
|
||||
}));
|
||||
m_view_menu->add_separator();
|
||||
|
||||
auto show_pixel_grid_action = GUI::Action::create_checkable(
|
||||
@ -562,7 +562,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->set_pixel_grid_visibility(action.is_checked());
|
||||
});
|
||||
show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true));
|
||||
TRY(m_view_menu->try_add_action(*show_pixel_grid_action));
|
||||
m_view_menu->add_action(*show_pixel_grid_action);
|
||||
|
||||
m_show_rulers_action = TRY(GUI::Action::try_create_checkable(
|
||||
"Show R&ulers", { Mod_Ctrl, Key_R }, [&](auto& action) {
|
||||
@ -572,7 +572,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->set_ruler_visibility(action.is_checked());
|
||||
}));
|
||||
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true));
|
||||
TRY(m_view_menu->try_add_action(*m_show_rulers_action));
|
||||
m_view_menu->add_action(*m_show_rulers_action);
|
||||
|
||||
m_show_active_layer_boundary_action = GUI::Action::create_checkable(
|
||||
"Show Active Layer &Boundary", [&](auto& action) {
|
||||
@ -582,7 +582,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->set_show_active_layer_boundary(action.is_checked());
|
||||
});
|
||||
m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint"sv, "ImageEditor"sv, "ShowActiveLayerBoundary"sv, true));
|
||||
TRY(m_view_menu->try_add_action(*m_show_active_layer_boundary_action));
|
||||
m_view_menu->add_action(*m_show_active_layer_boundary_action);
|
||||
|
||||
m_view_menu->add_separator();
|
||||
|
||||
@ -601,8 +601,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_vectorscope_widget->parent_widget()->set_visible(vectorscope_action->is_checked());
|
||||
|
||||
auto scopes_menu = m_view_menu->add_submenu("&Scopes"_string);
|
||||
TRY(scopes_menu->try_add_action(histogram_action));
|
||||
TRY(scopes_menu->try_add_action(vectorscope_action));
|
||||
scopes_menu->add_action(histogram_action);
|
||||
scopes_menu->add_action(vectorscope_action);
|
||||
|
||||
m_tool_menu = TRY(window.try_add_menu("&Tool"_string));
|
||||
m_toolbox->for_each_tool([&](auto& tool) {
|
||||
@ -612,7 +612,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
});
|
||||
|
||||
m_image_menu = TRY(window.try_add_menu("&Image"_string));
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create(
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"Flip Image &Vertically", g_icon_bag.edit_flip_vertical, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -622,8 +622,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Flip Image Vertically"sv);
|
||||
})));
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"Flip Image &Horizontally", g_icon_bag.edit_flip_horizontal, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -633,10 +633,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Flip Image Horizontally"sv);
|
||||
})));
|
||||
}));
|
||||
m_image_menu->add_separator();
|
||||
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create("Rotate Image &Counterclockwise", { Mod_Ctrl | Mod_Shift, Key_LessThan }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-ccw.png"sv)),
|
||||
m_image_menu->add_action(GUI::Action::create("Rotate Image &Counterclockwise", { Mod_Ctrl | Mod_Shift, Key_LessThan }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-ccw.png"sv)),
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -646,9 +646,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Rotate Image Counterclockwise"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create("Rotate Image Clock&wise", { Mod_Ctrl | Mod_Shift, Key_GreaterThan }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-cw.png"sv)),
|
||||
m_image_menu->add_action(GUI::Action::create("Rotate Image Clock&wise", { Mod_Ctrl | Mod_Shift, Key_GreaterThan }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-cw.png"sv)),
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -658,9 +658,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Rotate Image Clockwise"sv);
|
||||
})));
|
||||
}));
|
||||
m_image_menu->add_separator();
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create(
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"&Resize Image...", { Mod_Ctrl | Mod_Shift, Key_R }, g_icon_bag.resize_image, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -674,8 +674,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
// FIXME: We should ensure the selection is within the bounds of the image here.
|
||||
editor->did_complete_action("Resize Image"sv);
|
||||
}
|
||||
})));
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"&Crop Image to Selection", g_icon_bag.crop, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -694,9 +694,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
}
|
||||
editor->image().selection().clear();
|
||||
editor->did_complete_action("Crop Image to Selection"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_image_menu->try_add_action(GUI::Action::create(
|
||||
m_image_menu->add_action(GUI::Action::create(
|
||||
"&Crop Image to Content", g_icon_bag.crop, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -711,7 +711,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Crop Image to Content"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_layer_menu = TRY(window.try_add_menu("&Layer"_string));
|
||||
|
||||
@ -726,7 +726,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_layer_via_cut->set_enabled(image_has_selection);
|
||||
};
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, g_icon_bag.new_layer, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -742,9 +742,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->did_complete_action("New Layer"sv);
|
||||
m_layer_list_widget->select_top_layer();
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Duplicate Layer", { Mod_Ctrl | Mod_Shift, Key_D }, g_icon_bag.new_layer, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -764,7 +764,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->image().select_layer(duplicated_layer);
|
||||
editor->layers_did_change();
|
||||
editor->did_complete_action("Duplicate Layer"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_layer_via_copy = GUI::Action::create(
|
||||
"Layer via Copy", { Mod_Ctrl | Mod_Shift, Key_C }, g_icon_bag.new_layer, [&](auto&) {
|
||||
@ -776,7 +776,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
current_image_editor()->did_complete_action("New Layer via Copy"sv);
|
||||
m_layer_list_widget->select_top_layer();
|
||||
});
|
||||
TRY(m_layer_menu->try_add_action(*m_layer_via_copy));
|
||||
m_layer_menu->add_action(*m_layer_via_copy);
|
||||
|
||||
m_layer_via_cut = GUI::Action::create(
|
||||
"Layer via Cut", { Mod_Ctrl | Mod_Shift, Key_X }, g_icon_bag.new_layer, [&](auto&) {
|
||||
@ -789,7 +789,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
current_image_editor()->did_complete_action("New Layer via Cut"sv);
|
||||
m_layer_list_widget->select_top_layer();
|
||||
});
|
||||
TRY(m_layer_menu->try_add_action(*m_layer_via_cut));
|
||||
m_layer_menu->add_action(*m_layer_via_cut);
|
||||
|
||||
m_layer_menu->add_separator();
|
||||
|
||||
@ -818,7 +818,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (auto maybe_error = active_layer->create_mask(Layer::MaskType::BasicMask); maybe_error.is_error())
|
||||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Failed to create layer mask: {}", maybe_error.release_error())));
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_add_mask_action));
|
||||
mask_submenu->add_action(*m_add_mask_action);
|
||||
|
||||
m_add_editing_mask_action = GUI::Action::create(
|
||||
"Add E&diting Mask", { Mod_Ctrl | Mod_Alt, Key_E }, g_icon_bag.add_mask, create_layer_mask_callback("Add Editing Mask", [&](Layer* active_layer) {
|
||||
@ -826,35 +826,35 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (auto maybe_error = active_layer->create_mask(Layer::MaskType::EditingMask); maybe_error.is_error())
|
||||
GUI::MessageBox::show_error(&window, MUST(String::formatted("Failed to create layer mask: {}", maybe_error.release_error())));
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_add_editing_mask_action));
|
||||
mask_submenu->add_action(*m_add_editing_mask_action);
|
||||
|
||||
m_delete_mask_action = GUI::Action::create(
|
||||
"Delete Mask", create_layer_mask_callback("Delete Mask", [&](Layer* active_layer) {
|
||||
VERIFY(active_layer->is_masked());
|
||||
active_layer->delete_mask();
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_delete_mask_action));
|
||||
mask_submenu->add_action(*m_delete_mask_action);
|
||||
|
||||
m_apply_mask_action = GUI::Action::create(
|
||||
"Apply Mask", create_layer_mask_callback("Apply Mask", [&](Layer* active_layer) {
|
||||
VERIFY(active_layer->is_masked());
|
||||
active_layer->apply_mask();
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_apply_mask_action));
|
||||
mask_submenu->add_action(*m_apply_mask_action);
|
||||
|
||||
m_invert_mask_action = GUI::Action::create(
|
||||
"Invert Mask", create_layer_mask_callback("Invert Mask", [&](Layer* active_layer) {
|
||||
VERIFY(active_layer->is_masked());
|
||||
active_layer->invert_mask();
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_invert_mask_action));
|
||||
mask_submenu->add_action(*m_invert_mask_action);
|
||||
|
||||
m_clear_mask_action = GUI::Action::create(
|
||||
"Clear Mask", create_layer_mask_callback("Clear Mask", [&](Layer* active_layer) {
|
||||
VERIFY(active_layer->is_masked());
|
||||
active_layer->clear_mask();
|
||||
}));
|
||||
TRY(mask_submenu->try_add_action(*m_clear_mask_action));
|
||||
mask_submenu->add_action(*m_clear_mask_action);
|
||||
|
||||
m_toggle_mask_visibility_action = GUI::Action::create_checkable(
|
||||
"Show Mask", [&](auto&) {
|
||||
@ -868,7 +868,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->update();
|
||||
});
|
||||
|
||||
TRY(mask_submenu->try_add_action(*m_toggle_mask_visibility_action));
|
||||
mask_submenu->add_action(*m_toggle_mask_visibility_action);
|
||||
|
||||
m_open_luminosity_masking_action = GUI::Action::create(
|
||||
"Luminosity Masking", [&](auto&) {
|
||||
@ -882,7 +882,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_layer_list_widget->repaint();
|
||||
});
|
||||
|
||||
TRY(mask_submenu->try_add_action(*m_open_luminosity_masking_action));
|
||||
mask_submenu->add_action(*m_open_luminosity_masking_action);
|
||||
|
||||
m_open_color_masking_action = GUI::Action::create(
|
||||
"Color Masking", [&](auto&) {
|
||||
@ -896,28 +896,28 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_layer_list_widget->repaint();
|
||||
});
|
||||
|
||||
TRY(mask_submenu->try_add_action(*m_open_color_masking_action));
|
||||
mask_submenu->add_action(*m_open_color_masking_action);
|
||||
|
||||
m_layer_menu->add_separator();
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Select &Previous Layer", { 0, Key_PageUp }, g_icon_bag.previous_layer, [&](auto&) {
|
||||
m_layer_list_widget->cycle_through_selection(1);
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Select &Next Layer", { 0, Key_PageDown }, g_icon_bag.next_layer, [&](auto&) {
|
||||
m_layer_list_widget->cycle_through_selection(-1);
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Select &Top Layer", { 0, Key_Home }, g_icon_bag.top_layer, [&](auto&) {
|
||||
m_layer_list_widget->select_top_layer();
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Select B&ottom Layer", { 0, Key_End }, g_icon_bag.bottom_layer, [&](auto&) {
|
||||
m_layer_list_widget->select_bottom_layer();
|
||||
})));
|
||||
}));
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::CommonActions::make_move_to_front_action(
|
||||
m_layer_menu->add_action(GUI::CommonActions::make_move_to_front_action(
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -926,8 +926,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
editor->image().move_layer_to_front(*active_layer);
|
||||
editor->layers_did_change();
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::CommonActions::make_move_to_back_action(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::CommonActions::make_move_to_back_action(
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -936,9 +936,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
editor->image().move_layer_to_back(*active_layer);
|
||||
editor->layers_did_change();
|
||||
})));
|
||||
}));
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Move Active Layer &Up", { Mod_Ctrl, Key_PageUp }, g_icon_bag.active_layer_up, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -946,8 +946,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (!active_layer)
|
||||
return;
|
||||
editor->image().move_layer_up(*active_layer);
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Move Active Layer &Down", { Mod_Ctrl, Key_PageDown }, g_icon_bag.active_layer_down, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -955,9 +955,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (!active_layer)
|
||||
return;
|
||||
editor->image().move_layer_down(*active_layer);
|
||||
})));
|
||||
}));
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"&Remove Active Layer", { Mod_Ctrl, Key_D }, g_icon_bag.delete_layer, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -982,13 +982,13 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->layers_did_change();
|
||||
m_layer_list_widget->select_top_layer();
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
m_layer_list_widget->on_context_menu_request = [&](auto& event) {
|
||||
m_layer_menu->popup(event.screen_position());
|
||||
};
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Fl&atten Image", { Mod_Ctrl, Key_F }, g_icon_bag.flatten_image, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -997,9 +997,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Flatten Image"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"&Merge Visible", { Mod_Ctrl, Key_M }, g_icon_bag.merge_visible, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1008,9 +1008,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Merge Visible"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Merge &Active Layer Up", g_icon_bag.merge_active_layer_up, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1023,9 +1023,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Merge Active Layer Up"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"M&erge Active Layer Down", { Mod_Ctrl, Key_E }, g_icon_bag.merge_active_layer_down, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1038,10 +1038,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Merge Active Layer Down"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Flip Layer &Vertically", g_icon_bag.edit_flip_vertical, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1054,8 +1054,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Flip Layer Vertically"sv);
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"Flip Layer &Horizontally", g_icon_bag.edit_flip_horizontal, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1068,10 +1068,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Flip Layer Horizontally"sv);
|
||||
})));
|
||||
}));
|
||||
m_layer_menu->add_separator();
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create("Rotate Layer &Counterclockwise", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-ccw.png"sv)),
|
||||
m_layer_menu->add_action(GUI::Action::create("Rotate Layer &Counterclockwise", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-ccw.png"sv)),
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1084,9 +1084,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Rotate Layer Counterclockwise"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create("Rotate Layer Clock&wise", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-cw.png"sv)),
|
||||
m_layer_menu->add_action(GUI::Action::create("Rotate Layer Clock&wise", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-cw.png"sv)),
|
||||
[&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1099,10 +1099,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
}
|
||||
editor->did_complete_action("Rotate Layer Clockwise"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_layer_menu->add_separator();
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"&Crop Layer to Selection", g_icon_bag.crop, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1120,8 +1120,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
active_layer->set_location(intersection.location());
|
||||
editor->image().selection().clear();
|
||||
editor->did_complete_action("Crop Layer to Selection"sv);
|
||||
})));
|
||||
TRY(m_layer_menu->try_add_action(GUI::Action::create(
|
||||
}));
|
||||
m_layer_menu->add_action(GUI::Action::create(
|
||||
"&Crop Layer to Content", g_icon_bag.crop, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
@ -1138,20 +1138,20 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
}
|
||||
active_layer->set_location(content_bounding_rect->location());
|
||||
editor->did_complete_action("Crop Layer to Content"sv);
|
||||
})));
|
||||
}));
|
||||
|
||||
m_filter_menu = TRY(window.try_add_menu("&Filter"_string));
|
||||
|
||||
TRY(m_filter_menu->try_add_action(GUI::Action::create("Filter &Gallery", g_icon_bag.filter, [&](auto&) {
|
||||
m_filter_menu->add_action(GUI::Action::create("Filter &Gallery", g_icon_bag.filter, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
auto dialog = PixelPaint::FilterGallery::construct(&window, editor);
|
||||
if (dialog->exec() != GUI::Dialog::ExecResult::OK)
|
||||
return;
|
||||
})));
|
||||
}));
|
||||
|
||||
m_filter_menu->add_separator();
|
||||
TRY(m_filter_menu->try_add_action(GUI::Action::create("Generic 5x5 &Convolution", g_icon_bag.generic_5x5_convolution, [&](auto&) {
|
||||
m_filter_menu->add_action(GUI::Action::create("Generic 5x5 &Convolution", g_icon_bag.generic_5x5_convolution, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
if (auto* layer = editor->active_layer()) {
|
||||
@ -1162,11 +1162,11 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
editor->did_complete_action("Generic 5x5 Convolution"sv);
|
||||
}
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"sv), &window)));
|
||||
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));
|
||||
|
||||
m_levels_dialog_action = GUI::Action::create(
|
||||
"Change &Levels...", { Mod_Ctrl, Key_L }, g_icon_bag.levels, [&](auto&) {
|
||||
|
@ -65,11 +65,11 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
||||
return;
|
||||
this->set_file(response.value().filename());
|
||||
});
|
||||
TRY(file_menu->try_add_action(open_action));
|
||||
file_menu->add_action(open_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto presentation_menu = TRY(window->try_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&) {
|
||||
@ -94,9 +94,9 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
||||
this->window()->set_fullscreen(true);
|
||||
});
|
||||
|
||||
TRY(presentation_menu->try_add_action(*m_next_slide_action));
|
||||
TRY(presentation_menu->try_add_action(*m_previous_slide_action));
|
||||
TRY(presentation_menu->try_add_action(*m_present_from_first_slide_action));
|
||||
presentation_menu->add_action(*m_next_slide_action);
|
||||
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));
|
||||
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&) {
|
||||
@ -112,13 +112,13 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
||||
}
|
||||
});
|
||||
|
||||
TRY(view_menu->try_add_action(*m_full_screen_action));
|
||||
TRY(view_menu->try_add_action(*m_resize_to_fit_content_action));
|
||||
view_menu->add_action(*m_full_screen_action);
|
||||
view_menu->add_action(*m_resize_to_fit_content_action);
|
||||
|
||||
update_slides_actions();
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Presenter", GUI::Icon::default_icon("app-presenter"sv))));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Presenter", GUI::Icon::default_icon("app-presenter"sv)));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Settings", app_icon, window)));
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Settings", app_icon, window));
|
||||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
|
@ -61,17 +61,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(window);
|
||||
if (path.has_value()) {
|
||||
player->play_file_path(path.value());
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto playback_menu = TRY(window->try_add_menu("&Playback"_string));
|
||||
GUI::ActionGroup loop_actions;
|
||||
@ -80,13 +80,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
player->set_loop_mode(Player::LoopMode::None);
|
||||
});
|
||||
loop_actions.add_action(loop_none);
|
||||
TRY(playback_menu->try_add_action(loop_none));
|
||||
playback_menu->add_action(loop_none);
|
||||
|
||||
auto loop_file = GUI::Action::create_checkable("Loop &File", { Mod_Ctrl, Key_F }, [&](auto&) {
|
||||
player->set_loop_mode(Player::LoopMode::File);
|
||||
});
|
||||
loop_actions.add_action(loop_file);
|
||||
TRY(playback_menu->try_add_action(loop_file));
|
||||
playback_menu->add_action(loop_file);
|
||||
|
||||
auto loop_playlist = GUI::Action::create_checkable("Loop &Playlist", { Mod_Ctrl, Key_P }, [&](auto&) {
|
||||
player->set_loop_mode(Player::LoopMode::Playlist);
|
||||
@ -98,7 +98,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
static_cast<SoundPlayerWidget*>(player)->set_nonlinear_volume_slider(action.is_checked());
|
||||
});
|
||||
playback_menu->add_separator();
|
||||
TRY(playback_menu->try_add_action(linear_volume_slider));
|
||||
playback_menu->add_action(linear_volume_slider);
|
||||
playback_menu->add_separator();
|
||||
|
||||
auto playlist_toggle = GUI::Action::create_checkable("&Show Playlist", [&](auto& action) {
|
||||
@ -110,7 +110,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
} else {
|
||||
loop_none->set_checked(true);
|
||||
}
|
||||
TRY(playback_menu->try_add_action(playlist_toggle));
|
||||
playback_menu->add_action(playlist_toggle);
|
||||
|
||||
auto shuffle_mode = GUI::Action::create_checkable("S&huffle Playlist", [&](auto& action) {
|
||||
if (action.is_checked())
|
||||
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
else
|
||||
player->set_shuffle_mode(Player::ShuffleMode::None);
|
||||
});
|
||||
TRY(playback_menu->try_add_action(shuffle_mode));
|
||||
playback_menu->add_action(shuffle_mode);
|
||||
|
||||
auto visualization_menu = TRY(window->try_add_menu("&Visualization"_string));
|
||||
GUI::ActionGroup visualization_actions;
|
||||
@ -132,14 +132,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
static_cast<SoundPlayerWidget*>(player)->set_visualization<BarsVisualizationWidget>();
|
||||
set_selected_visualization_in_config("bars"sv);
|
||||
});
|
||||
TRY(visualization_menu->try_add_action(bars));
|
||||
visualization_menu->add_action(bars);
|
||||
visualization_actions.add_action(bars);
|
||||
|
||||
auto samples = GUI::Action::create_checkable("&Samples", [&](auto&) {
|
||||
static_cast<SoundPlayerWidget*>(player)->set_visualization<SampleWidget>();
|
||||
set_selected_visualization_in_config("samples"sv);
|
||||
});
|
||||
TRY(visualization_menu->try_add_action(samples));
|
||||
visualization_menu->add_action(samples);
|
||||
visualization_actions.add_action(samples);
|
||||
|
||||
auto album_cover_visualization = GUI::Action::create_checkable("&Album Cover", [&](auto&) {
|
||||
@ -150,7 +150,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
set_selected_visualization_in_config("album_cover"sv);
|
||||
});
|
||||
TRY(visualization_menu->try_add_action(album_cover_visualization));
|
||||
visualization_menu->add_action(album_cover_visualization);
|
||||
visualization_actions.add_action(album_cover_visualization);
|
||||
|
||||
auto selected_visualization_widget = bars;
|
||||
@ -164,8 +164,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
selected_visualization_widget->set_checked(true);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Sound Player", app_icon, window)));
|
||||
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));
|
||||
|
||||
window->show();
|
||||
return app->exec();
|
||||
|
@ -68,20 +68,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
tree_map_widget.set_focus(true);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::Action::create("&Analyze", { KeyCode::Key_F5 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
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()) {
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
|
||||
}
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window)));
|
||||
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));
|
||||
|
||||
auto open_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv));
|
||||
// Configure the node's context menu.
|
||||
@ -135,9 +135,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
|
||||
auto context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(context_menu->try_add_action(open_action));
|
||||
TRY(context_menu->try_add_action(copy_path_action));
|
||||
TRY(context_menu->try_add_action(delete_action));
|
||||
context_menu->add_action(open_action);
|
||||
context_menu->add_action(copy_path_action);
|
||||
context_menu->add_action(delete_action);
|
||||
|
||||
// Configure event handlers.
|
||||
breadcrumbbar.on_segment_click = [&](size_t index) {
|
||||
|
@ -719,12 +719,12 @@ 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));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(*m_import_action));
|
||||
file_menu->add_action(*m_import_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
if (!request_close())
|
||||
@ -735,21 +735,21 @@ ErrorOr<void> SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
load_file(response.value().filename(), response.value().stream());
|
||||
}));
|
||||
TRY(file_menu->try_add_action(*m_quit_action));
|
||||
file_menu->add_action(*m_quit_action);
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(edit_menu->try_add_action(*m_redo_action));
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_cut_action));
|
||||
TRY(edit_menu->try_add_action(*m_copy_action));
|
||||
TRY(edit_menu->try_add_action(*m_paste_action));
|
||||
TRY(edit_menu->try_add_action(*m_insert_emoji_action));
|
||||
edit_menu->add_action(*m_cut_action);
|
||||
edit_menu->add_action(*m_copy_action);
|
||||
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));
|
||||
TRY(help_menu->try_add_action(*m_search_action));
|
||||
TRY(help_menu->try_add_action(*m_functions_help_action));
|
||||
TRY(help_menu->try_add_action(*m_about_action));
|
||||
help_menu->add_action(*m_search_action);
|
||||
help_menu->add_action(*m_functions_help_action);
|
||||
help_menu->add_action(*m_about_action);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -428,19 +428,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
&process_table_view);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto process_context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(process_context_menu->try_add_action(kill_action));
|
||||
TRY(process_context_menu->try_add_action(stop_action));
|
||||
TRY(process_context_menu->try_add_action(continue_action));
|
||||
process_context_menu->add_action(kill_action);
|
||||
process_context_menu->add_action(stop_action);
|
||||
process_context_menu->add_action(continue_action);
|
||||
process_context_menu->add_separator();
|
||||
TRY(process_context_menu->try_add_action(profile_action));
|
||||
TRY(process_context_menu->try_add_action(debug_action));
|
||||
process_context_menu->add_action(profile_action);
|
||||
process_context_menu->add_action(debug_action);
|
||||
process_context_menu->add_separator();
|
||||
TRY(process_context_menu->try_add_action(process_properties_action));
|
||||
process_context_menu->add_action(process_properties_action);
|
||||
process_table_view.on_context_menu_request = [&]([[maybe_unused]] const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||
if (index.is_valid())
|
||||
process_context_menu->popup(event.screen_position(), process_properties_action);
|
||||
@ -458,7 +458,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
action->set_status_tip(TRY(String::formatted("Refresh every {} seconds", seconds)));
|
||||
action->set_checked(frequency == seconds);
|
||||
frequency_action_group.add_action(*action);
|
||||
TRY(frequency_menu->try_add_action(*action));
|
||||
frequency_menu->add_action(*action);
|
||||
return {};
|
||||
};
|
||||
|
||||
@ -467,8 +467,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
TRY(make_frequency_action(5));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("System Monitor", app_icon, window)));
|
||||
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));
|
||||
|
||||
process_table_view.on_activation = [&](auto&) {
|
||||
if (process_properties_action->is_enabled())
|
||||
|
@ -333,14 +333,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
|
||||
terminal->context_menu().add_separator();
|
||||
TRY(terminal->context_menu().try_add_action(open_settings_action));
|
||||
terminal->context_menu().add_action(open_settings_action);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_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&) {
|
||||
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);
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(file_menu->try_add_action(open_settings_action));
|
||||
file_menu->add_action(open_settings_action);
|
||||
file_menu->add_separator();
|
||||
|
||||
auto tty_has_foreground_process = [&] {
|
||||
@ -378,27 +378,27 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
return GUI::MessageBox::ExecResult::OK;
|
||||
};
|
||||
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
dbgln("Terminal: Quit menu activated!");
|
||||
if (check_terminal_quit() == GUI::MessageBox::ExecResult::OK)
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(terminal->copy_action()));
|
||||
TRY(edit_menu->try_add_action(terminal->paste_action()));
|
||||
edit_menu->add_action(terminal->copy_action());
|
||||
edit_menu->add_action(terminal->paste_action());
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)),
|
||||
edit_menu->add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)),
|
||||
[&](auto&) {
|
||||
find_window->show();
|
||||
find_window->move_to_front();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
view_menu->add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
})));
|
||||
TRY(view_menu->try_add_action(terminal->clear_including_history_action()));
|
||||
}));
|
||||
view_menu->add_action(terminal->clear_including_history_action());
|
||||
|
||||
auto adjust_font_size = [&](float adjustment) {
|
||||
auto& font = terminal->font();
|
||||
@ -411,19 +411,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
};
|
||||
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(GUI::CommonActions::make_zoom_in_action([&](auto&) {
|
||||
view_menu->add_action(GUI::CommonActions::make_zoom_in_action([&](auto&) {
|
||||
adjust_font_size(1);
|
||||
})));
|
||||
TRY(view_menu->try_add_action(GUI::CommonActions::make_zoom_out_action([&](auto&) {
|
||||
}));
|
||||
view_menu->add_action(GUI::CommonActions::make_zoom_out_action([&](auto&) {
|
||||
adjust_font_size(-1);
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Terminal", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Terminal", app_icon, window));
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (check_terminal_quit() == GUI::MessageBox::ExecResult::OK)
|
||||
|
@ -366,12 +366,12 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view()
|
||||
ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(*m_open_folder_action));
|
||||
file_menu->add_action(*m_open_folder_action);
|
||||
file_menu->add_separator();
|
||||
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
@ -390,28 +390,28 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
if (auto result = read_file(response.value().filename(), response.value().stream()); result.is_error())
|
||||
GUI::MessageBox::show(&window, "Unable to open file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
}));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(m_editor->undo_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->redo_action()));
|
||||
edit_menu->add_action(m_editor->undo_action());
|
||||
edit_menu->add_action(m_editor->redo_action());
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(m_editor->cut_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->copy_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->paste_action()));
|
||||
edit_menu->add_action(m_editor->cut_action());
|
||||
edit_menu->add_action(m_editor->copy_action());
|
||||
edit_menu->add_action(m_editor->paste_action());
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(m_editor->insert_emoji_action()));
|
||||
TRY(edit_menu->try_add_action(*m_vim_emulation_setting_action));
|
||||
edit_menu->add_action(m_editor->insert_emoji_action());
|
||||
edit_menu->add_action(*m_vim_emulation_setting_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_find_replace_action));
|
||||
TRY(edit_menu->try_add_action(*m_find_next_action));
|
||||
TRY(edit_menu->try_add_action(*m_find_previous_action));
|
||||
TRY(edit_menu->try_add_action(*m_replace_action));
|
||||
TRY(edit_menu->try_add_action(*m_replace_all_action));
|
||||
edit_menu->add_action(*m_find_replace_action);
|
||||
edit_menu->add_action(*m_find_next_action);
|
||||
edit_menu->add_action(*m_find_previous_action);
|
||||
edit_menu->add_action(*m_replace_action);
|
||||
edit_menu->add_action(*m_replace_all_action);
|
||||
|
||||
m_no_preview_action = GUI::Action::create_checkable(
|
||||
"&No Preview", [this](auto&) {
|
||||
@ -462,13 +462,13 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
auto layout_menu = view_menu->add_submenu("&Layout"_string);
|
||||
TRY(layout_menu->try_add_action(*m_layout_toolbar_action));
|
||||
TRY(layout_menu->try_add_action(*m_layout_statusbar_action));
|
||||
TRY(layout_menu->try_add_action(*m_layout_ruler_action));
|
||||
layout_menu->add_action(*m_layout_toolbar_action);
|
||||
layout_menu->add_action(*m_layout_statusbar_action);
|
||||
layout_menu->add_action(*m_layout_ruler_action);
|
||||
|
||||
view_menu->add_separator();
|
||||
|
||||
TRY(view_menu->try_add_action(GUI::Action::create("Change &Font...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"sv)),
|
||||
view_menu->add_action(GUI::Action::create("Change &Font...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"sv)),
|
||||
[&](auto&) {
|
||||
auto picker = GUI::FontPicker::construct(&window, &m_editor->font(), false);
|
||||
if (picker->exec() == GUI::Dialog::ExecResult::OK) {
|
||||
@ -476,7 +476,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_editor->set_font(picker->font());
|
||||
Config::write_string("TextEditor"sv, "Text"sv, "Font"sv, picker->font()->qualified_name());
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
view_menu->add_separator();
|
||||
|
||||
@ -499,9 +499,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_wrapping_mode_actions.add_action(*m_wrap_anywhere_action);
|
||||
m_wrapping_mode_actions.add_action(*m_wrap_at_words_action);
|
||||
|
||||
TRY(wrapping_mode_menu->try_add_action(*m_no_wrapping_action));
|
||||
TRY(wrapping_mode_menu->try_add_action(*m_wrap_anywhere_action));
|
||||
TRY(wrapping_mode_menu->try_add_action(*m_wrap_at_words_action));
|
||||
wrapping_mode_menu->add_action(*m_no_wrapping_action);
|
||||
wrapping_mode_menu->add_action(*m_wrap_anywhere_action);
|
||||
wrapping_mode_menu->add_action(*m_wrap_at_words_action);
|
||||
|
||||
auto word_wrap = Config::read_string("TextEditor"sv, "View"sv, "WrappingMode"sv, "Words"sv);
|
||||
if (word_wrap == "None") {
|
||||
@ -539,11 +539,11 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_soft_tab_width_actions.add_action(*m_soft_tab_8_width_action);
|
||||
m_soft_tab_width_actions.add_action(*m_soft_tab_16_width_action);
|
||||
|
||||
TRY(soft_tab_width_menu->try_add_action(*m_soft_tab_1_width_action));
|
||||
TRY(soft_tab_width_menu->try_add_action(*m_soft_tab_2_width_action));
|
||||
TRY(soft_tab_width_menu->try_add_action(*m_soft_tab_4_width_action));
|
||||
TRY(soft_tab_width_menu->try_add_action(*m_soft_tab_8_width_action));
|
||||
TRY(soft_tab_width_menu->try_add_action(*m_soft_tab_16_width_action));
|
||||
soft_tab_width_menu->add_action(*m_soft_tab_1_width_action);
|
||||
soft_tab_width_menu->add_action(*m_soft_tab_2_width_action);
|
||||
soft_tab_width_menu->add_action(*m_soft_tab_4_width_action);
|
||||
soft_tab_width_menu->add_action(*m_soft_tab_8_width_action);
|
||||
soft_tab_width_menu->add_action(*m_soft_tab_16_width_action);
|
||||
|
||||
m_soft_tab_4_width_action->set_checked(true);
|
||||
|
||||
@ -560,8 +560,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_visualize_trailing_whitespace_action->set_status_tip("Visualize trailing whitespace"_string);
|
||||
m_visualize_leading_whitespace_action->set_status_tip("Visualize leading whitespace"_string);
|
||||
|
||||
TRY(view_menu->try_add_action(*m_visualize_trailing_whitespace_action));
|
||||
TRY(view_menu->try_add_action(*m_visualize_leading_whitespace_action));
|
||||
view_menu->add_action(*m_visualize_trailing_whitespace_action);
|
||||
view_menu->add_action(*m_visualize_leading_whitespace_action);
|
||||
|
||||
m_cursor_line_highlighting_action = GUI::Action::create_checkable("L&ine Highlighting", [&](auto&) {
|
||||
m_editor->set_cursor_line_highlighting(m_cursor_line_highlighting_action->is_checked());
|
||||
@ -570,7 +570,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_cursor_line_highlighting_action->set_checked(true);
|
||||
m_cursor_line_highlighting_action->set_status_tip("Highlight the current line"_string);
|
||||
|
||||
TRY(view_menu->try_add_action(*m_cursor_line_highlighting_action));
|
||||
view_menu->add_action(*m_cursor_line_highlighting_action);
|
||||
|
||||
m_relative_line_number_action = GUI::Action::create_checkable("R&elative Line Number", [&](auto& action) {
|
||||
m_editor->set_relative_line_number(action.is_checked());
|
||||
@ -583,12 +583,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
|
||||
m_relative_line_number_action->set_status_tip("Set relative line number"_string);
|
||||
|
||||
TRY(view_menu->try_add_action(*m_relative_line_number_action));
|
||||
view_menu->add_action(*m_relative_line_number_action);
|
||||
|
||||
view_menu->add_separator();
|
||||
TRY(view_menu->try_add_action(*m_no_preview_action));
|
||||
TRY(view_menu->try_add_action(*m_markdown_preview_action));
|
||||
TRY(view_menu->try_add_action(*m_html_preview_action));
|
||||
view_menu->add_action(*m_no_preview_action);
|
||||
view_menu->add_action(*m_markdown_preview_action);
|
||||
view_menu->add_action(*m_html_preview_action);
|
||||
m_no_preview_action->set_checked(true);
|
||||
view_menu->add_separator();
|
||||
|
||||
@ -603,127 +603,127 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_plain_text_highlight->set_checked(true);
|
||||
m_statusbar->set_text(1, "Plain Text"_string);
|
||||
syntax_actions.add_action(*m_plain_text_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_plain_text_highlight));
|
||||
syntax_menu->add_action(*m_plain_text_highlight);
|
||||
|
||||
m_cpp_highlight = GUI::Action::create_checkable("&C++", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Cpp::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_cpp_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_cpp_highlight));
|
||||
syntax_menu->add_action(*m_cpp_highlight);
|
||||
|
||||
m_cmake_highlight = GUI::Action::create_checkable("C&Make", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<CMake::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_cmake_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_cmake_highlight));
|
||||
syntax_menu->add_action(*m_cmake_highlight);
|
||||
|
||||
m_cmakecache_highlight = GUI::Action::create_checkable("CM&akeCache", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<CMake::Cache::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_cmakecache_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_cmakecache_highlight));
|
||||
syntax_menu->add_action(*m_cmakecache_highlight);
|
||||
|
||||
m_js_highlight = GUI::Action::create_checkable("&JavaScript", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<JS::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_js_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_js_highlight));
|
||||
syntax_menu->add_action(*m_js_highlight);
|
||||
|
||||
m_css_highlight = GUI::Action::create_checkable("C&SS", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_css_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_css_highlight));
|
||||
syntax_menu->add_action(*m_css_highlight);
|
||||
|
||||
m_html_highlight = GUI::Action::create_checkable("&HTML File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_html_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_html_highlight));
|
||||
syntax_menu->add_action(*m_html_highlight);
|
||||
|
||||
m_git_highlight = GUI::Action::create_checkable("Gi&t Commit", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<GUI::GitCommitSyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_git_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_git_highlight));
|
||||
syntax_menu->add_action(*m_git_highlight);
|
||||
|
||||
m_gml_highlight = GUI::Action::create_checkable("&GML", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<GUI::GML::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_gml_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_gml_highlight));
|
||||
syntax_menu->add_action(*m_gml_highlight);
|
||||
|
||||
m_ini_highlight = GUI::Action::create_checkable("&INI File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<GUI::IniSyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_ini_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_ini_highlight));
|
||||
syntax_menu->add_action(*m_ini_highlight);
|
||||
|
||||
m_markdown_highlight = GUI::Action::create_checkable("Ma&rkdown", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Markdown::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_markdown_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_markdown_highlight));
|
||||
syntax_menu->add_action(*m_markdown_highlight);
|
||||
|
||||
m_shell_highlight = GUI::Action::create_checkable("Sh&ell File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<Shell::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_shell_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_shell_highlight));
|
||||
syntax_menu->add_action(*m_shell_highlight);
|
||||
|
||||
m_sql_highlight = GUI::Action::create_checkable("S&QL File", [&](auto&) {
|
||||
m_editor->set_syntax_highlighter(make<SQL::AST::SyntaxHighlighter>());
|
||||
m_editor->update();
|
||||
});
|
||||
syntax_actions.add_action(*m_sql_highlight);
|
||||
TRY(syntax_menu->try_add_action(*m_sql_highlight));
|
||||
syntax_menu->add_action(*m_sql_highlight);
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Text Editor", GUI::Icon::default_icon("app-text-editor"sv), &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Text Editor", GUI::Icon::default_icon("app-text-editor"sv), &window));
|
||||
|
||||
auto wrapping_statusbar_menu = m_line_column_statusbar_menu->add_submenu("&Wrapping Mode"_string);
|
||||
TRY(wrapping_statusbar_menu->try_add_action(*m_no_wrapping_action));
|
||||
TRY(wrapping_statusbar_menu->try_add_action(*m_wrap_anywhere_action));
|
||||
TRY(wrapping_statusbar_menu->try_add_action(*m_wrap_at_words_action));
|
||||
wrapping_statusbar_menu->add_action(*m_no_wrapping_action);
|
||||
wrapping_statusbar_menu->add_action(*m_wrap_anywhere_action);
|
||||
wrapping_statusbar_menu->add_action(*m_wrap_at_words_action);
|
||||
|
||||
auto tab_width_statusbar_menu = m_line_column_statusbar_menu->add_submenu("&Tab Width"_string);
|
||||
TRY(tab_width_statusbar_menu->try_add_action(*m_soft_tab_1_width_action));
|
||||
TRY(tab_width_statusbar_menu->try_add_action(*m_soft_tab_2_width_action));
|
||||
TRY(tab_width_statusbar_menu->try_add_action(*m_soft_tab_4_width_action));
|
||||
TRY(tab_width_statusbar_menu->try_add_action(*m_soft_tab_8_width_action));
|
||||
TRY(tab_width_statusbar_menu->try_add_action(*m_soft_tab_16_width_action));
|
||||
tab_width_statusbar_menu->add_action(*m_soft_tab_1_width_action);
|
||||
tab_width_statusbar_menu->add_action(*m_soft_tab_2_width_action);
|
||||
tab_width_statusbar_menu->add_action(*m_soft_tab_4_width_action);
|
||||
tab_width_statusbar_menu->add_action(*m_soft_tab_8_width_action);
|
||||
tab_width_statusbar_menu->add_action(*m_soft_tab_16_width_action);
|
||||
|
||||
m_line_column_statusbar_menu->add_separator();
|
||||
TRY(m_line_column_statusbar_menu->try_add_action(*m_cursor_line_highlighting_action));
|
||||
m_line_column_statusbar_menu->add_action(*m_cursor_line_highlighting_action);
|
||||
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_plain_text_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_cpp_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_cmake_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_cmakecache_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_css_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_git_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_gml_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_html_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_ini_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_js_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_markdown_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_shell_highlight));
|
||||
TRY(m_syntax_statusbar_menu->try_add_action(*m_sql_highlight));
|
||||
m_syntax_statusbar_menu->add_action(*m_plain_text_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_cpp_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_cmake_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_cmakecache_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_css_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_git_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_gml_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_html_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_ini_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_js_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_markdown_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_shell_highlight);
|
||||
m_syntax_statusbar_menu->add_action(*m_sql_highlight);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -246,7 +246,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));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
|
||||
return;
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
@ -262,7 +262,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error()));
|
||||
return;
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
|
||||
if (m_path.has_value()) {
|
||||
@ -277,14 +277,14 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
save_to_file(result.value().filename(), result.value().release_stream());
|
||||
}
|
||||
});
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
file_menu->add_action(*m_save_action);
|
||||
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
auto result = FileSystemAccessClient::Client::the().save_file(&window, "Theme", "ini", Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Truncate);
|
||||
if (result.is_error())
|
||||
return;
|
||||
save_to_file(result.value().filename(), result.value().release_stream());
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
@ -300,16 +300,16 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
}
|
||||
}));
|
||||
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
if (request_close() == GUI::Window::CloseRequestDecision::Close)
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(window.try_add_menu(TRY(GUI::CommonMenus::make_accessibility_menu(*m_preview_widget))));
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Theme Editor", GUI::Icon::default_icon("app-theme-editor"sv), &window)));
|
||||
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));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
// File menu
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_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 { "Video Files", { { "mkv", "webm" } } }, GUI::FileTypeFilter::all_files() } },
|
||||
};
|
||||
@ -392,11 +392,11 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
return;
|
||||
|
||||
open_file(response.release_value());
|
||||
})));
|
||||
}));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
window.close();
|
||||
})));
|
||||
}));
|
||||
|
||||
// Playback menu
|
||||
auto playback_menu = TRY(window.try_add_menu("&Playback"_string));
|
||||
@ -404,12 +404,12 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
// FIXME: Maybe seek mode should be in an options dialog instead. The playback menu may get crowded.
|
||||
// For now, leave it here for convenience.
|
||||
m_use_fast_seeking = GUI::Action::create_checkable("&Fast Seeking", [&](auto&) {});
|
||||
TRY(playback_menu->try_add_action(*m_use_fast_seeking));
|
||||
playback_menu->add_action(*m_use_fast_seeking);
|
||||
set_seek_mode(Video::PlaybackManager::DEFAULT_SEEK_MODE);
|
||||
|
||||
// View menu
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(*m_toggle_fullscreen_action));
|
||||
view_menu->add_action(*m_toggle_fullscreen_action);
|
||||
|
||||
auto sizing_mode_menu = view_menu->add_submenu("&Sizing Mode"_string);
|
||||
sizing_mode_menu->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/fit-image-to-view.png"sv)));
|
||||
@ -421,14 +421,14 @@ ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
m_sizing_mode_group->add_action(*m_size_stretch_action);
|
||||
m_sizing_mode_group->add_action(*m_size_fullsize_action);
|
||||
|
||||
TRY(sizing_mode_menu->try_add_action(*m_size_fit_action));
|
||||
TRY(sizing_mode_menu->try_add_action(*m_size_fill_action));
|
||||
TRY(sizing_mode_menu->try_add_action(*m_size_stretch_action));
|
||||
TRY(sizing_mode_menu->try_add_action(*m_size_fullsize_action));
|
||||
sizing_mode_menu->add_action(*m_size_fit_action);
|
||||
sizing_mode_menu->add_action(*m_size_fill_action);
|
||||
sizing_mode_menu->add_action(*m_size_stretch_action);
|
||||
sizing_mode_menu->add_action(*m_size_fullsize_action);
|
||||
|
||||
// Help menu
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Video Player", TRY(GUI::Icon::try_create_default_icon("app-video-player"sv)), &window)));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Video Player", TRY(GUI::Icon::try_create_default_icon("app-video-player"sv)), &window));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
catdog_widget->set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 0);
|
||||
|
||||
auto context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(context_menu->try_add_action(GUI::CommonActions::make_about_action("CatDog Demo", app_icon, window)));
|
||||
context_menu->add_action(GUI::CommonActions::make_about_action("CatDog Demo", app_icon, window));
|
||||
context_menu->add_separator();
|
||||
TRY(context_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
context_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
window->show();
|
||||
window->set_always_on_top();
|
||||
|
@ -85,16 +85,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
show_window_frame_action->set_checked(window_frame_enabled);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(move(show_window_frame_action)));
|
||||
file_menu->add_action(move(show_window_frame_action));
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Eyes Demo", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Eyes Demo", app_icon, window));
|
||||
|
||||
auto eyes_widget = TRY(window->set_main_widget<EyesWidget>(num_eyes, full_rows, extra_columns));
|
||||
eyes_widget->on_context_menu_request = [&](auto& event) {
|
||||
|
@ -198,7 +198,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
window->resize(WIDTH, HEIGHT);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
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));
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
@ -117,7 +117,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
window->resize(WIDTH * 2, HEIGHT * 3);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
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));
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
@ -417,35 +417,35 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto export_submenu = file_menu->add_submenu("&Export"_string);
|
||||
|
||||
TRY(export_submenu->try_add_action(GUI::Action::create("As &BMP...",
|
||||
export_submenu->add_action(GUI::Action::create("As &BMP...",
|
||||
[&](GUI::Action&) {
|
||||
Optional<DeprecatedString> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp");
|
||||
if (!export_path.has_value())
|
||||
return;
|
||||
if (auto result = mandelbrot->export_image(export_path.value(), ImageType::BMP); result.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
|
||||
})));
|
||||
TRY(export_submenu->try_add_action(GUI::Action::create("As &PNG...", { Mod_Ctrl | Mod_Shift, Key_S },
|
||||
}));
|
||||
export_submenu->add_action(GUI::Action::create("As &PNG...", { Mod_Ctrl | Mod_Shift, Key_S },
|
||||
[&](GUI::Action&) {
|
||||
Optional<DeprecatedString> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png");
|
||||
if (!export_path.has_value())
|
||||
return;
|
||||
if (auto result = mandelbrot->export_image(export_path.value(), ImageType::PNG); result.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
|
||||
})));
|
||||
TRY(export_submenu->try_add_action(GUI::Action::create("As &QOI...",
|
||||
}));
|
||||
export_submenu->add_action(GUI::Action::create("As &QOI...",
|
||||
[&](GUI::Action&) {
|
||||
Optional<DeprecatedString> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "qoi");
|
||||
if (!export_path.has_value())
|
||||
return;
|
||||
if (auto result = mandelbrot->export_image(export_path.value(), ImageType::QOI); result.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
|
||||
})));
|
||||
}));
|
||||
|
||||
export_submenu->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv)));
|
||||
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto zoom_in_action = GUI::CommonActions::make_zoom_in_action(
|
||||
[&](auto&) {
|
||||
@ -470,13 +470,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
TRY(view_menu->try_add_action(zoom_in_action));
|
||||
TRY(view_menu->try_add_action(reset_zoom_action));
|
||||
TRY(view_menu->try_add_action(zoom_out_action));
|
||||
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));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Mandelbrot Demo", app_icon, window)));
|
||||
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));
|
||||
|
||||
window->show();
|
||||
window->set_cursor(Gfx::StandardCursor::Zoom);
|
||||
|
@ -82,8 +82,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Screensaver", app_icon, window)));
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Screensaver", app_icon, window));
|
||||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
|
@ -187,9 +187,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
load_file(response.release_value());
|
||||
});
|
||||
|
||||
TRY(file_menu->try_add_action(open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
file_menu->add_action(open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_separator();
|
||||
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
@ -201,21 +201,21 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
load_file(response.release_value());
|
||||
}));
|
||||
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
if (window.on_close_request() == GUI::Window::CloseRequestDecision::Close)
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(m_editor->undo_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->redo_action()));
|
||||
edit_menu->add_action(m_editor->undo_action());
|
||||
edit_menu->add_action(m_editor->redo_action());
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(m_editor->cut_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->copy_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->paste_action()));
|
||||
edit_menu->add_action(m_editor->cut_action());
|
||||
edit_menu->add_action(m_editor->copy_action());
|
||||
edit_menu->add_action(m_editor->paste_action());
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(m_editor->select_all_action()));
|
||||
TRY(edit_menu->try_add_action(m_editor->go_to_line_or_column_action()));
|
||||
edit_menu->add_action(m_editor->select_all_action());
|
||||
edit_menu->add_action(m_editor->go_to_line_or_column_action());
|
||||
edit_menu->add_separator();
|
||||
|
||||
auto format_gml_action = GUI::Action::create("&Format GML", { Mod_Ctrl | Mod_Shift, Key_I }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reformat.png"sv)), [&](auto&) {
|
||||
@ -230,7 +230,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
GUI::MessageBox::Type::Error);
|
||||
}
|
||||
});
|
||||
TRY(edit_menu->try_add_action(format_gml_action));
|
||||
edit_menu->add_action(format_gml_action);
|
||||
|
||||
auto vim_emulation_setting_action = GUI::Action::create_checkable("&Vim Emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [&](auto& action) {
|
||||
if (action.is_checked())
|
||||
@ -239,7 +239,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
m_editor->set_editing_engine(make<GUI::RegularEditingEngine>());
|
||||
});
|
||||
vim_emulation_setting_action->set_checked(false);
|
||||
TRY(edit_menu->try_add_action(vim_emulation_setting_action));
|
||||
edit_menu->add_action(vim_emulation_setting_action);
|
||||
|
||||
auto view_menu = TRY(window.try_add_menu("&View"_string));
|
||||
m_views_group.set_exclusive(true);
|
||||
@ -273,11 +273,11 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
||||
};
|
||||
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("GML Playground", m_icon, &window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("GML Playground", m_icon, &window));
|
||||
|
||||
(void)TRY(m_toolbar->try_add_action(open_action));
|
||||
(void)TRY(m_toolbar->try_add_action(*m_save_action));
|
||||
|
@ -266,7 +266,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
filesystem_events_tree_view->set_model(profile->file_event_model());
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
|
||||
@ -274,13 +274,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
profile->set_inverted(action.is_checked());
|
||||
});
|
||||
invert_action->set_checked(false);
|
||||
TRY(view_menu->try_add_action(invert_action));
|
||||
view_menu->add_action(invert_action);
|
||||
|
||||
auto top_functions_action = GUI::Action::create_checkable("&Top Functions", { Mod_Ctrl, Key_T }, [&](auto& action) {
|
||||
profile->set_show_top_functions(action.is_checked());
|
||||
});
|
||||
top_functions_action->set_checked(false);
|
||||
TRY(view_menu->try_add_action(top_functions_action));
|
||||
view_menu->add_action(top_functions_action);
|
||||
|
||||
auto percent_action = GUI::Action::create_checkable("Show &Percentages", { Mod_Ctrl, Key_P }, [&](auto& action) {
|
||||
profile->set_show_percentages(action.is_checked());
|
||||
@ -289,17 +289,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
source_view->update();
|
||||
});
|
||||
percent_action->set_checked(false);
|
||||
TRY(view_menu->try_add_action(percent_action));
|
||||
view_menu->add_action(percent_action);
|
||||
|
||||
TRY(view_menu->try_add_action(disassembly_action));
|
||||
TRY(view_menu->try_add_action(source_action));
|
||||
view_menu->add_action(disassembly_action);
|
||||
view_menu->add_action(source_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Profiler", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Profiler", app_icon, window));
|
||||
|
||||
window->show();
|
||||
return app->exec();
|
||||
|
@ -302,32 +302,32 @@ ErrorOr<void> MainWidget::setup()
|
||||
ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
|
||||
{
|
||||
auto file_menu = TRY(window->try_add_menu("&File"_string));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
TRY(file_menu->try_add_action(*m_save_all_action));
|
||||
file_menu->add_action(*m_new_action);
|
||||
file_menu->add_action(*m_open_action);
|
||||
file_menu->add_action(*m_save_action);
|
||||
file_menu->add_action(*m_save_as_action);
|
||||
file_menu->add_action(*m_save_all_action);
|
||||
file_menu->add_separator();
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto edit_menu = TRY(window->try_add_menu("&Edit"_string));
|
||||
TRY(edit_menu->try_add_action(*m_copy_action));
|
||||
TRY(edit_menu->try_add_action(*m_cut_action));
|
||||
TRY(edit_menu->try_add_action(*m_paste_action));
|
||||
edit_menu->add_action(*m_copy_action);
|
||||
edit_menu->add_action(*m_cut_action);
|
||||
edit_menu->add_action(*m_paste_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(edit_menu->try_add_action(*m_redo_action));
|
||||
edit_menu->add_action(*m_undo_action);
|
||||
edit_menu->add_action(*m_redo_action);
|
||||
edit_menu->add_separator();
|
||||
TRY(edit_menu->try_add_action(*m_run_script_action));
|
||||
edit_menu->add_action(*m_run_script_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -167,42 +167,42 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
if (undo_stack.is_empty())
|
||||
return;
|
||||
redo_stack.append(game);
|
||||
game = undo_stack.take_last();
|
||||
update();
|
||||
})));
|
||||
}));
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_redo_action([&](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_redo_action([&](auto&) {
|
||||
if (redo_stack.is_empty())
|
||||
return;
|
||||
undo_stack.append(game);
|
||||
game = redo_stack.take_last();
|
||||
update();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
game_menu->add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("2048", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("2048", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -53,12 +53,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("Toggle &Pause", { Mod_None, Key_P }, [&](auto&) {
|
||||
}));
|
||||
game_menu->add_action(GUI::Action::create("Toggle &Pause", { Mod_None, Key_P }, [&](auto&) {
|
||||
game->toggle_pause();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto show_shadow_piece_action = TRY(GUI::Action::try_create_checkable("Show Shadow Piece", GUI::Shortcut {}, [&](auto& action) {
|
||||
game->set_show_shadow_hint(action.is_checked());
|
||||
@ -67,18 +67,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
game->set_show_shadow_hint(Config::read_bool(app_name, app_name, "ShowShadowPiece"sv, true));
|
||||
show_shadow_piece_action->set_checked(game->show_shadow_hint());
|
||||
|
||||
TRY(game_menu->try_add_action(show_shadow_piece_action));
|
||||
game_menu->add_action(show_shadow_piece_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action(title, app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action(title, app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -91,15 +91,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Resign", { Mod_None, Key_F3 }, [&](auto&) {
|
||||
game_menu->add_action(GUI::Action::create("&Resign", { Mod_None, Key_F3 }, [&](auto&) {
|
||||
widget->resign();
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Flip Board", { Mod_Ctrl, Key_F }, [&](auto&) {
|
||||
}));
|
||||
game_menu->add_action(GUI::Action::create("&Flip Board", { Mod_Ctrl, Key_F }, [&](auto&) {
|
||||
widget->flip_board();
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Import PGN...", { Mod_Ctrl, Key_O }, [&](auto&) {
|
||||
game_menu->add_action(GUI::Action::create("&Import PGN...", { Mod_Ctrl, Key_O }, [&](auto&) {
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.allowed_file_types = Vector {
|
||||
GUI::FileTypeFilter { "PGN Files", { { "pgn" } } },
|
||||
@ -114,8 +114,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
dbgln("Failed to import PGN: {}", maybe_error.release_error());
|
||||
else
|
||||
dbgln("Imported PGN file from {}", result.value().filename());
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Export PGN...", { Mod_Ctrl, Key_S }, [&](auto&) {
|
||||
}));
|
||||
game_menu->add_action(GUI::Action::create("&Export PGN...", { Mod_Ctrl, Key_S }, [&](auto&) {
|
||||
auto result = FileSystemAccessClient::Client::the().save_file(window, "Untitled", "pgn");
|
||||
if (result.is_error())
|
||||
return;
|
||||
@ -124,20 +124,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
dbgln("Failed to export PGN: {}", maybe_error.release_error());
|
||||
else
|
||||
dbgln("Exported PGN file to {}", result.value().filename());
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Copy FEN", { Mod_Ctrl, Key_C }, [&](auto&) {
|
||||
}));
|
||||
game_menu->add_action(GUI::Action::create("&Copy FEN", { Mod_Ctrl, Key_C }, [&](auto&) {
|
||||
GUI::Clipboard::the().set_data(widget->get_fen().release_value_but_fixme_should_propagate_errors().bytes());
|
||||
GUI::MessageBox::show(window, "Board state copied to clipboard as FEN."sv, "Copy FEN"sv, GUI::MessageBox::Type::Information);
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
|
||||
TRY(game_menu->try_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_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 (widget->board().game_result() == Chess::Board::Result::NotFinished) {
|
||||
if (widget->resign() < 0)
|
||||
return;
|
||||
}
|
||||
widget->reset();
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
|
||||
auto settings_action = GUI::Action::create(
|
||||
@ -146,7 +146,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
},
|
||||
window);
|
||||
settings_action->set_status_tip("Open the Game Settings for Chess"_string);
|
||||
TRY(game_menu->try_add_action(settings_action));
|
||||
game_menu->add_action(settings_action);
|
||||
|
||||
auto show_available_moves_action = GUI::Action::create_checkable("Show Available Moves", [&](auto& action) {
|
||||
widget->set_show_available_moves(action.is_checked());
|
||||
@ -154,12 +154,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
Config::write_bool("Games"sv, "Chess"sv, "ShowAvailableMoves"sv, action.is_checked());
|
||||
});
|
||||
show_available_moves_action->set_checked(widget->show_available_moves());
|
||||
TRY(game_menu->try_add_action(show_available_moves_action));
|
||||
game_menu->add_action(show_available_moves_action);
|
||||
game_menu->add_separator();
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto engine_menu = TRY(window->try_add_menu("&Engine"_string));
|
||||
|
||||
@ -171,7 +171,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
human_engine_checkbox->set_checked(true);
|
||||
engines_action_group.add_action(human_engine_checkbox);
|
||||
TRY(engine_submenu->try_add_action(human_engine_checkbox));
|
||||
engine_submenu->add_action(human_engine_checkbox);
|
||||
|
||||
for (auto const& engine : engines) {
|
||||
auto action = GUI::Action::create_checkable(engine.name, [&](auto&) {
|
||||
@ -190,15 +190,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
widget->input_engine_move();
|
||||
});
|
||||
engines_action_group.add_action(*action);
|
||||
TRY(engine_submenu->try_add_action(*action));
|
||||
engine_submenu->add_action(*action);
|
||||
}
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Chess", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Chess", app_icon, window));
|
||||
|
||||
window->show();
|
||||
widget->reset();
|
||||
|
@ -52,20 +52,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action(title, app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action(title, app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -56,16 +56,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
};
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Flappy Bug", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Flappy Bug", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -166,26 +166,26 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
game_menu->add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Flood", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Flood", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -134,22 +134,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_add_action(clear_board_action));
|
||||
TRY(game_menu->try_add_action(randomize_cells_action));
|
||||
game_menu->add_action(clear_board_action);
|
||||
game_menu->add_action(randomize_cells_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(toggle_running_action));
|
||||
TRY(game_menu->try_add_action(run_one_generation_action));
|
||||
game_menu->add_action(toggle_running_action);
|
||||
game_menu->add_action(run_one_generation_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Game of Life", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Game of Life", app_icon, window));
|
||||
|
||||
board_widget->on_running_state_change = [&]() {
|
||||
if (board_widget->is_running()) {
|
||||
|
@ -87,23 +87,23 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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);
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(TRY(Cards::make_cards_settings_action(window))));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
game_menu->add_action(TRY(Cards::make_cards_settings_action(window)));
|
||||
game_menu->add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Hearts", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Hearts", app_icon, window));
|
||||
|
||||
window->set_resizable(false);
|
||||
window->resize(Hearts::Game::width, Hearts::Game::height + statusbar.max_height().as_int());
|
||||
|
@ -68,33 +68,33 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game_menu->add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game.reset();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto settings_menu = TRY(window->try_add_menu("&Settings"_string));
|
||||
|
||||
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Word Length...", [&](auto&) {
|
||||
settings_menu->add_action(GUI::Action::create("Set &Word Length...", [&](auto&) {
|
||||
auto word_length = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5);
|
||||
auto result = GUI::InputBox::show_numeric(window, word_length, shortest_word, longest_word, "Word Length"sv);
|
||||
if (!result.is_error() && result.value() == GUI::InputBox::ExecResult::OK) {
|
||||
Config::write_i32("MasterWord"sv, ""sv, "word_length"sv, word_length);
|
||||
game.set_word_length(word_length);
|
||||
}
|
||||
})));
|
||||
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Number of Guesses...", [&](auto&) {
|
||||
}));
|
||||
settings_menu->add_action(GUI::Action::create("Set &Number of Guesses...", [&](auto&) {
|
||||
auto max_guesses = Config::read_i32("MasterWord"sv, ""sv, "max_guesses"sv, 5);
|
||||
auto result = GUI::InputBox::show_numeric(window, max_guesses, 1, 20, "Number of Guesses"sv);
|
||||
if (!result.is_error() && result.value() == GUI::InputBox::ExecResult::OK) {
|
||||
Config::write_i32("MasterWord"sv, ""sv, "max_guesses"sv, max_guesses);
|
||||
game.set_max_guesses(max_guesses);
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
auto toggle_check_guesses = GUI::Action::create_checkable("Check &Guesses in Dictionary", [&](auto& action) {
|
||||
auto checked = action.is_checked();
|
||||
@ -102,7 +102,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
Config::write_bool("MasterWord"sv, ""sv, "check_guesses_in_dictionary"sv, checked);
|
||||
});
|
||||
toggle_check_guesses->set_checked(game.is_checking_guesses());
|
||||
TRY(settings_menu->try_add_action(toggle_check_guesses));
|
||||
settings_menu->add_action(toggle_check_guesses);
|
||||
|
||||
auto theme_menu = TRY(window->try_add_menu("&Theme"_string));
|
||||
auto system_theme_action = GUI::Action::create("&System", [&](auto&) {
|
||||
@ -111,7 +111,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
system_theme_action->set_checkable(true);
|
||||
system_theme_action->set_checked(use_system_theme);
|
||||
TRY(theme_menu->try_add_action(system_theme_action));
|
||||
theme_menu->add_action(system_theme_action);
|
||||
|
||||
auto wordle_theme_action = GUI::Action::create("&Wordle", [&](auto&) {
|
||||
game.set_use_system_theme(false);
|
||||
@ -119,7 +119,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
wordle_theme_action->set_checkable(true);
|
||||
wordle_theme_action->set_checked(!use_system_theme);
|
||||
TRY(theme_menu->try_add_action(wordle_theme_action));
|
||||
theme_menu->add_action(wordle_theme_action);
|
||||
|
||||
GUI::ActionGroup theme_actions;
|
||||
theme_actions.set_exclusive(true);
|
||||
@ -128,11 +128,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
theme_actions.add_action(wordle_theme_action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("MasterWord", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("MasterWord", app_icon, window));
|
||||
|
||||
game.on_message = [&](auto message) {
|
||||
if (!message.has_value())
|
||||
|
@ -60,9 +60,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
}));
|
||||
|
||||
game_menu->add_separator();
|
||||
|
||||
@ -71,12 +71,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
});
|
||||
chord_toggler_action->set_checked(field->is_single_chording());
|
||||
|
||||
TRY(game_menu->try_add_action(*chord_toggler_action));
|
||||
game_menu->add_action(*chord_toggler_action);
|
||||
game_menu->add_separator();
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto difficulty_menu = TRY(window->try_add_menu("&Difficulty"_string));
|
||||
GUI::ActionGroup difficulty_actions;
|
||||
@ -86,28 +86,28 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
field->set_field_difficulty(Field::Difficulty::Beginner);
|
||||
});
|
||||
action->set_checked(field->difficulty() == Field::Difficulty::Beginner);
|
||||
TRY(difficulty_menu->try_add_action(action));
|
||||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
action = GUI::Action::create_checkable("&Intermediate", { Mod_Ctrl, Key_I }, [&](auto&) {
|
||||
field->set_field_difficulty(Field::Difficulty::Intermediate);
|
||||
});
|
||||
action->set_checked(field->difficulty() == Field::Difficulty::Intermediate);
|
||||
TRY(difficulty_menu->try_add_action(action));
|
||||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
action = GUI::Action::create_checkable("&Expert", { Mod_Ctrl, Key_E }, [&](auto&) {
|
||||
field->set_field_difficulty(Field::Difficulty::Expert);
|
||||
});
|
||||
action->set_checked(field->difficulty() == Field::Difficulty::Expert);
|
||||
TRY(difficulty_menu->try_add_action(action));
|
||||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
action = GUI::Action::create_checkable("&Madwoman", { Mod_Ctrl, Key_M }, [&](auto&) {
|
||||
field->set_field_difficulty(Field::Difficulty::Madwoman);
|
||||
});
|
||||
action->set_checked(field->difficulty() == Field::Difficulty::Madwoman);
|
||||
TRY(difficulty_menu->try_add_action(action));
|
||||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
difficulty_menu->add_separator();
|
||||
@ -115,15 +115,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
CustomGameDialog::show(window, field);
|
||||
});
|
||||
action->set_checked(field->difficulty() == Field::Difficulty::Custom);
|
||||
TRY(difficulty_menu->try_add_action(action));
|
||||
difficulty_menu->add_action(action);
|
||||
difficulty_actions.add_action(action);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Minesweeper", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Minesweeper", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -85,14 +85,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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();
|
||||
})));
|
||||
}));
|
||||
static DeprecatedString const pause_text = "&Pause Game"sv;
|
||||
auto const pause_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
static DeprecatedString const continue_text = "&Continue Game"sv;
|
||||
auto const continue_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"sv));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create(pause_text, { Mod_None, Key_Space }, pause_icon, [&](auto& action) {
|
||||
game_menu->add_action(GUI::Action::create(pause_text, { Mod_None, Key_Space }, pause_icon, [&](auto& action) {
|
||||
if (game.has_timer()) {
|
||||
game.pause();
|
||||
action.set_text(continue_text);
|
||||
@ -102,7 +102,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
action.set_text(pause_text);
|
||||
action.set_icon(pause_icon);
|
||||
}
|
||||
})));
|
||||
}));
|
||||
|
||||
auto change_snake_color = GUI::Action::create("&Change Snake Color", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/color-chooser.png"sv)), [&](auto&) {
|
||||
auto was_paused = game.is_paused();
|
||||
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
game.start();
|
||||
});
|
||||
change_snake_color->set_enabled(snake_skin_name == "Classic"sv);
|
||||
TRY(game_menu->try_add_action(change_snake_color));
|
||||
game_menu->add_action(change_snake_color);
|
||||
|
||||
GUI::ActionGroup skin_action_group;
|
||||
skin_action_group.set_exclusive(true);
|
||||
@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
skin_action_group.add_action(*action);
|
||||
if (snake_skin_name == name)
|
||||
action->set_checked(true);
|
||||
TRY(skin_menu->try_add_action(*action));
|
||||
skin_menu->add_action(*action);
|
||||
return {};
|
||||
};
|
||||
|
||||
@ -147,16 +147,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
TRY(add_skin_action("Classic"sv, true));
|
||||
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
}));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
|
||||
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");
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Snake", app_icon, window)));
|
||||
}));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Snake", app_icon, window));
|
||||
|
||||
window->show();
|
||||
|
||||
|
@ -199,34 +199,34 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
|
||||
TRY(game_menu->try_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_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;
|
||||
|
||||
game.setup(mode);
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
auto undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
game.perform_undo();
|
||||
});
|
||||
undo_action->set_enabled(false);
|
||||
TRY(game_menu->try_add_action(undo_action));
|
||||
game_menu->add_action(undo_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(TRY(Cards::make_cards_settings_action(window))));
|
||||
TRY(game_menu->try_add_action(single_card_draw_action));
|
||||
TRY(game_menu->try_add_action(three_card_draw_action));
|
||||
game_menu->add_action(TRY(Cards::make_cards_settings_action(window)));
|
||||
game_menu->add_action(single_card_draw_action);
|
||||
game_menu->add_action(three_card_draw_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(toggle_auto_collect_action));
|
||||
game_menu->add_action(toggle_auto_collect_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window)));
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
help_menu->add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window));
|
||||
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
help_menu->add_action(GUI::CommonActions::make_help_action([&man_file](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help");
|
||||
})));
|
||||
}));
|
||||
|
||||
window->set_resizable(false);
|
||||
window->resize(Solitaire::Game::width, Solitaire::Game::height + statusbar.max_height().as_int());
|
||||
|
@ -236,24 +236,24 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
suit_actions.add_action(two_suit_action);
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"_string));
|
||||
TRY(game_menu->try_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_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;
|
||||
|
||||
game.setup(mode);
|
||||
})));
|
||||
}));
|
||||
game_menu->add_separator();
|
||||
auto undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
game.perform_undo();
|
||||
});
|
||||
undo_action->set_enabled(false);
|
||||
TRY(game_menu->try_add_action(undo_action));
|
||||
game_menu->add_action(undo_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(TRY(Cards::make_cards_settings_action(window))));
|
||||
TRY(game_menu->try_add_action(single_suit_action));
|
||||
TRY(game_menu->try_add_action(two_suit_action));
|
||||
game_menu->add_action(TRY(Cards::make_cards_settings_action(window)));
|
||||
game_menu->add_action(single_suit_action);
|
||||
game_menu->add_action(two_suit_action);
|
||||
game_menu->add_separator();
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
|
||||
game_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto view_menu = TRY(window->try_add_menu("&View"_string));
|
||||
|
||||
@ -274,8 +274,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
best_time_actions->set_checked(statistic_display == StatisticDisplay::BestTime);
|
||||
statistic_display_actions.add_action(best_time_actions);
|
||||
|
||||
TRY(view_menu->try_add_action(high_score_action));
|
||||
TRY(view_menu->try_add_action(best_time_actions));
|
||||
view_menu->add_action(high_score_action);
|
||||
view_menu->add_action(best_time_actions);
|
||||
|
||||
auto help_menu = TRY(window->try_add_menu("&Help"_string));
|
||||
help_menu->add_action(GUI::CommonActions::make_command_palette_action(window));
|
||||
|
@ -50,9 +50,9 @@ ErrorOr<void> LinkLabel::create_actions()
|
||||
ErrorOr<void> LinkLabel::create_menus()
|
||||
{
|
||||
m_context_menu = TRY(Menu::try_create());
|
||||
TRY(m_context_menu->try_add_action(*m_open_action));
|
||||
m_context_menu->add_action(*m_open_action);
|
||||
m_context_menu->add_separator();
|
||||
TRY(m_context_menu->try_add_action(*m_copy_action));
|
||||
m_context_menu->add_action(*m_copy_action);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -48,21 +48,12 @@ void Menu::set_icon(Gfx::Bitmap const* icon)
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
ErrorOr<void> Menu::try_add_action(NonnullRefPtr<Action> action)
|
||||
{
|
||||
// NOTE: We grow the vector first, to get allocation failure handled immediately.
|
||||
TRY(m_items.try_ensure_capacity(m_items.size() + 1));
|
||||
|
||||
auto item = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MenuItem(m_menu_id, move(action))));
|
||||
if (m_menu_id != -1)
|
||||
realize_menu_item(*item, m_items.size());
|
||||
m_items.unchecked_append(move(item));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Menu::add_action(NonnullRefPtr<Action> action)
|
||||
{
|
||||
MUST(try_add_action(move(action)));
|
||||
auto item = make<MenuItem>(m_menu_id, move(action));
|
||||
if (m_menu_id != -1)
|
||||
realize_menu_item(*item, m_items.size());
|
||||
m_items.append(move(item));
|
||||
}
|
||||
|
||||
void Menu::remove_all_actions()
|
||||
@ -250,7 +241,7 @@ ErrorOr<void> Menu::add_recent_files_list(Function<void(Action&)> callback)
|
||||
app->register_recent_file_actions({}, recent_file_actions);
|
||||
|
||||
for (auto& action : recent_file_actions) {
|
||||
TRY(try_add_action(action));
|
||||
add_action(action);
|
||||
}
|
||||
|
||||
add_separator();
|
||||
|
@ -41,8 +41,6 @@ public:
|
||||
|
||||
Action* action_at(size_t);
|
||||
|
||||
ErrorOr<void> try_add_action(NonnullRefPtr<Action>);
|
||||
|
||||
void add_action(NonnullRefPtr<Action>);
|
||||
void add_separator();
|
||||
[[nodiscard]] NonnullRefPtr<Menu> add_submenu(String name);
|
||||
|
@ -255,7 +255,7 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
||||
item->widget->set_visible(false);
|
||||
peek_item = m_items[i + 1];
|
||||
if (item->action)
|
||||
TRY(m_overflow_menu->try_add_action(*item->action));
|
||||
m_overflow_menu->add_action(*item->action);
|
||||
}
|
||||
if (item->action && peek_item->type == Item::Type::Separator)
|
||||
m_overflow_menu->add_separator();
|
||||
|
Loading…
Reference in New Issue
Block a user