diff options
28 files changed, 36 insertions, 38 deletions
diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index b0afac6929..06a88877ea 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -228,7 +228,7 @@ int main(int argc, char** argv) statusbar.set_text(String::format("Loading (%d pending resources...)", Web::ResourceLoader::the().pending_loads())); }; - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); 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&) { diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index e8a06f2677..7ff679d1fb 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) window->show(); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calculator.png")); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Calculator"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { diff --git a/Applications/Calendar/main.cpp b/Applications/Calendar/main.cpp index 132bc00511..3a0b64ff08 100644 --- a/Applications/Calendar/main.cpp +++ b/Applications/Calendar/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) window->show(); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png")); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Calendar"); app_menu.add_action(GUI::Action::create("Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp index c950eefcb9..438c0ac1d8 100644 --- a/Applications/ChanViewer/main.cpp +++ b/Applications/ChanViewer/main.cpp @@ -92,7 +92,7 @@ int main(int argc, char** argv) window->show(); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("ChanViewer"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { diff --git a/Applications/DisplayProperties/main.cpp b/Applications/DisplayProperties/main.cpp index 2e064ef54b..3a90bfffdb 100644 --- a/Applications/DisplayProperties/main.cpp +++ b/Applications/DisplayProperties/main.cpp @@ -60,7 +60,7 @@ 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")); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Display Properties"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) { diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index fca3215f97..c37b8d3deb 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -534,7 +534,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio }, window); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("File Manager"); app_menu.add_action(mkdir_action); diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index da5f4a3850..9185733d33 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) window->show(); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png")); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Font Editor"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 1a828c0bf4..daf6819f65 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -177,7 +177,7 @@ int main(int argc, char* argv[]) toolbar.add_action(*go_back_action); toolbar.add_action(*go_forward_action); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Help"); app_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp index 0102820adc..43d80dae0a 100644 --- a/Applications/HexEditor/HexEditorWidget.cpp +++ b/Applications/HexEditor/HexEditorWidget.cpp @@ -132,7 +132,7 @@ HexEditorWidget::HexEditorWidget() dbg() << "Wrote document to " << save_path.value(); }); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Hex Editor"); app_menu.add_action(*m_new_action); app_menu.add_action(*m_open_action); diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index b33b28de83..05fa68dd6d 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -259,7 +259,7 @@ void IRCAppWindow::setup_actions() void IRCAppWindow::setup_menus() { - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("IRC Client"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index 52b284413d..c4d6cffb85 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) window->show(); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("PaintBrush"); app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index dc84893bae..3fef83134a 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -92,7 +92,7 @@ int main(int argc, char** argv) }); audio_thread.start(); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Piano"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index 3568899260..a60421e319 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -234,7 +234,7 @@ int main(int argc, char** argv) main_toolbar.add_action(zoom_in_action); main_toolbar.add_action(zoom_out_action); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("QuickShow"); app_menu.add_action(open_action); diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index 75d558693c..c2ad025f34 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char** argv) window->set_rect(300, 300, 350, 140); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-sound-player.png")); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("SoundPlayer"); auto& player = window->set_main_widget<SoundPlayerWidget>(window, audio_client); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 6b94e44d78..eefd7a4980 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -174,7 +174,7 @@ int main(int argc, char** argv) toolbar.add_action(stop_action); toolbar.add_action(continue_action); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("System Monitor"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index a5d5bf1600..a89a5c3a79 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -243,7 +243,7 @@ int main(int argc, char** argv) terminal.set_opacity(new_opacity); window->set_has_alpha_channel(new_opacity < 255); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); 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&) { diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index f7b90a7b48..bf1ce9d864 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -341,7 +341,7 @@ TextEditorWidget::TextEditorWidget() m_line_wrapping_setting_action->set_checkable(true); m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled()); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Text Editor"); app_menu.add_action(*m_new_action); app_menu.add_action(*m_open_action); diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index d69f6b9da7..0edabf04cf 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -491,7 +491,7 @@ int main(int argc, char** argv) locator.open(); }); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("HackStudio"); app_menu.add_action(open_action); app_menu.add_action(save_action); diff --git a/DevTools/ProfileViewer/main.cpp b/DevTools/ProfileViewer/main.cpp index 2d966085db..325f3dfad9 100644 --- a/DevTools/ProfileViewer/main.cpp +++ b/DevTools/ProfileViewer/main.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) disassembly_view.set_model(profile->disassembly_model()); }; - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("ProfileViewer"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); diff --git a/DevTools/VisualBuilder/main.cpp b/DevTools/VisualBuilder/main.cpp index c697602e80..c008dda49b 100644 --- a/DevTools/VisualBuilder/main.cpp +++ b/DevTools/VisualBuilder/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char** argv) propbox->table_view().set_model(widget ? &widget->property_model() : nullptr); }; - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Visual Builder"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the().quit(0); diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 04aec36a39..72fe4bbab5 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) window->resize(size); }); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Minesweeper"); diff --git a/Games/Snake/main.cpp b/Games/Snake/main.cpp index 4e94e0a23d..8db863c990 100644 --- a/Games/Snake/main.cpp +++ b/Games/Snake/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char** argv) auto& game = window->set_main_widget<SnakeGame>(); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Snake"); diff --git a/Games/Solitaire/main.cpp b/Games/Solitaire/main.cpp index 479beeac03..25c98272a5 100644 --- a/Games/Solitaire/main.cpp +++ b/Games/Solitaire/main.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) window->set_title(String::format("Score: %u - Solitaire", score)); }); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Solitaire"); app_menu.add_action(GUI::Action::create("Restart game", [&](auto&) { widget->setup(); })); diff --git a/Libraries/LibGUI/Application.cpp b/Libraries/LibGUI/Application.cpp index b560677082..322869b91f 100644 --- a/Libraries/LibGUI/Application.cpp +++ b/Libraries/LibGUI/Application.cpp @@ -79,7 +79,7 @@ void Application::quit(int exit_code) m_event_loop->quit(exit_code); } -void Application::set_menubar(OwnPtr<MenuBar>&& menubar) +void Application::set_menubar(RefPtr<MenuBar> menubar) { if (m_menubar) m_menubar->notify_removed_from_application({}); diff --git a/Libraries/LibGUI/Application.h b/Libraries/LibGUI/Application.h index 400ed6fb5e..422bbc06e4 100644 --- a/Libraries/LibGUI/Application.h +++ b/Libraries/LibGUI/Application.h @@ -45,7 +45,7 @@ public: int exec(); void quit(int = 0); - void set_menubar(OwnPtr<MenuBar>&&); + void set_menubar(RefPtr<MenuBar>); Action* action_for_key_event(const KeyEvent&); void register_global_shortcut_action(Badge<Action>, Action&); @@ -70,7 +70,7 @@ public: private: OwnPtr<Core::EventLoop> m_event_loop; - OwnPtr<MenuBar> m_menubar; + RefPtr<MenuBar> m_menubar; RefPtr<Gfx::PaletteImpl> m_palette; RefPtr<Gfx::PaletteImpl> m_system_palette; HashMap<Shortcut, Action*> m_global_shortcut_actions; diff --git a/Libraries/LibGUI/MenuBar.cpp b/Libraries/LibGUI/MenuBar.cpp index 316e4d2d42..ea8c9649b5 100644 --- a/Libraries/LibGUI/MenuBar.cpp +++ b/Libraries/LibGUI/MenuBar.cpp @@ -43,14 +43,9 @@ MenuBar::~MenuBar() Menu& MenuBar::add_menu(String name) { - auto menu = Menu::construct(move(name)); - append_menu(menu); - return *menu; -} - -void MenuBar::append_menu(NonnullRefPtr<Menu> menu) -{ - m_menus.append(move(menu)); + auto& menu = add<Menu>(move(name)); + m_menus.append(menu); + return menu; } int MenuBar::realize_menubar() diff --git a/Libraries/LibGUI/MenuBar.h b/Libraries/LibGUI/MenuBar.h index 695911a18e..20c1b5678b 100644 --- a/Libraries/LibGUI/MenuBar.h +++ b/Libraries/LibGUI/MenuBar.h @@ -28,22 +28,25 @@ #include <AK/Forward.h> #include <AK/NonnullRefPtrVector.h> +#include <LibCore/Object.h> #include <LibGUI/Forward.h> namespace GUI { -class MenuBar { +class MenuBar : public Core::Object { + C_OBJECT(MenuBar); + public: - MenuBar(); ~MenuBar(); Menu& add_menu(String name); - void append_menu(NonnullRefPtr<Menu>); void notify_added_to_application(Badge<Application>); void notify_removed_from_application(Badge<Application>); private: + MenuBar(); + int realize_menubar(); void unrealize_menubar(); diff --git a/Userland/html.cpp b/Userland/html.cpp index dc1ccd175b..9fe2b1a363 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -72,7 +72,7 @@ int main(int argc, char** argv) window->set_title("HTML"); window->show(); - auto menubar = make<GUI::MenuBar>(); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("HTML"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { |