diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-04 19:07:55 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-04 21:04:06 +0100 |
commit | 028c011760b5b665fc2a72bb3c11fd3a6ca60d2c (patch) | |
tree | a961293992de78ebac5c3ffec864179d661dcc09 /Applications/IRCClient | |
parent | fb09b6a8cec02cc473b3fed326d99055d80a60ba (diff) | |
download | serenity-028c011760b5b665fc2a72bb3c11fd3a6ca60d2c.zip |
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
Diffstat (limited to 'Applications/IRCClient')
-rw-r--r-- | Applications/IRCClient/IRCAppWindow.cpp | 44 | ||||
-rw-r--r-- | Applications/IRCClient/IRCWindow.cpp | 18 |
2 files changed, 31 insertions, 31 deletions
diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index b3b22c6d16..908453ad11 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -94,12 +94,12 @@ void IRCAppWindow::setup_client() }; if (m_client->hostname().is_empty()) { - auto input_box = add<GUI::InputBox>("Enter server:", "Connect to server"); - auto result = input_box->exec(); + auto& input_box = add<GUI::InputBox>("Enter server:", "Connect to server"); + auto result = input_box.exec(); if (result == GUI::InputBox::ExecCancel) ::exit(0); - m_client->set_server(input_box->text_value(), 6667); + m_client->set_server(input_box.text_value(), 6667); } update_title(); bool success = m_client->connect(); @@ -109,9 +109,9 @@ void IRCAppWindow::setup_client() void IRCAppWindow::setup_actions() { m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { - auto input_box = add<GUI::InputBox>("Enter channel name:", "Join channel"); - if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) - m_client->handle_join_action(input_box->text_value()); + auto& input_box = add<GUI::InputBox>("Enter channel name:", "Join channel"); + if (input_box.exec() == GUI::InputBox::ExecOK && !input_box.text_value().is_empty()) + m_client->handle_join_action(input_box.text_value()); }); m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) { @@ -184,24 +184,24 @@ void IRCAppWindow::setup_widgets() widget.set_layout<GUI::VerticalBoxLayout>(); widget.layout()->set_spacing(0); - auto toolbar = widget.add<GUI::ToolBar>(); - toolbar->set_has_frame(false); - toolbar->add_action(*m_change_nick_action); - toolbar->add_separator(); - toolbar->add_action(*m_join_action); - toolbar->add_action(*m_part_action); - toolbar->add_separator(); - toolbar->add_action(*m_whois_action); - toolbar->add_action(*m_open_query_action); - toolbar->add_action(*m_close_query_action); + auto& toolbar = widget.add<GUI::ToolBar>(); + toolbar.set_has_frame(false); + toolbar.add_action(*m_change_nick_action); + toolbar.add_separator(); + toolbar.add_action(*m_join_action); + toolbar.add_action(*m_part_action); + toolbar.add_separator(); + toolbar.add_action(*m_whois_action); + toolbar.add_action(*m_open_query_action); + toolbar.add_action(*m_close_query_action); - auto outer_container = widget.add<GUI::Widget>(); - outer_container->set_layout<GUI::VerticalBoxLayout>(); - outer_container->layout()->set_margins({ 2, 0, 2, 2 }); + auto& outer_container = widget.add<GUI::Widget>(); + outer_container.set_layout<GUI::VerticalBoxLayout>(); + outer_container.layout()->set_margins({ 2, 0, 2, 2 }); - auto horizontal_container = outer_container->add<GUI::HorizontalSplitter>(); + auto& horizontal_container = outer_container.add<GUI::HorizontalSplitter>(); - m_window_list = horizontal_container->add<GUI::TableView>(); + m_window_list = horizontal_container.add<GUI::TableView>(); m_window_list->set_headers_visible(false); m_window_list->set_alternating_row_colors(false); m_window_list->set_size_columns_to_fit_content(true); @@ -213,7 +213,7 @@ void IRCAppWindow::setup_widgets() set_active_window(m_client->window_at(index.row())); }; - m_container = horizontal_container->add<GUI::StackWidget>(); + m_container = horizontal_container.add<GUI::StackWidget>(); m_container->on_active_widget_change = [this](auto*) { update_part_action(); }; diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index 9ad9739e5d..a47525da8e 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -44,18 +44,18 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na set_layout<GUI::VerticalBoxLayout>(); // Make a container for the log buffer view + (optional) member list. - auto container = add<GUI::HorizontalSplitter>(); + auto& container = add<GUI::HorizontalSplitter>(); - m_html_view = container->add<HtmlView>(); + m_html_view = container.add<HtmlView>(); if (m_type == Channel) { - auto member_view = container->add<GUI::TableView>(); - member_view->set_headers_visible(false); - member_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); - member_view->set_preferred_size(100, 0); - member_view->set_alternating_row_colors(false); - member_view->set_model(channel().member_model()); - member_view->set_activates_on_selection(true); + auto& member_view = container.add<GUI::TableView>(); + member_view.set_headers_visible(false); + member_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); + member_view.set_preferred_size(100, 0); + member_view.set_alternating_row_colors(false); + member_view.set_model(channel().member_model()); + member_view.set_activates_on_selection(true); } m_text_editor = add<GUI::TextBox>(); |