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/SpaceAnalyzer/main.cpp | |
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/SpaceAnalyzer/main.cpp')
-rw-r--r-- | Userland/Applications/SpaceAnalyzer/main.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 052502d6fb..8695e42609 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -271,9 +271,7 @@ int main(int argc, char* argv[]) auto& treemapwidget = *mainwidget.find_descendant_of_type_named<SpaceAnalyzer::TreeMapWidget>("tree_map"); auto& statusbar = *mainwidget.find_descendant_of_type_named<GUI::Statusbar>("statusbar"); - 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("&Analyze", [&](auto&) { analyze(tree, treemapwidget, statusbar); })); @@ -282,11 +280,9 @@ int main(int argc, char* argv[]) 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(APP_NAME, app_icon, window)); - window->set_menubar(move(menubar)); - // Configure the nodes context menu. auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget))); |