mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 07:45:07 +00:00
LibGUI: Add MenuBar::add_menu(name)
This allows us to construct menus in a more natural way: auto& file_menu = menubar->add_menu("File"); file_menu.add_action(...); Instead of the old way: auto file_menu = GUI::Menu::construct(); file_menu->add_action(...); menubar->add_menu(file_menu);
This commit is contained in:
parent
faac43597a
commit
26eeaef0a8
26 changed files with 261 additions and 331 deletions
|
@ -69,19 +69,16 @@ int main(int argc, char** argv)
|
|||
tree_view.set_model(profile->model());
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
auto app_menu = GUI::Menu::construct("ProfileViewer");
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
||||
auto& app_menu = menubar->add_menu("ProfileViewer");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
||||
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto view_menu = GUI::Menu::construct("View");
|
||||
auto& view_menu = menubar->add_menu("View");
|
||||
auto invert_action = GUI::Action::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
|
||||
action.set_checked(!action.is_checked());
|
||||
profile->set_inverted(action.is_checked());
|
||||
});
|
||||
invert_action->set_checkable(true);
|
||||
invert_action->set_checked(false);
|
||||
view_menu->add_action(invert_action);
|
||||
|
||||
auto percent_action = GUI::Action::create("Show percentages", { Mod_Ctrl, Key_P }, [&](auto& action) {
|
||||
action.set_checked(!action.is_checked());
|
||||
|
@ -90,9 +87,7 @@ int main(int argc, char** argv)
|
|||
});
|
||||
percent_action->set_checkable(true);
|
||||
percent_action->set_checked(false);
|
||||
view_menu->add_action(percent_action);
|
||||
|
||||
menubar->add_menu(move(view_menu));
|
||||
view_menu.add_action(percent_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue