mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +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:
parent
a4fdb7f029
commit
687a12d7fb
58 changed files with 187 additions and 311 deletions
|
@ -171,8 +171,7 @@ int main(int argc, char** argv)
|
|||
three_card_draw_action->set_status_tip("Draw three cards at a time");
|
||||
draw_setting_actions.add_action(three_card_draw_action);
|
||||
|
||||
auto menubar = GUI::Menubar::construct();
|
||||
auto& game_menu = menubar->add_menu("&Game");
|
||||
auto& game_menu = window->add_menu("&Game");
|
||||
|
||||
game_menu.add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game.setup(mode);
|
||||
|
@ -189,12 +188,11 @@ int main(int argc, char** argv)
|
|||
game_menu.add_separator();
|
||||
game_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = menubar->add_menu("&Help");
|
||||
auto& help_menu = window->add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window));
|
||||
|
||||
window->set_resizable(false);
|
||||
window->resize(Solitaire::Game::width, Solitaire::Game::height + statusbar.max_height());
|
||||
window->set_menubar(move(menubar));
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
window->show();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue