From 26eeaef0a8211fd666fa3eaa6b12c1c5fe56b93f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 Apr 2020 12:18:40 +0200 Subject: LibGUI: Add MenuBar::add_menu(name) This allows us to construct menus in a more natural way: auto& file_menu = menubar->add_menu("File"); file_menu.add_action(...); Instead of the old way: auto file_menu = GUI::Menu::construct(); file_menu->add_action(...); menubar->add_menu(file_menu); --- Applications/Help/main.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Applications/Help/main.cpp') diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 0d696e2d4d..1a828c0bf4 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -179,20 +179,18 @@ int main(int argc, char* argv[]) auto menubar = make(); - auto app_menu = GUI::Menu::construct("Help"); - app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& app_menu = menubar->add_menu("Help"); + app_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Help", Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"), window); })); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); - auto go_menu = GUI::Menu::construct("Go"); - go_menu->add_action(*go_back_action); - go_menu->add_action(*go_forward_action); - menubar->add_menu(move(go_menu)); + auto& go_menu = menubar->add_menu("Go"); + go_menu.add_action(*go_back_action); + go_menu.add_action(*go_forward_action); app.set_menubar(move(menubar)); -- cgit v1.2.3