summaryrefslogtreecommitdiff
path: root/Userland/Demos/Cube
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-21 21:21:03 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-21 21:24:26 +0200
commit687a12d7fb480cf3586c97e30cdb4f67d7e72da5 (patch)
tree18075eda4d084c161e935c4d386f6b9f6790a9d1 /Userland/Demos/Cube
parenta4fdb7f0296379affbf1083a7875d40e1624a067 (diff)
downloadserenity-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/Demos/Cube')
-rw-r--r--Userland/Demos/Cube/Cube.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp
index 84cad9d5a7..199511caa8 100644
--- a/Userland/Demos/Cube/Cube.cpp
+++ b/Userland/Demos/Cube/Cube.cpp
@@ -241,8 +241,7 @@ int main(int argc, char** argv)
auto app_icon = GUI::Icon::default_icon("app-cube");
window->set_icon(app_icon.bitmap_for_size(16));
- auto menubar = GUI::Menubar::construct();
- auto& file_menu = menubar->add_menu("&File");
+ auto& file_menu = window->add_menu("&File");
auto show_window_frame_action = GUI::Action::create_checkable("Show Window &Frame", [&](auto& action) {
cube.set_show_window_frame(action.is_checked());
});
@@ -252,9 +251,8 @@ int main(int argc, char** argv)
file_menu.add_action(move(show_window_frame_action));
file_menu.add_separator();
file_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("Cube Demo", app_icon, window));
- window->set_menubar(move(menubar));
cube.on_context_menu_request = [&](auto& event) {
file_menu.popup(event.screen_position());