diff options
author | Brendan Coles <bcoles@gmail.com> | 2020-04-18 16:46:22 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-18 19:49:05 +0200 |
commit | e87347e1d39cd1cec53a652f3c9c4962c10d1c5b (patch) | |
tree | 98935e663fc415ff48bc4f7a9debc43eaca6531f /Applications/IRCClient | |
parent | 2de843692cfd844609cef5a65dd36627a42f85f6 (diff) | |
download | serenity-e87347e1d39cd1cec53a652f3c9c4962c10d1c5b.zip |
IRCClient: Use sub-menus for app channel menu and member context menu
Diffstat (limited to 'Applications/IRCClient')
-rw-r--r-- | Applications/IRCClient/IRCAppWindow.cpp | 21 | ||||
-rw-r--r-- | Applications/IRCClient/IRCWindow.cpp | 54 |
2 files changed, 40 insertions, 35 deletions
diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index f9a388bb7e..b33b28de83 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -281,15 +281,18 @@ void IRCAppWindow::setup_menus() channel_menu.add_action(*m_change_topic_action); channel_menu.add_action(*m_invite_user_action); channel_menu.add_action(*m_banlist_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_hop_user_action); - channel_menu.add_action(*m_dehop_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); + + RefPtr<GUI::Menu> channel_control_menu = GUI::Menu::construct("Control"); + channel_menu.add_submenu(*channel_control_menu); + channel_control_menu->add_action(*m_voice_user_action); + channel_control_menu->add_action(*m_devoice_user_action); + channel_control_menu->add_action(*m_hop_user_action); + channel_control_menu->add_action(*m_dehop_user_action); + channel_control_menu->add_action(*m_op_user_action); + channel_control_menu->add_action(*m_deop_user_action); + channel_control_menu->add_separator(); + channel_control_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); diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index fc41819064..ad6a1095ef 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -90,9 +90,10 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na m_client.handle_whois_action(m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_separator(); + RefPtr<GUI::Menu> m_context_control_menu = GUI::Menu::construct("Control"); + m_context_menu->add_submenu(*m_context_control_menu); - m_context_menu->add_action(GUI::Action::create("Voice", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("Voice", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; @@ -100,89 +101,90 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na m_client.handle_voice_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("DeVoice", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("DeVoice", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client.handle_devoice_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("Hop", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("Hop", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client.handle_hop_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("DeHop", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("DeHop", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client.handle_dehop_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("Op", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("Op", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client.handle_op_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("DeOp", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("DeOp", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client.handle_deop_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters())); })); - m_context_menu->add_separator(); + m_context_control_menu->add_separator(); - m_context_menu->add_action(GUI::Action::create("User info", [&](const GUI::Action&) { + m_context_control_menu->add_action(GUI::Action::create("Kick", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "USERINFO"); + if (IRCClient::is_nick_prefix(nick[0])) + nick = nick.substring(1, nick.length() - 1); + auto input_box = GUI::InputBox::construct("Enter reason:", "Reason"); + if (input_box->exec() == GUI::InputBox::ExecOK) + m_client.handle_kick_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters()), input_box->text_value()); })); - m_context_menu->add_action(GUI::Action::create("Finger", [&](const GUI::Action&) { + RefPtr<GUI::Menu> m_context_ctcp_menu = GUI::Menu::construct("CTCP"); + m_context_menu->add_submenu(*m_context_ctcp_menu); + + m_context_ctcp_menu->add_action(GUI::Action::create("User info", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "FINGER"); + m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "USERINFO"); })); - m_context_menu->add_action(GUI::Action::create("Time", [&](const GUI::Action&) { + m_context_ctcp_menu->add_action(GUI::Action::create("Finger", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "TIME"); + m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "FINGER"); })); - m_context_menu->add_action(GUI::Action::create("Version", [&](const GUI::Action&) { + m_context_ctcp_menu->add_action(GUI::Action::create("Time", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "VERSION"); + m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "TIME"); })); - m_context_menu->add_action(GUI::Action::create("Client info", [&](const GUI::Action&) { + m_context_ctcp_menu->add_action(GUI::Action::create("Version", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "CLIENTINFO"); + m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "VERSION"); })); - m_context_menu->add_separator(); - - m_context_menu->add_action(GUI::Action::create("Kick", [&](const GUI::Action&) { + m_context_ctcp_menu->add_action(GUI::Action::create("Client info", [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; - if (IRCClient::is_nick_prefix(nick[0])) - nick = nick.substring(1, nick.length() - 1); - auto input_box = GUI::InputBox::construct("Enter reason:", "Reason"); - if (input_box->exec() == GUI::InputBox::ExecOK) - m_client.handle_kick_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters()), input_box->text_value()); + m_client.handle_ctcp_user_action(m_client.nick_without_prefix(nick.characters()), "CLIENTINFO"); })); m_context_menu->popup(event.screen_position()); |