summaryrefslogtreecommitdiff
path: root/Applications/SoundPlayer
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-04 12:18:40 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-04 12:58:05 +0200
commit26eeaef0a8211fd666fa3eaa6b12c1c5fe56b93f (patch)
treed2ea5c324e86332b35e35dcab951d6894d36e5f4 /Applications/SoundPlayer
parentfaac43597a6fcf6ea477bcfa883931d928c56f32 (diff)
downloadserenity-26eeaef0a8211fd666fa3eaa6b12c1c5fe56b93f.zip
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);
Diffstat (limited to 'Applications/SoundPlayer')
-rw-r--r--Applications/SoundPlayer/main.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp
index 085c7a650e..75d558693c 100644
--- a/Applications/SoundPlayer/main.cpp
+++ b/Applications/SoundPlayer/main.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv)
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-sound-player.png"));
auto menubar = make<GUI::MenuBar>();
- auto app_menu = GUI::Menu::construct("SoundPlayer");
+ auto& app_menu = menubar->add_menu("SoundPlayer");
auto& player = window->set_main_widget<SoundPlayerWidget>(window, audio_client);
if (argc > 1) {
@@ -80,25 +80,23 @@ int main(int argc, char** argv)
});
hide_scope->set_checkable(true);
- app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) {
+ app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
Optional<String> path = GUI::FilePicker::get_open_filepath("Open wav file...");
if (path.has_value()) {
player.open_file(path.value());
}
}));
- app_menu->add_action(move(hide_scope));
- app_menu->add_separator();
- app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
+ app_menu.add_action(move(hide_scope));
+ app_menu.add_separator();
+ app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
app.quit();
}));
- auto help_menu = GUI::Menu::construct("Help");
- help_menu->add_action(GUI::Action::create("About", [&](auto&) {
+ auto& help_menu = menubar->add_menu("Help");
+ help_menu.add_action(GUI::Action::create("About", [&](auto&) {
GUI::AboutDialog::show("SoundPlayer", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-sound-player.png"), window);
}));
- menubar->add_menu(move(app_menu));
- menubar->add_menu(move(help_menu));
app.set_menubar(move(menubar));
window->show();