diff options
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/Browser/main.cpp | 39 | ||||
-rw-r--r-- | Applications/Calculator/main.cpp | 10 | ||||
-rw-r--r-- | Applications/Calendar/main.cpp | 5 | ||||
-rw-r--r-- | Applications/ChanViewer/main.cpp | 10 | ||||
-rw-r--r-- | Applications/DisplayProperties/main.cpp | 11 | ||||
-rw-r--r-- | Applications/FileManager/main.cpp | 46 | ||||
-rw-r--r-- | Applications/FontEditor/main.cpp | 10 | ||||
-rw-r--r-- | Applications/Help/main.cpp | 16 | ||||
-rw-r--r-- | Applications/HexEditor/HexEditorWidget.cpp | 46 | ||||
-rw-r--r-- | Applications/IRCClient/IRCAppWindow.cpp | 62 | ||||
-rw-r--r-- | Applications/PaintBrush/main.cpp | 18 | ||||
-rw-r--r-- | Applications/Piano/main.cpp | 12 | ||||
-rw-r--r-- | Applications/QuickShow/main.cpp | 13 | ||||
-rw-r--r-- | Applications/SoundPlayer/main.cpp | 16 | ||||
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 25 | ||||
-rw-r--r-- | Applications/Terminal/main.cpp | 28 | ||||
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 78 |
17 files changed, 196 insertions, 249 deletions
diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 9380073d37..30f733ced4 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -226,21 +226,20 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Browser"); - app_menu->add_action(GUI::Action::create("Reload", { Mod_None, Key_F5 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), [&](auto&) { + auto& app_menu = menubar->add_menu("Browser"); + app_menu.add_action(GUI::Action::create("Reload", { Mod_None, Key_F5 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), [&](auto&) { TemporaryChange<bool> change(should_push_loads_to_history, false); html_widget.reload(); })); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); - menubar->add_menu(move(app_menu)); RefPtr<GUI::Window> dom_inspector_window; - auto inspect_menu = GUI::Menu::construct("Inspect"); - inspect_menu->add_action(GUI::Action::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) { + auto& inspect_menu = menubar->add_menu("Inspect"); + inspect_menu.add_action(GUI::Action::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) { String filename_to_open; char tmp_filename[] = "/tmp/view-source.XXXXXX"; ASSERT(html_widget.document()); @@ -259,7 +258,7 @@ int main(int argc, char** argv) ASSERT_NOT_REACHED(); } })); - inspect_menu->add_action(GUI::Action::create("Inspect DOM tree", { Mod_None, Key_F12 }, [&](auto&) { + inspect_menu.add_action(GUI::Action::create("Inspect DOM tree", { Mod_None, Key_F12 }, [&](auto&) { if (!dom_inspector_window) { dom_inspector_window = GUI::Window::construct(); dom_inspector_window->set_rect(100, 100, 300, 500); @@ -271,21 +270,20 @@ int main(int argc, char** argv) dom_inspector_window->show(); dom_inspector_window->move_to_front(); })); - menubar->add_menu(move(inspect_menu)); - auto debug_menu = GUI::Menu::construct("Debug"); - debug_menu->add_action(GUI::Action::create("Dump DOM tree", [&](auto&) { + auto& debug_menu = menubar->add_menu("Debug"); + debug_menu.add_action(GUI::Action::create("Dump DOM tree", [&](auto&) { dump_tree(*html_widget.document()); })); - debug_menu->add_action(GUI::Action::create("Dump Layout tree", [&](auto&) { + debug_menu.add_action(GUI::Action::create("Dump Layout tree", [&](auto&) { dump_tree(*html_widget.document()->layout_node()); })); - debug_menu->add_action(GUI::Action::create("Dump Style sheets", [&](auto&) { + debug_menu.add_action(GUI::Action::create("Dump Style sheets", [&](auto&) { for (auto& sheet : html_widget.document()->stylesheets()) { dump_sheet(sheet); } })); - debug_menu->add_separator(); + debug_menu.add_separator(); auto line_box_borders_action = GUI::Action::create("Line box borders", [&](auto& action) { action.set_checked(!action.is_checked()); html_widget.set_should_show_line_box_borders(action.is_checked()); @@ -293,10 +291,9 @@ int main(int argc, char** argv) }); line_box_borders_action->set_checkable(true); line_box_borders_action->set_checked(false); - debug_menu->add_action(line_box_borders_action); - menubar->add_menu(move(debug_menu)); + debug_menu.add_action(line_box_borders_action); - auto bookmarks_menu = GUI::Menu::construct("Bookmarks"); + auto& bookmarks_menu = menubar->add_menu("Bookmarks"); auto show_bookmarksbar_action = GUI::Action::create("Show bookmarks bar", [&](auto& action) { action.set_checked(!action.is_checked()); bookmarksbar.set_visible(action.is_checked()); @@ -304,14 +301,12 @@ int main(int argc, char** argv) }); show_bookmarksbar_action->set_checkable(true); show_bookmarksbar_action->set_checked(bookmarksbar_enabled); - bookmarks_menu->add_action(show_bookmarksbar_action); - menubar->add_menu(move(bookmarks_menu)); + bookmarks_menu.add_action(show_bookmarksbar_action); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Browser", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index 772564f4a4..e8a06f2677 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -67,18 +67,16 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Calculator"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("Calculator"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Calculator", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calculator.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/Calendar/main.cpp b/Applications/Calendar/main.cpp index d1a2ef7d64..769cb33d53 100644 --- a/Applications/Calendar/main.cpp +++ b/Applications/Calendar/main.cpp @@ -66,12 +66,11 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Calendar"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("Calendar"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); app.set_menubar(move(menubar)); app.exec(); diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp index 6f4f1fb981..c950eefcb9 100644 --- a/Applications/ChanViewer/main.cpp +++ b/Applications/ChanViewer/main.cpp @@ -94,18 +94,16 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("ChanViewer"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("ChanViewer"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("ChanViewer", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-chanviewer.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/DisplayProperties/main.cpp b/Applications/DisplayProperties/main.cpp index fef9f35eec..2e064ef54b 100644 --- a/Applications/DisplayProperties/main.cpp +++ b/Applications/DisplayProperties/main.cpp @@ -60,20 +60,17 @@ int main(int argc, char** argv) window->set_main_widget(instance.root_widget()); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-display-properties.png")); - // Let's create the menubar first auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Display Properties"); - app_menu->add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) { + auto& app_menu = menubar->add_menu("Display Properties"); + app_menu.add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) { app.quit(); })); - menubar->add_menu(move(app_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Display Properties", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-display-properties.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); window->show(); diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 0372b9e4d7..b74b17ecc0 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -457,35 +457,31 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("File Manager"); - app_menu->add_action(mkdir_action); - app_menu->add_action(copy_action); - app_menu->add_action(paste_action); - app_menu->add_action(delete_action); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("File Manager"); + app_menu.add_action(mkdir_action); + app_menu.add_action(copy_action); + app_menu.add_action(paste_action); + app_menu.add_action(delete_action); + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); - - auto view_menu = GUI::Menu::construct("View"); - view_menu->add_action(*view_as_icons_action); - view_menu->add_action(*view_as_table_action); - view_menu->add_action(*view_as_columns_action); - menubar->add_menu(move(view_menu)); - - auto go_menu = GUI::Menu::construct("Go"); - go_menu->add_action(go_back_action); - go_menu->add_action(go_forward_action); - go_menu->add_action(open_parent_directory_action); - go_menu->add_action(go_home_action); - menubar->add_menu(move(go_menu)); - - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + + auto& view_menu = menubar->add_menu("View"); + view_menu.add_action(*view_as_icons_action); + view_menu.add_action(*view_as_table_action); + view_menu.add_action(*view_as_columns_action); + + auto& go_menu = menubar->add_menu("Go"); + go_menu.add_action(go_back_action); + go_menu.add_action(go_forward_action); + go_menu.add_action(open_parent_directory_action); + go_menu.add_action(go_home_action); + + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](auto&) { GUI::AboutDialog::show("File Manager", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-folder.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 92db3e2fc0..da5f4a3850 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -76,18 +76,16 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Font Editor"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("Font Editor"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Font Editor", Gfx::Bitmap::load_from_file("/res/icons/FontEditor.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 0d696e2d4d..1a828c0bf4 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -179,20 +179,18 @@ int main(int argc, char* argv[]) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Help"); - app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& app_menu = menubar->add_menu("Help"); + app_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Help", Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"), window); })); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); - auto go_menu = GUI::Menu::construct("Go"); - go_menu->add_action(*go_back_action); - go_menu->add_action(*go_forward_action); - menubar->add_menu(move(go_menu)); + auto& go_menu = menubar->add_menu("Go"); + go_menu.add_action(*go_back_action); + go_menu.add_action(*go_forward_action); app.set_menubar(move(menubar)); diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp index c6b9dd500f..0102820adc 100644 --- a/Applications/HexEditor/HexEditorWidget.cpp +++ b/Applications/HexEditor/HexEditorWidget.cpp @@ -133,18 +133,17 @@ HexEditorWidget::HexEditorWidget() }); auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Hex Editor"); - app_menu->add_action(*m_new_action); - app_menu->add_action(*m_open_action); - app_menu->add_action(*m_save_action); - app_menu->add_action(*m_save_as_action); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { + auto& app_menu = menubar->add_menu("Hex Editor"); + app_menu.add_action(*m_new_action); + app_menu.add_action(*m_open_action); + app_menu.add_action(*m_save_action); + app_menu.add_action(*m_save_as_action); + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); auto bytes_per_row_menu = GUI::Menu::construct("Bytes Per Row"); for (int i = 8; i <= 32; i += 8) { @@ -173,39 +172,36 @@ HexEditorWidget::HexEditorWidget() } }); - auto edit_menu = GUI::Menu::construct("Edit"); - edit_menu->add_action(GUI::Action::create("Fill selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { + auto& edit_menu = menubar->add_menu("Edit"); + edit_menu.add_action(GUI::Action::create("Fill selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { auto input_box = GUI::InputBox::construct("Fill byte (hex):", "Fill Selection", window()); if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto fill_byte = strtol(input_box->text_value().characters(), nullptr, 16); m_editor->fill_selection(fill_byte); } })); - edit_menu->add_separator(); - edit_menu->add_action(*m_goto_decimal_offset_action); - edit_menu->add_action(*m_goto_hex_offset_action); - edit_menu->add_separator(); - edit_menu->add_action(GUI::Action::create("Copy Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) { + edit_menu.add_separator(); + edit_menu.add_action(*m_goto_decimal_offset_action); + edit_menu.add_action(*m_goto_hex_offset_action); + edit_menu.add_separator(); + edit_menu.add_action(GUI::Action::create("Copy Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard(); })); - edit_menu->add_action(GUI::Action::create("Copy Text", { Mod_Ctrl | Mod_Shift, Key_C }, [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Copy Text", { Mod_Ctrl | Mod_Shift, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_text_to_clipboard(); })); - edit_menu->add_separator(); - edit_menu->add_action(GUI::Action::create("Copy As C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) { + edit_menu.add_separator(); + edit_menu.add_action(GUI::Action::create("Copy As C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard_as_c_code(); })); - menubar->add_menu(move(edit_menu)); - auto view_menu = GUI::Menu::construct("View"); - view_menu->add_submenu(move(bytes_per_row_menu)); - menubar->add_menu(move(view_menu)); + auto& view_menu = menubar->add_menu("View"); + view_menu.add_submenu(move(bytes_per_row_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](auto&) { GUI::AboutDialog::show("Hex Editor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hexeditor.png"), window()); })); - menubar->add_menu(move(help_menu)); GUI::Application::the().set_menubar(move(menubar)); diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index 438cae86b9..01a08d06d7 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -232,45 +232,41 @@ void IRCAppWindow::setup_actions() void IRCAppWindow::setup_menus() { auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("IRC Client"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("IRC Client"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - - auto server_menu = GUI::Menu::construct("Server"); - server_menu->add_action(*m_change_nick_action); - server_menu->add_separator(); - server_menu->add_action(*m_join_action); - server_menu->add_action(*m_list_channels_action); - server_menu->add_separator(); - server_menu->add_action(*m_whois_action); - server_menu->add_action(*m_open_query_action); - server_menu->add_action(*m_close_query_action); - menubar->add_menu(move(server_menu)); - - auto channel_menu = GUI::Menu::construct("Channel"); - channel_menu->add_action(*m_change_topic_action); - channel_menu->add_action(*m_invite_user_action); - channel_menu->add_separator(); - channel_menu->add_action(*m_voice_user_action); - channel_menu->add_action(*m_devoice_user_action); - channel_menu->add_action(*m_op_user_action); - channel_menu->add_action(*m_deop_user_action); - channel_menu->add_separator(); - channel_menu->add_action(*m_kick_user_action); - channel_menu->add_separator(); - channel_menu->add_action(*m_cycle_channel_action); - channel_menu->add_action(*m_part_action); - menubar->add_menu(move(channel_menu)); - - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [this](const GUI::Action&) { + + auto& server_menu = menubar->add_menu("Server"); + server_menu.add_action(*m_change_nick_action); + server_menu.add_separator(); + server_menu.add_action(*m_join_action); + server_menu.add_action(*m_list_channels_action); + server_menu.add_separator(); + server_menu.add_action(*m_whois_action); + server_menu.add_action(*m_open_query_action); + server_menu.add_action(*m_close_query_action); + + auto& channel_menu = menubar->add_menu("Channel"); + channel_menu.add_action(*m_change_topic_action); + channel_menu.add_action(*m_invite_user_action); + channel_menu.add_separator(); + channel_menu.add_action(*m_voice_user_action); + channel_menu.add_action(*m_devoice_user_action); + channel_menu.add_action(*m_op_user_action); + channel_menu.add_action(*m_deop_user_action); + channel_menu.add_separator(); + channel_menu.add_action(*m_kick_user_action); + channel_menu.add_separator(); + channel_menu.add_action(*m_cycle_channel_action); + channel_menu.add_action(*m_part_action); + + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [this](auto&) { GUI::AboutDialog::show("IRC Client", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-irc-client.png"), this); })); - menubar->add_menu(move(help_menu)); GUI::Application::the().set_menubar(move(menubar)); } diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index dc730fbbcf..52b284413d 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -75,9 +75,9 @@ int main(int argc, char** argv) window->show(); auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("PaintBrush"); + auto& app_menu = menubar->add_menu("PaintBrush"); - app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { + app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { Optional<String> open_path = GUI::FilePicker::get_open_filepath(); if (!open_path.has_value()) @@ -90,22 +90,18 @@ int main(int argc, char** argv) } paintable_widget.set_bitmap(*bitmap); })); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); + menubar->add_menu("Edit"); - auto edit_menu = GUI::Menu::construct("Edit"); - menubar->add_menu(move(edit_menu)); - - 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("PaintBrush", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-paintbrush.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index 9c396909a6..dc84893bae 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -94,12 +94,12 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Piano"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("Piano"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - app_menu->add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) { + app_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) { save_path = GUI::FilePicker::get_save_filepath("Untitled", "wav"); if (!save_path.has_value()) return; @@ -111,13 +111,11 @@ int main(int argc, char** argv) } need_to_write_wav = true; })); - menubar->add_menu(move(app_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Piano", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-piano.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index f5d6a34719..6b36549494 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -51,21 +51,18 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("QuickShow"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("QuickShow"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - auto file_menu = GUI::Menu::construct("File"); - menubar->add_menu(move(file_menu)); + menubar->add_menu("File"); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [](const GUI::Action&) { dbgprintf("FIXME: Implement Help/About\n"); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); 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(); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 42524dbc42..301354a039 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -175,18 +175,16 @@ int main(int argc, char** argv) toolbar.add_action(continue_action); auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("System Monitor"); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + auto& app_menu = menubar->add_menu("System Monitor"); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); return; })); - menubar->add_menu(move(app_menu)); - auto process_menu = GUI::Menu::construct("Process"); - process_menu->add_action(kill_action); - process_menu->add_action(stop_action); - process_menu->add_action(continue_action); - menubar->add_menu(move(process_menu)); + auto& process_menu = menubar->add_menu("Process"); + process_menu.add_action(kill_action); + process_menu.add_action(stop_action); + process_menu.add_action(continue_action); auto process_context_menu = GUI::Menu::construct(); process_context_menu->add_action(kill_action); @@ -197,7 +195,7 @@ int main(int argc, char** argv) process_context_menu->popup(event.screen_position()); }; - auto frequency_menu = GUI::Menu::construct("Frequency"); + auto& frequency_menu = menubar->add_menu("Frequency"); GUI::ActionGroup frequency_action_group; frequency_action_group.set_exclusive(true); @@ -209,7 +207,7 @@ int main(int argc, char** argv) action->set_checkable(true); action->set_checked(checked); frequency_action_group.add_action(*action); - frequency_menu->add_action(*action); + frequency_menu.add_action(*action); }; make_frequency_action("0.25 sec", 250); @@ -218,13 +216,10 @@ int main(int argc, char** argv) make_frequency_action("3 sec", 3000); make_frequency_action("5 sec", 5000); - menubar->add_menu(move(frequency_menu)); - - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("System Monitor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-system-monitor.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 162836affe..31e5f48c27 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -246,14 +246,14 @@ int main(int argc, char** argv) auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Terminal"); - app_menu->add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { + auto& app_menu = menubar->add_menu("Terminal"); + app_menu.add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { if (!fork()) { execl("/bin/Terminal", "Terminal", nullptr); exit(1); } })); - app_menu->add_action(GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/gear16.png"), + app_menu.add_action(GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/gear16.png"), [&](const GUI::Action&) { if (!settings_window) { settings_window = create_settings_window(terminal); @@ -265,21 +265,19 @@ int main(int argc, char** argv) settings_window->show(); settings_window->move_to_front(); })); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); - auto edit_menu = GUI::Menu::construct("Edit"); - edit_menu->add_action(terminal.copy_action()); - edit_menu->add_action(terminal.paste_action()); - menubar->add_menu(move(edit_menu)); + auto& edit_menu = menubar->add_menu("Edit"); + edit_menu.add_action(terminal.copy_action()); + edit_menu.add_action(terminal.paste_action()); GUI::ActionGroup font_action_group; font_action_group.set_exclusive(true); - auto font_menu = GUI::Menu::construct("Font"); + auto& font_menu = menubar->add_menu("Font"); GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { auto action = GUI::Action::create(font_name, [&](GUI::Action& action) { action.set_checked(true); @@ -294,15 +292,13 @@ int main(int argc, char** argv) action->set_checkable(true); if (terminal.font().name() == font_name) action->set_checked(true); - font_menu->add_action(*action); + font_menu.add_action(*action); }); - menubar->add_menu(move(font_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](auto&) { GUI::AboutDialog::show("Terminal", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-terminal.png"), window); })); - menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 38d510bd6a..8e3f2201c2 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -342,39 +342,37 @@ TextEditorWidget::TextEditorWidget() m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled()); auto menubar = make<GUI::MenuBar>(); - auto app_menu = GUI::Menu::construct("Text Editor"); - app_menu->add_action(*m_new_action); - app_menu->add_action(*m_open_action); - app_menu->add_action(*m_save_action); - app_menu->add_action(*m_save_as_action); - app_menu->add_separator(); - app_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { + auto& app_menu = menubar->add_menu("Text Editor"); + app_menu.add_action(*m_new_action); + app_menu.add_action(*m_open_action); + app_menu.add_action(*m_save_action); + app_menu.add_action(*m_save_as_action); + app_menu.add_separator(); + app_menu.add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; GUI::Application::the().quit(0); })); - menubar->add_menu(move(app_menu)); - - auto edit_menu = GUI::Menu::construct("Edit"); - edit_menu->add_action(m_editor->undo_action()); - edit_menu->add_action(m_editor->redo_action()); - edit_menu->add_separator(); - edit_menu->add_action(m_editor->cut_action()); - edit_menu->add_action(m_editor->copy_action()); - edit_menu->add_action(m_editor->paste_action()); - edit_menu->add_action(m_editor->delete_action()); - edit_menu->add_separator(); - edit_menu->add_action(*m_find_replace_action); - edit_menu->add_action(*m_find_next_action); - edit_menu->add_action(*m_find_previous_action); - edit_menu->add_action(*m_replace_next_action); - edit_menu->add_action(*m_replace_previous_action); - edit_menu->add_action(*m_replace_all_action); - menubar->add_menu(move(edit_menu)); - - auto font_menu = GUI::Menu::construct("Font"); + + auto& edit_menu = menubar->add_menu("Edit"); + edit_menu.add_action(m_editor->undo_action()); + edit_menu.add_action(m_editor->redo_action()); + edit_menu.add_separator(); + edit_menu.add_action(m_editor->cut_action()); + edit_menu.add_action(m_editor->copy_action()); + edit_menu.add_action(m_editor->paste_action()); + edit_menu.add_action(m_editor->delete_action()); + edit_menu.add_separator(); + edit_menu.add_action(*m_find_replace_action); + edit_menu.add_action(*m_find_next_action); + edit_menu.add_action(*m_find_previous_action); + edit_menu.add_action(*m_replace_next_action); + edit_menu.add_action(*m_replace_previous_action); + edit_menu.add_action(*m_replace_all_action); + + auto& font_menu = menubar->add_menu("Font"); GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { - font_menu->add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) { + font_menu.add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) { m_editor->set_font(GUI::FontDatabase::the().get_by_name(action.text())); m_editor->update(); })); @@ -383,7 +381,7 @@ TextEditorWidget::TextEditorWidget() syntax_actions = GUI::ActionGroup {}; syntax_actions.set_exclusive(true); - auto syntax_menu = GUI::Menu::construct("Syntax"); + auto& syntax_menu = menubar->add_menu("Syntax"); m_plain_text_highlight = GUI::Action::create("Plain Text", [&](GUI::Action& action) { action.set_checked(true); m_editor->set_syntax_highlighter(nullptr); @@ -392,7 +390,7 @@ TextEditorWidget::TextEditorWidget() m_plain_text_highlight->set_checkable(true); m_plain_text_highlight->set_checked(true); syntax_actions.add_action(*m_plain_text_highlight); - syntax_menu->add_action(*m_plain_text_highlight); + syntax_menu.add_action(*m_plain_text_highlight); m_cpp_highlight = GUI::Action::create("C++", [&](GUI::Action& action) { action.set_checked(true); @@ -401,7 +399,7 @@ TextEditorWidget::TextEditorWidget() }); m_cpp_highlight->set_checkable(true); syntax_actions.add_action(*m_cpp_highlight); - syntax_menu->add_action(*m_cpp_highlight); + syntax_menu.add_action(*m_cpp_highlight); m_js_highlight = GUI::Action::create("Javascript", [&](GUI::Action& action) { action.set_checked(true); @@ -410,20 +408,18 @@ TextEditorWidget::TextEditorWidget() }); m_js_highlight->set_checkable(true); syntax_actions.add_action(*m_js_highlight); - syntax_menu->add_action(*m_js_highlight); + syntax_menu.add_action(*m_js_highlight); - auto view_menu = GUI::Menu::construct("View"); - view_menu->add_action(*m_line_wrapping_setting_action); - view_menu->add_separator(); - view_menu->add_submenu(move(font_menu)); - view_menu->add_submenu(move(syntax_menu)); - menubar->add_menu(move(view_menu)); + auto& view_menu = menubar->add_menu("View"); + view_menu.add_action(*m_line_wrapping_setting_action); + view_menu.add_separator(); + view_menu.add_submenu(move(font_menu)); + view_menu.add_submenu(move(syntax_menu)); - auto help_menu = GUI::Menu::construct("Help"); - help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::Action::create("About", [&](auto&) { GUI::AboutDialog::show("Text Editor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-texteditor.png"), window()); })); - menubar->add_menu(move(help_menu)); GUI::Application::the().set_menubar(move(menubar)); |