summaryrefslogtreecommitdiff
path: root/Userland/Applications/IRCClient/IRCAppWindow.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-21 21:21:03 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-21 21:24:26 +0200
commit687a12d7fb480cf3586c97e30cdb4f67d7e72da5 (patch)
tree18075eda4d084c161e935c4d386f6b9f6790a9d1 /Userland/Applications/IRCClient/IRCAppWindow.cpp
parenta4fdb7f0296379affbf1083a7875d40e1624a067 (diff)
downloadserenity-687a12d7fb480cf3586c97e30cdb4f67d7e72da5.zip
Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus to it, and then call GUI::Window::set_menubar(). This patch introduces GUI::Window::add_menu() which creates the menubar automatically and adds items to it. Application code becomes slightly simpler as a result. :^)
Diffstat (limited to 'Userland/Applications/IRCClient/IRCAppWindow.cpp')
-rw-r--r--Userland/Applications/IRCClient/IRCAppWindow.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/Userland/Applications/IRCClient/IRCAppWindow.cpp b/Userland/Applications/IRCClient/IRCAppWindow.cpp
index 8a800d7e58..6f762f2eb0 100644
--- a/Userland/Applications/IRCClient/IRCAppWindow.cpp
+++ b/Userland/Applications/IRCClient/IRCAppWindow.cpp
@@ -237,13 +237,12 @@ void IRCAppWindow::setup_actions()
void IRCAppWindow::setup_menus()
{
- auto menubar = GUI::Menubar::construct();
- auto& file_menu = menubar->add_menu("&File");
+ auto& file_menu = add_menu("&File");
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
GUI::Application::the()->quit();
}));
- auto& server_menu = menubar->add_menu("&Server");
+ auto& server_menu = add_menu("&Server");
server_menu.add_action(*m_change_nick_action);
server_menu.add_separator();
server_menu.add_action(*m_join_action);
@@ -253,7 +252,7 @@ void IRCAppWindow::setup_menus()
server_menu.add_action(*m_open_query_action);
server_menu.add_action(*m_close_query_action);
- auto& channel_menu = menubar->add_menu("&Channel");
+ auto& channel_menu = add_menu("&Channel");
channel_menu.add_action(*m_change_topic_action);
channel_menu.add_action(*m_invite_user_action);
channel_menu.add_action(*m_banlist_action);
@@ -272,10 +271,8 @@ void IRCAppWindow::setup_menus()
channel_menu.add_action(*m_cycle_channel_action);
channel_menu.add_action(*m_part_action);
- auto& help_menu = menubar->add_menu("&Help");
+ auto& help_menu = add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("IRC Client", GUI::Icon::default_icon("app-irc-client"), this));
-
- set_menubar(move(menubar));
}
void IRCAppWindow::setup_widgets()