1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

Userland: Add GUI::Window::add_menu() and use it everywhere

Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
This commit is contained in:
Andreas Kling 2021-07-21 21:21:03 +02:00
parent a4fdb7f029
commit 687a12d7fb
58 changed files with 187 additions and 311 deletions

View file

@ -60,9 +60,7 @@ int main(int argc, char** argv)
});
main_widget_updater->start();
auto menubar = GUI::Menubar::construct();
auto& file_menu = menubar->add_menu("&File");
auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) {
save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav");
if (!save_path.has_value())
@ -81,13 +79,11 @@ int main(int argc, char** argv)
return;
}));
auto& edit_menu = menubar->add_menu("&Edit");
auto& edit_menu = window->add_menu("&Edit");
main_widget.add_actions(edit_menu);
auto& help_menu = menubar->add_menu("&Help");
auto& help_menu = window->add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Piano", app_icon, window));
window->set_menubar(move(menubar));
return app->exec();
}