From fd5eb79d1959cbd4b43f624e3e0779e5dd5e0f17 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 9 Dec 2019 21:05:28 +0100 Subject: [PATCH] LibGUI: Make GMenu inherit from CObject This is primarily to make it possible to pass a GMenu* where a CObject* is expected. --- Applications/Browser/main.cpp | 8 ++++---- Applications/FileManager/main.cpp | 14 +++++++------- Applications/Help/main.cpp | 4 ++-- Applications/HexEditor/HexEditorWidget.cpp | 10 +++++----- Applications/IRCClient/IRCAppWindow.cpp | 6 +++--- Applications/PaintBrush/EraseTool.cpp | 2 +- Applications/PaintBrush/EraseTool.h | 2 +- Applications/PaintBrush/LineTool.cpp | 2 +- Applications/PaintBrush/LineTool.h | 2 +- Applications/PaintBrush/PenTool.cpp | 2 +- Applications/PaintBrush/PenTool.h | 2 +- Applications/PaintBrush/SprayTool.cpp | 2 +- Applications/PaintBrush/SprayTool.h | 2 +- Applications/PaintBrush/main.cpp | 6 +++--- Applications/Piano/main.cpp | 2 +- Applications/QuickShow/main.cpp | 6 +++--- Applications/SoundPlayer/main.cpp | 4 ++-- Applications/SystemMonitor/main.cpp | 10 +++++----- Applications/Terminal/main.cpp | 8 ++++---- Applications/TextEditor/TextEditorWidget.cpp | 10 +++++----- DevTools/HackStudio/main.cpp | 12 ++++++------ DevTools/VisualBuilder/VBForm.cpp | 2 +- DevTools/VisualBuilder/VBForm.h | 2 +- DevTools/VisualBuilder/main.cpp | 6 +++--- Games/Minesweeper/main.cpp | 6 +++--- Games/Snake/main.cpp | 4 ++-- Libraries/LibGUI/GMenu.cpp | 2 +- Libraries/LibGUI/GMenu.h | 8 +++++--- Libraries/LibGUI/GMenuBar.cpp | 2 +- Libraries/LibGUI/GMenuBar.h | 4 ++-- Libraries/LibGUI/GMenuItem.cpp | 2 +- Libraries/LibGUI/GMenuItem.h | 4 ++-- Libraries/LibGUI/GTableView.cpp | 2 +- Libraries/LibGUI/GTableView.h | 2 +- Libraries/LibGUI/GTextEditor.cpp | 2 +- Libraries/LibGUI/GTextEditor.h | 2 +- Libraries/LibVT/TerminalWidget.cpp | 2 +- Libraries/LibVT/TerminalWidget.h | 2 +- Userland/html.cpp | 4 ++-- 39 files changed, 88 insertions(+), 86 deletions(-) diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 5f3c463aa01..b60252544d2 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -126,7 +126,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("Browser"); + auto app_menu = GMenu::construct("Browser"); app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); })); @@ -135,7 +135,7 @@ int main(int argc, char** argv) RefPtr dom_inspector_window; RefPtr dom_tree_view; - auto inspect_menu = make("Inspect"); + auto inspect_menu = GMenu::construct("Inspect"); inspect_menu->add_action(GAction::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) { String filename_to_open; char tmp_filename[] = "/tmp/view-source.XXXXXX"; @@ -176,7 +176,7 @@ int main(int argc, char** argv) })); menubar->add_menu(move(inspect_menu)); - auto debug_menu = make("Debug"); + auto debug_menu = GMenu::construct("Debug"); debug_menu->add_action(GAction::create("Dump DOM tree", [&](auto&) { dump_tree(*html_widget->document()); })); @@ -199,7 +199,7 @@ int main(int argc, char** argv) debug_menu->add_action(line_box_borders_action); menubar->add_menu(move(debug_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); })); diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index ff84f6a7be1..ccbd71e0133 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -322,7 +322,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("File Manager"); + auto app_menu = GMenu::construct("File Manager"); app_menu->add_action(mkdir_action); app_menu->add_action(copy_action); app_menu->add_action(paste_action); @@ -333,19 +333,19 @@ int main(int argc, char** argv) })); menubar->add_menu(move(app_menu)); - auto view_menu = make("View"); + auto view_menu = GMenu::construct("View"); view_menu->add_action(*view_as_icons_action); view_menu->add_action(*view_as_table_action); menubar->add_menu(move(view_menu)); - auto go_menu = make("Go"); + auto go_menu = GMenu::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 = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); @@ -412,14 +412,14 @@ int main(int argc, char** argv) } }); - auto directory_context_menu = make(); + auto directory_context_menu = GMenu::construct(); directory_context_menu->add_action(copy_action); directory_context_menu->add_action(paste_action); directory_context_menu->add_action(delete_action); directory_context_menu->add_separator(); directory_context_menu->add_action(properties_action); - auto file_context_menu = make(); + auto file_context_menu = GMenu::construct(); file_context_menu->add_action(copy_action); file_context_menu->add_action(paste_action); file_context_menu->add_action(delete_action); @@ -428,7 +428,7 @@ int main(int argc, char** argv) file_context_menu->add_separator(); file_context_menu->add_action(properties_action); - auto directory_view_context_menu = make(); + auto directory_view_context_menu = GMenu::construct(); directory_view_context_menu->add_action(mkdir_action); directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex& index, const GContextMenuEvent& event) { diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 391bb734014..e89625d211d 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) auto menubar = make(); - auto app_menu = make("Help"); + auto app_menu = GMenu::construct("Help"); app_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window); })); @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) })); menubar->add_menu(move(app_menu)); - auto go_menu = make("Go"); + auto go_menu = GMenu::construct("Go"); go_menu->add_action(*go_back_action); go_menu->add_action(*go_forward_action); menubar->add_menu(move(go_menu)); diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp index ec4ff7d23e9..f38213a2c04 100644 --- a/Applications/HexEditor/HexEditorWidget.cpp +++ b/Applications/HexEditor/HexEditorWidget.cpp @@ -106,7 +106,7 @@ HexEditorWidget::HexEditorWidget() }); auto menubar = make(); - auto app_menu = make("Hex Editor"); + auto app_menu = GMenu::construct("Hex Editor"); app_menu->add_action(*m_new_action); app_menu->add_action(*m_open_action); app_menu->add_action(*m_save_action); @@ -119,7 +119,7 @@ HexEditorWidget::HexEditorWidget() })); menubar->add_menu(move(app_menu)); - auto bytes_per_row_menu = make("Bytes Per Row"); + auto bytes_per_row_menu = GMenu::construct("Bytes Per Row"); for (int i = 8; i <= 32; i += 8) { bytes_per_row_menu->add_action(GAction::create(String::number(i), [this, i](auto&) { m_editor->set_bytes_per_row(i); @@ -146,7 +146,7 @@ HexEditorWidget::HexEditorWidget() } }); - auto edit_menu = make("Edit"); + auto edit_menu = GMenu::construct("Edit"); edit_menu->add_action(GAction::create("Fill selection...", [&](const GAction&) { auto input_box = GInputBox::construct("Fill byte (hex):", "Fill Selection", this); if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { @@ -170,11 +170,11 @@ HexEditorWidget::HexEditorWidget() })); menubar->add_menu(move(edit_menu)); - auto view_menu = make("View"); + auto view_menu = GMenu::construct("View"); view_menu->add_submenu(move(bytes_per_row_menu)); menubar->add_menu(move(view_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("Hex Editor", load_png("/res/icons/32x32/app-hexeditor.png"), window()); })); diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index 35da44f912b..a2671b50b3d 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -123,7 +123,7 @@ void IRCAppWindow::setup_actions() void IRCAppWindow::setup_menus() { auto menubar = make(); - auto app_menu = make("IRC Client"); + auto app_menu = GMenu::construct("IRC Client"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); GApplication::the().quit(0); @@ -131,7 +131,7 @@ void IRCAppWindow::setup_menus() })); menubar->add_menu(move(app_menu)); - auto server_menu = make("Server"); + auto server_menu = GMenu::construct("Server"); server_menu->add_action(*m_change_nick_action); server_menu->add_separator(); server_menu->add_action(*m_join_action); @@ -142,7 +142,7 @@ void IRCAppWindow::setup_menus() server_menu->add_action(*m_close_query_action); menubar->add_menu(move(server_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [this](const GAction&) { GAboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this); })); diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index f9947edf654..bc832484878 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -48,7 +48,7 @@ void EraseTool::on_mousemove(GMouseEvent& event) void EraseTool::on_contextmenu(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); NonnullRefPtr eraser_color_toggler = GAction::create("Use secondary color", [&](GAction& action) { bool toggled = !m_use_secondary_color; diff --git a/Applications/PaintBrush/EraseTool.h b/Applications/PaintBrush/EraseTool.h index b23844e0d76..d72f36841b2 100644 --- a/Applications/PaintBrush/EraseTool.h +++ b/Applications/PaintBrush/EraseTool.h @@ -18,7 +18,7 @@ private: Color get_color() const; virtual const char* class_name() const override { return "EraseTool"; } Rect build_rect(const Point& pos, const Rect& widget_rect); - OwnPtr m_context_menu; + RefPtr m_context_menu; bool m_use_secondary_color { true }; int m_thickness { 1 }; diff --git a/Applications/PaintBrush/LineTool.cpp b/Applications/PaintBrush/LineTool.cpp index e6c867ca32f..03bc4761cda 100644 --- a/Applications/PaintBrush/LineTool.cpp +++ b/Applications/PaintBrush/LineTool.cpp @@ -70,7 +70,7 @@ void LineTool::on_keydown(GKeyEvent& event) void LineTool::on_contextmenu(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(GAction::create("1", [this](auto&) { m_thickness = 1; })); diff --git a/Applications/PaintBrush/LineTool.h b/Applications/PaintBrush/LineTool.h index 4bfb589d280..4c5920f54ba 100644 --- a/Applications/PaintBrush/LineTool.h +++ b/Applications/PaintBrush/LineTool.h @@ -23,6 +23,6 @@ private: GMouseButton m_drawing_button { GMouseButton::None }; Point m_line_start_position; Point m_line_end_position; - OwnPtr m_context_menu; + RefPtr m_context_menu; int m_thickness { 1 }; }; diff --git a/Applications/PaintBrush/PenTool.cpp b/Applications/PaintBrush/PenTool.cpp index 33f1c300a18..a9887bff254 100644 --- a/Applications/PaintBrush/PenTool.cpp +++ b/Applications/PaintBrush/PenTool.cpp @@ -50,7 +50,7 @@ void PenTool::on_mousemove(GMouseEvent& event) void PenTool::on_contextmenu(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(GAction::create("1", [this](auto&) { m_thickness = 1; })); diff --git a/Applications/PaintBrush/PenTool.h b/Applications/PaintBrush/PenTool.h index 3020285e097..686ebf9584b 100644 --- a/Applications/PaintBrush/PenTool.h +++ b/Applications/PaintBrush/PenTool.h @@ -19,6 +19,6 @@ private: virtual const char* class_name() const override { return "PenTool"; } Point m_last_drawing_event_position { -1, -1 }; - OwnPtr m_context_menu; + RefPtr m_context_menu; int m_thickness { 1 }; }; diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index fb473fda0e6..6f359f8b455 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -76,7 +76,7 @@ void SprayTool::on_mouseup(GMouseEvent&) void SprayTool::on_contextmenu(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(GAction::create("1", [this](auto&) { m_thickness = 1; })); diff --git a/Applications/PaintBrush/SprayTool.h b/Applications/PaintBrush/SprayTool.h index 7f75da7dcc9..efa2b170f48 100644 --- a/Applications/PaintBrush/SprayTool.h +++ b/Applications/PaintBrush/SprayTool.h @@ -22,6 +22,6 @@ private: RefPtr m_timer; Point m_last_pos; Color m_color; - OwnPtr m_context_menu; + RefPtr m_context_menu; int m_thickness { 1 }; }; diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index 384a2b65d82..571b7bf2248 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) window->show(); auto menubar = make(); - auto app_menu = make("PaintBrush"); + auto app_menu = GMenu::construct("PaintBrush"); app_menu->add_action(GCommonActions::make_open_action([&](auto&) { Optional open_path = GFilePicker::get_open_filepath(); @@ -62,10 +62,10 @@ int main(int argc, char** argv) menubar->add_menu(move(app_menu)); - auto edit_menu = make("Edit"); + auto edit_menu = GMenu::construct("Edit"); menubar->add_menu(move(edit_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](auto&) { GAboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window); })); diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index 735ca214a4d..15517403a38 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("Piano"); + auto app_menu = GMenu::construct("Piano"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { GApplication::the().quit(0); return; diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index e40c96b7803..73bec79aac9 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -15,17 +15,17 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("QuickShow"); + auto app_menu = GMenu::construct("QuickShow"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { GApplication::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto file_menu = make("File"); + auto file_menu = GMenu::construct("File"); menubar->add_menu(move(file_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index 410b31fd8a6..51186c0f561 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char** argv) window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-sound-player.png")); auto menubar = make(); - auto app_menu = make("SoundPlayer"); + auto app_menu = GMenu::construct("SoundPlayer"); auto player = SoundPlayerWidget::construct(window, audio_client); if (argc > 1) { @@ -51,7 +51,7 @@ int main(int argc, char** argv) app.quit(); })); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [](auto&) { GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png")); })); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 4898fac21b8..c6c997b893b 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -116,20 +116,20 @@ int main(int argc, char** argv) window->set_main_widget(keeper); auto menubar = make(); - auto app_menu = make("System Monitor"); + auto app_menu = GMenu::construct("System Monitor"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { GApplication::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto process_menu = make("Process"); + auto process_menu = GMenu::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_context_menu = make(); + auto process_context_menu = GMenu::construct(); process_context_menu->add_action(kill_action); process_context_menu->add_action(stop_action); process_context_menu->add_action(continue_action); @@ -138,7 +138,7 @@ int main(int argc, char** argv) process_context_menu->popup(event.screen_position()); }; - auto frequency_menu = make("Frequency"); + auto frequency_menu = GMenu::construct("Frequency"); frequency_menu->add_action(GAction::create("0.25 sec", [&](auto&) { refresh_timer->restart(250); })); @@ -156,7 +156,7 @@ int main(int argc, char** argv) })); menubar->add_menu(move(frequency_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("SystemMonitor", load_png("/res/icons/32x32/app-system-monitor.png"), window); })); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index c1503ad1729..17bd9dd2d03 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -195,7 +195,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("Terminal"); + auto app_menu = GMenu::construct("Terminal"); app_menu->add_action(GAction::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { if (!fork()) { execl("/bin/Terminal", "Terminal", nullptr); @@ -221,12 +221,12 @@ int main(int argc, char** argv) })); menubar->add_menu(move(app_menu)); - auto edit_menu = make("Edit"); + auto edit_menu = GMenu::construct("Edit"); edit_menu->add_action(terminal->copy_action()); edit_menu->add_action(terminal->paste_action()); menubar->add_menu(move(edit_menu)); - auto font_menu = make("Font"); + auto font_menu = GMenu::construct("Font"); GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { font_menu->add_action(GAction::create(font_name, [&](const GAction& action) { terminal->set_font(GFontDatabase::the().get_by_name(action.text())); @@ -239,7 +239,7 @@ int main(int argc, char** argv) }); menubar->add_menu(move(font_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("Terminal", load_png("/res/icons/32x32/app-terminal.png"), window); })); diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index cc12a350f6f..3a5beb99945 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -192,7 +192,7 @@ TextEditorWidget::TextEditorWidget() m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled()); auto menubar = make(); - auto app_menu = make("Text Editor"); + auto app_menu = GMenu::construct("Text Editor"); app_menu->add_action(*m_new_action); app_menu->add_action(*m_open_action); app_menu->add_action(*m_save_action); @@ -205,7 +205,7 @@ TextEditorWidget::TextEditorWidget() })); menubar->add_menu(move(app_menu)); - auto edit_menu = make("Edit"); + auto edit_menu = GMenu::construct("Edit"); edit_menu->add_action(m_editor->undo_action()); edit_menu->add_action(m_editor->redo_action()); edit_menu->add_separator(); @@ -219,7 +219,7 @@ TextEditorWidget::TextEditorWidget() edit_menu->add_action(*m_find_previous_action); menubar->add_menu(move(edit_menu)); - auto font_menu = make("Font"); + auto font_menu = GMenu::construct("Font"); GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { font_menu->add_action(GAction::create(font_name, [this](const GAction& action) { m_editor->set_font(GFontDatabase::the().get_by_name(action.text())); @@ -227,13 +227,13 @@ TextEditorWidget::TextEditorWidget() })); }); - auto view_menu = make("View"); + auto view_menu = GMenu::construct("View"); view_menu->add_action(*m_line_wrapping_setting_action); view_menu->add_separator(); view_menu->add_submenu(move(font_menu)); menubar->add_menu(move(view_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("TextEditor", load_png("/res/icons/32x32/app-texteditor.png"), window()); })); diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index eb5ff776e32..69fe4fa327d 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -348,19 +348,19 @@ int main(int argc, char** argv) }); auto menubar = make(); - auto app_menu = make("HackStudio"); + auto app_menu = GMenu::construct("HackStudio"); app_menu->add_action(save_action); app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); })); menubar->add_menu(move(app_menu)); - auto project_menu = make("Project"); + auto project_menu = GMenu::construct("Project"); project_menu->add_action(new_action); project_menu->add_action(add_existing_file_action); menubar->add_menu(move(project_menu)); - auto edit_menu = make("Edit"); + auto edit_menu = GMenu::construct("Edit"); edit_menu->add_action(GAction::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) { reveal_action_tab(find_in_files_widget); find_in_files_widget->focus_textbox_and_select_all(); @@ -391,13 +391,13 @@ int main(int argc, char** argv) toolbar->add_action(run_action); toolbar->add_action(stop_action); - auto build_menu = make("Build"); + auto build_menu = GMenu::construct("Build"); build_menu->add_action(build_action); build_menu->add_action(run_action); build_menu->add_action(stop_action); menubar->add_menu(move(build_menu)); - auto view_menu = make("View"); + auto view_menu = GMenu::construct("View"); view_menu->add_action(hide_action_tabs_action); view_menu->add_action(open_locator_action); view_menu->add_separator(); @@ -407,7 +407,7 @@ int main(int argc, char** argv) auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](auto&) { GAboutDialog::show("HackStudio", small_icon, g_window); })); diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index cd0aad11def..11a716fe05f 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -28,7 +28,7 @@ VBForm::VBForm(const String& name, GWidget* parent) set_background_color(Color::WarmGray); set_greedy_for_hits(true); - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(GCommonActions::make_move_to_front_action([this](auto&) { if (auto* widget = single_selected_widget()) widget->gwidget()->move_to_front(); diff --git a/DevTools/VisualBuilder/VBForm.h b/DevTools/VisualBuilder/VBForm.h index a2c0a27f90f..384b7509e8e 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -61,5 +61,5 @@ private: Point m_next_insertion_position; Direction m_resize_direction { Direction::None }; Direction m_mouse_direction_type { Direction::None }; - OwnPtr m_context_menu; + RefPtr m_context_menu; }; diff --git a/DevTools/VisualBuilder/main.cpp b/DevTools/VisualBuilder/main.cpp index 3d96db1e510..6647bae6fdc 100644 --- a/DevTools/VisualBuilder/main.cpp +++ b/DevTools/VisualBuilder/main.cpp @@ -31,14 +31,14 @@ int main(int argc, char** argv) }; auto menubar = make(); - auto app_menu = make("Visual Builder"); + auto app_menu = GMenu::construct("Visual Builder"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { GApplication::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto file_menu = make("File"); + auto file_menu = GMenu::construct("File"); file_menu->add_action(GAction::create("Dump Form", [&](auto&) { form1->dump(); })); @@ -54,7 +54,7 @@ int main(int argc, char** argv) window->show(); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window); })); diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 05ff8cc8bb1..80f4ad71c69 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("Minesweeper"); + auto app_menu = GMenu::construct("Minesweeper"); app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) { field->reset(); @@ -73,7 +73,7 @@ int main(int argc, char** argv) })); menubar->add_menu(move(app_menu)); - auto difficulty_menu = make("Difficulty"); + auto difficulty_menu = GMenu::construct("Difficulty"); difficulty_menu->add_action(GAction::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GAction&) { field->set_field_size(9, 9, 10); })); @@ -88,7 +88,7 @@ int main(int argc, char** argv) })); menubar->add_menu(move(difficulty_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); diff --git a/Games/Snake/main.cpp b/Games/Snake/main.cpp index 2000cc2aa4b..e5b75c86b3b 100644 --- a/Games/Snake/main.cpp +++ b/Games/Snake/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("Snake"); + auto app_menu = GMenu::construct("Snake"); app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) { game->reset(); @@ -34,7 +34,7 @@ int main(int argc, char** argv) menubar->add_menu(move(app_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); diff --git a/Libraries/LibGUI/GMenu.cpp b/Libraries/LibGUI/GMenu.cpp index de660678ab6..401b3672dbb 100644 --- a/Libraries/LibGUI/GMenu.cpp +++ b/Libraries/LibGUI/GMenu.cpp @@ -39,7 +39,7 @@ void GMenu::add_action(NonnullRefPtr action) #endif } -void GMenu::add_submenu(NonnullOwnPtr submenu) +void GMenu::add_submenu(NonnullRefPtr submenu) { m_items.append(make(m_menu_id, move(submenu))); } diff --git a/Libraries/LibGUI/GMenu.h b/Libraries/LibGUI/GMenu.h index a4fadcf1324..d80153d1485 100644 --- a/Libraries/LibGUI/GMenu.h +++ b/Libraries/LibGUI/GMenu.h @@ -3,15 +3,17 @@ #include #include #include +#include #include class GAction; class Point; -class GMenu { +class GMenu final : public CObject { + C_OBJECT(GMenu) public: explicit GMenu(const StringView& name = ""); - ~GMenu(); + virtual ~GMenu() override; static GMenu* from_menu_id(int); @@ -21,7 +23,7 @@ public: void add_action(NonnullRefPtr); void add_separator(); - void add_submenu(NonnullOwnPtr); + void add_submenu(NonnullRefPtr); void popup(const Point& screen_position); void dismiss(); diff --git a/Libraries/LibGUI/GMenuBar.cpp b/Libraries/LibGUI/GMenuBar.cpp index 1449b189bde..8301bb638e2 100644 --- a/Libraries/LibGUI/GMenuBar.cpp +++ b/Libraries/LibGUI/GMenuBar.cpp @@ -10,7 +10,7 @@ GMenuBar::~GMenuBar() unrealize_menubar(); } -void GMenuBar::add_menu(NonnullOwnPtr&& menu) +void GMenuBar::add_menu(NonnullRefPtr menu) { m_menus.append(move(menu)); } diff --git a/Libraries/LibGUI/GMenuBar.h b/Libraries/LibGUI/GMenuBar.h index 5802177cb90..ca82b04144a 100644 --- a/Libraries/LibGUI/GMenuBar.h +++ b/Libraries/LibGUI/GMenuBar.h @@ -11,7 +11,7 @@ public: GMenuBar(); ~GMenuBar(); - void add_menu(NonnullOwnPtr&&); + void add_menu(NonnullRefPtr); void notify_added_to_application(Badge); void notify_removed_from_application(Badge); @@ -21,5 +21,5 @@ private: void unrealize_menubar(); int m_menubar_id { -1 }; - NonnullOwnPtrVector m_menus; + NonnullRefPtrVector m_menus; }; diff --git a/Libraries/LibGUI/GMenuItem.cpp b/Libraries/LibGUI/GMenuItem.cpp index c77fedddfa2..fe5614bc164 100644 --- a/Libraries/LibGUI/GMenuItem.cpp +++ b/Libraries/LibGUI/GMenuItem.cpp @@ -21,7 +21,7 @@ GMenuItem::GMenuItem(unsigned menu_id, NonnullRefPtr&& action) m_checked = m_action->is_checked(); } -GMenuItem::GMenuItem(unsigned menu_id, NonnullOwnPtr&& submenu) +GMenuItem::GMenuItem(unsigned menu_id, NonnullRefPtr&& submenu) : m_type(Submenu) , m_menu_id(menu_id) , m_submenu(move(submenu)) diff --git a/Libraries/LibGUI/GMenuItem.h b/Libraries/LibGUI/GMenuItem.h index 5b17b74c717..7fdd26d24fd 100644 --- a/Libraries/LibGUI/GMenuItem.h +++ b/Libraries/LibGUI/GMenuItem.h @@ -19,7 +19,7 @@ public: GMenuItem(unsigned menu_id, Type); GMenuItem(unsigned menu_id, NonnullRefPtr&&); - GMenuItem(unsigned menu_id, NonnullOwnPtr&&); + GMenuItem(unsigned menu_id, NonnullRefPtr&&); ~GMenuItem(); Type type() const { return m_type; } @@ -53,5 +53,5 @@ private: bool m_checkable { false }; bool m_checked { false }; RefPtr m_action; - OwnPtr m_submenu; + RefPtr m_submenu; }; diff --git a/Libraries/LibGUI/GTableView.cpp b/Libraries/LibGUI/GTableView.cpp index e9d3060e4e4..a37d62025ae 100644 --- a/Libraries/LibGUI/GTableView.cpp +++ b/Libraries/LibGUI/GTableView.cpp @@ -550,7 +550,7 @@ GMenu& GTableView::ensure_header_context_menu() // or if the column count/names change. if (!m_header_context_menu) { ASSERT(model()); - m_header_context_menu = make(); + m_header_context_menu = GMenu::construct(); for (int column = 0; column < model()->column_count(); ++column) { auto& column_data = this->column_data(column); diff --git a/Libraries/LibGUI/GTableView.h b/Libraries/LibGUI/GTableView.h index e4e6845b3b9..89d9a62e7ae 100644 --- a/Libraries/LibGUI/GTableView.h +++ b/Libraries/LibGUI/GTableView.h @@ -98,5 +98,5 @@ protected: int m_hovered_column_header_index { -1 }; GMenu& ensure_header_context_menu(); - OwnPtr m_header_context_menu; + RefPtr m_header_context_menu; }; diff --git a/Libraries/LibGUI/GTextEditor.cpp b/Libraries/LibGUI/GTextEditor.cpp index 25bf3ff348f..f9dad605028 100644 --- a/Libraries/LibGUI/GTextEditor.cpp +++ b/Libraries/LibGUI/GTextEditor.cpp @@ -1180,7 +1180,7 @@ void GTextEditor::did_update_selection() void GTextEditor::context_menu_event(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(undo_action()); m_context_menu->add_action(redo_action()); m_context_menu->add_separator(); diff --git a/Libraries/LibGUI/GTextEditor.h b/Libraries/LibGUI/GTextEditor.h index 202be7e84ba..65219d1fc81 100644 --- a/Libraries/LibGUI/GTextEditor.h +++ b/Libraries/LibGUI/GTextEditor.h @@ -196,7 +196,7 @@ private: size_t m_soft_tab_width { 4 }; int m_horizontal_content_padding { 2 }; GTextRange m_selection; - OwnPtr m_context_menu; + RefPtr m_context_menu; RefPtr m_undo_action; RefPtr m_redo_action; RefPtr m_cut_action; diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index b9601231471..db3bce94b28 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -648,7 +648,7 @@ void TerminalWidget::beep() void TerminalWidget::context_menu_event(GContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = make(); + m_context_menu = GMenu::construct(); m_context_menu->add_action(copy_action()); m_context_menu->add_action(paste_action()); } diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h index be6951701ce..6d5d22da683 100644 --- a/Libraries/LibVT/TerminalWidget.h +++ b/Libraries/LibVT/TerminalWidget.h @@ -128,7 +128,7 @@ private: RefPtr m_copy_action; RefPtr m_paste_action; - OwnPtr m_context_menu; + RefPtr m_context_menu; CElapsedTimer m_triple_click_timer; }; diff --git a/Userland/html.cpp b/Userland/html.cpp index 33562f42c3c..9d2ddf3ae7a 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -48,13 +48,13 @@ int main(int argc, char** argv) auto menubar = make(); - auto app_menu = make("HTML"); + auto app_menu = GMenu::construct("HTML"); app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); })); menubar->add_menu(move(app_menu)); - auto help_menu = make("Help"); + auto help_menu = GMenu::construct("Help"); help_menu->add_action(GAction::create("About", [&](const GAction&) { GAboutDialog::show("HTML", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); }));