diff options
author | Andreas Kling <kling@serenityos.org> | 2021-07-21 21:21:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-21 21:24:26 +0200 |
commit | 687a12d7fb480cf3586c97e30cdb4f67d7e72da5 (patch) | |
tree | 18075eda4d084c161e935c4d386f6b9f6790a9d1 /Userland/Applications/Spreadsheet | |
parent | a4fdb7f0296379affbf1083a7875d40e1624a067 (diff) | |
download | serenity-687a12d7fb480cf3586c97e30cdb4f67d7e72da5.zip |
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. :^)
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/main.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 305d6a862a..edce7bbdfb 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -85,8 +85,7 @@ int main(int argc, char* argv[]) if (filename) spreadsheet_widget.load(filename); - 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("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) { spreadsheet_widget.add_sheet(); @@ -138,7 +137,7 @@ int main(int argc, char* argv[]) return GUI::Window::CloseRequestDecision::StayOpen; }; - auto& edit_menu = menubar->add_menu("&Edit"); + auto& edit_menu = window->add_menu("&Edit"); auto clipboard_action = [&](bool is_cut) { /// text/x-spreadsheet-data: @@ -228,7 +227,7 @@ int main(int argc, char* argv[]) }, window)); - auto& help_menu = menubar->add_menu("&Help"); + auto& help_menu = window->add_menu("&Help"); help_menu.add_action(GUI::Action::create( "&Functions Help", [&](auto&) { @@ -245,8 +244,6 @@ int main(int argc, char* argv[]) help_menu.add_action(GUI::CommonActions::make_about_action("Spreadsheet", app_icon, window)); - window->set_menubar(move(menubar)); - window->show(); return app->exec(); |