mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 19:28:11 +00:00
IRCClient: Add channel operations to Channel application menu
Add menu options to invite user, op/deop/voice/devoice user, and cycle channel.
This commit is contained in:
parent
b3d7c5d9de
commit
855f9286fa
4 changed files with 149 additions and 4 deletions
|
@ -160,6 +160,61 @@ void IRCAppWindow::setup_actions()
|
||||||
m_client->handle_change_topic_action(window->channel().name(), input_box->text_value());
|
m_client->handle_change_topic_action(window->channel().name(), input_box->text_value());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_invite_user_action = GUI::Action::create("Invite user", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto input_box = GUI::InputBox::construct("Enter nick:", "Invite user", this);
|
||||||
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
|
m_client->handle_invite_user_action(window->channel().name(), input_box->text_value());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_voice_user_action = GUI::Action::create("Voice user", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto input_box = GUI::InputBox::construct("Enter nick:", "Voice user", this);
|
||||||
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
|
m_client->handle_voice_user_action(window->channel().name(), input_box->text_value());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_devoice_user_action = GUI::Action::create("DeVoice user", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto input_box = GUI::InputBox::construct("Enter nick:", "DeVoice user", this);
|
||||||
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
|
m_client->handle_devoice_user_action(window->channel().name(), input_box->text_value());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_op_user_action = GUI::Action::create("Op user", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto input_box = GUI::InputBox::construct("Enter nick:", "Op user", this);
|
||||||
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
|
m_client->handle_op_user_action(window->channel().name(), input_box->text_value());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_deop_user_action = GUI::Action::create("DeOp user", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto input_box = GUI::InputBox::construct("Enter nick:", "DeOp user", this);
|
||||||
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
|
m_client->handle_deop_user_action(window->channel().name(), input_box->text_value());
|
||||||
|
});
|
||||||
|
|
||||||
m_kick_user_action = GUI::Action::create("Kick user", [this](auto&) {
|
m_kick_user_action = GUI::Action::create("Kick user", [this](auto&) {
|
||||||
auto* window = m_client->current_window();
|
auto* window = m_client->current_window();
|
||||||
if (!window || window->type() != IRCWindow::Type::Channel) {
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
@ -172,6 +227,15 @@ void IRCAppWindow::setup_actions()
|
||||||
if (reason_box->exec() == GUI::InputBox::ExecOK)
|
if (reason_box->exec() == GUI::InputBox::ExecOK)
|
||||||
m_client->handle_kick_user_action(window->channel().name(), input_box->text_value(), reason_box->text_value().characters());
|
m_client->handle_kick_user_action(window->channel().name(), input_box->text_value(), reason_box->text_value().characters());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_cycle_channel_action = GUI::Action::create("Cycle channel", [this](auto&) {
|
||||||
|
auto* window = m_client->current_window();
|
||||||
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_client->handle_cycle_channel_action(window->channel().name());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCAppWindow::setup_menus()
|
void IRCAppWindow::setup_menus()
|
||||||
|
@ -198,8 +262,16 @@ void IRCAppWindow::setup_menus()
|
||||||
|
|
||||||
auto channel_menu = GUI::Menu::construct("Channel");
|
auto channel_menu = GUI::Menu::construct("Channel");
|
||||||
channel_menu->add_action(*m_change_topic_action);
|
channel_menu->add_action(*m_change_topic_action);
|
||||||
|
channel_menu->add_action(*m_invite_user_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_op_user_action);
|
||||||
|
channel_menu->add_action(*m_deop_user_action);
|
||||||
|
channel_menu->add_separator();
|
||||||
channel_menu->add_action(*m_kick_user_action);
|
channel_menu->add_action(*m_kick_user_action);
|
||||||
channel_menu->add_separator();
|
channel_menu->add_separator();
|
||||||
|
channel_menu->add_action(*m_cycle_channel_action);
|
||||||
channel_menu->add_action(*m_part_action);
|
channel_menu->add_action(*m_part_action);
|
||||||
menubar->add_menu(move(channel_menu));
|
menubar->add_menu(move(channel_menu));
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,16 @@ private:
|
||||||
RefPtr<GUI::Action> m_join_action;
|
RefPtr<GUI::Action> m_join_action;
|
||||||
RefPtr<GUI::Action> m_list_channels_action;
|
RefPtr<GUI::Action> m_list_channels_action;
|
||||||
RefPtr<GUI::Action> m_part_action;
|
RefPtr<GUI::Action> m_part_action;
|
||||||
|
RefPtr<GUI::Action> m_cycle_channel_action;
|
||||||
RefPtr<GUI::Action> m_whois_action;
|
RefPtr<GUI::Action> m_whois_action;
|
||||||
RefPtr<GUI::Action> m_open_query_action;
|
RefPtr<GUI::Action> m_open_query_action;
|
||||||
RefPtr<GUI::Action> m_close_query_action;
|
RefPtr<GUI::Action> m_close_query_action;
|
||||||
RefPtr<GUI::Action> m_change_nick_action;
|
RefPtr<GUI::Action> m_change_nick_action;
|
||||||
RefPtr<GUI::Action> m_change_topic_action;
|
RefPtr<GUI::Action> m_change_topic_action;
|
||||||
|
RefPtr<GUI::Action> m_invite_user_action;
|
||||||
|
RefPtr<GUI::Action> m_voice_user_action;
|
||||||
|
RefPtr<GUI::Action> m_devoice_user_action;
|
||||||
|
RefPtr<GUI::Action> m_op_user_action;
|
||||||
|
RefPtr<GUI::Action> m_deop_user_action;
|
||||||
RefPtr<GUI::Action> m_kick_user_action;
|
RefPtr<GUI::Action> m_kick_user_action;
|
||||||
};
|
};
|
||||||
|
|
|
@ -317,6 +317,31 @@ void IRCClient::send_topic(const String& channel_name, const String& text)
|
||||||
send(String::format("TOPIC %s :%s\r\n", channel_name.characters(), text.characters()));
|
send(String::format("TOPIC %s :%s\r\n", channel_name.characters(), text.characters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCClient::send_invite(const String& channel_name, const String& nick)
|
||||||
|
{
|
||||||
|
send(String::format("INVITE %s %s\r\n", nick.characters(), channel_name.characters()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::send_voice_user(const String& channel_name, const String& nick)
|
||||||
|
{
|
||||||
|
send(String::format("MODE %s +v %s\r\n", channel_name.characters(), nick.characters()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::send_devoice_user(const String& channel_name, const String& nick)
|
||||||
|
{
|
||||||
|
send(String::format("MODE %s -v %s\r\n", channel_name.characters(), nick.characters()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::send_op_user(const String& channel_name, const String& nick)
|
||||||
|
{
|
||||||
|
send(String::format("MODE %s +o %s\r\n", channel_name.characters(), nick.characters()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::send_deop_user(const String& channel_name, const String& nick)
|
||||||
|
{
|
||||||
|
send(String::format("MODE %s -o %s\r\n", channel_name.characters(), nick.characters()));
|
||||||
|
}
|
||||||
|
|
||||||
void IRCClient::send_kick(const String& channel_name, const String& nick, const String& comment)
|
void IRCClient::send_kick(const String& channel_name, const String& nick, const String& comment)
|
||||||
{
|
{
|
||||||
send(String::format("KICK %s %s :%s\r\n", channel_name.characters(), nick.characters(), comment.characters()));
|
send(String::format("KICK %s %s :%s\r\n", channel_name.characters(), nick.characters(), comment.characters()));
|
||||||
|
@ -815,6 +840,31 @@ void IRCClient::handle_change_topic_action(const String& channel, const String&
|
||||||
send_topic(channel, topic);
|
send_topic(channel, topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_invite_user_action(const String& channel, const String& nick)
|
||||||
|
{
|
||||||
|
send_invite(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_voice_user_action(const String& channel, const String& nick)
|
||||||
|
{
|
||||||
|
send_voice_user(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_devoice_user_action(const String& channel, const String& nick)
|
||||||
|
{
|
||||||
|
send_devoice_user(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_op_user_action(const String& channel, const String& nick)
|
||||||
|
{
|
||||||
|
send_op_user(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_deop_user_action(const String& channel, const String& nick)
|
||||||
|
{
|
||||||
|
send_deop_user(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
void IRCClient::handle_kick_user_action(const String& channel, const String& nick, const String& message)
|
void IRCClient::handle_kick_user_action(const String& channel, const String& nick, const String& message)
|
||||||
{
|
{
|
||||||
send_kick(channel, nick, message);
|
send_kick(channel, nick, message);
|
||||||
|
@ -836,6 +886,12 @@ void IRCClient::handle_part_action(const String& channel)
|
||||||
part_channel(channel);
|
part_channel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_cycle_channel_action(const String& channel)
|
||||||
|
{
|
||||||
|
part_channel(channel);
|
||||||
|
join_channel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
void IRCClient::did_part_from_channel(Badge<IRCChannel>, IRCChannel& channel)
|
void IRCClient::did_part_from_channel(Badge<IRCChannel>, IRCChannel& channel)
|
||||||
{
|
{
|
||||||
if (on_part_from_channel)
|
if (on_part_from_channel)
|
||||||
|
|
|
@ -100,13 +100,19 @@ public:
|
||||||
void handle_user_input_in_server(const String&);
|
void handle_user_input_in_server(const String&);
|
||||||
|
|
||||||
void handle_list_channels_action();
|
void handle_list_channels_action();
|
||||||
void handle_whois_action(const String&);
|
void handle_whois_action(const String& nick);
|
||||||
void handle_open_query_action(const String&);
|
void handle_open_query_action(const String&);
|
||||||
void handle_close_query_action(const String&);
|
void handle_close_query_action(const String&);
|
||||||
void handle_join_action(const String&);
|
void handle_join_action(const String& channel_name);
|
||||||
void handle_part_action(const String&);
|
void handle_part_action(const String& channel_name);
|
||||||
void handle_change_nick_action(const String&);
|
void handle_cycle_channel_action(const String& channel_name);
|
||||||
|
void handle_change_nick_action(const String& nick);
|
||||||
void handle_change_topic_action(const String& channel_name, const String&);
|
void handle_change_topic_action(const String& channel_name, const String&);
|
||||||
|
void handle_invite_user_action(const String& channel_name, const String& nick);
|
||||||
|
void handle_voice_user_action(const String& channel_name, const String& nick);
|
||||||
|
void handle_devoice_user_action(const String& channel_name, const String& nick);
|
||||||
|
void handle_op_user_action(const String& channel_name, const String& nick);
|
||||||
|
void handle_deop_user_action(const String& channel_name, const String& nick);
|
||||||
void handle_kick_user_action(const String& channel_name, const String& nick, const String&);
|
void handle_kick_user_action(const String& channel_name, const String& nick, const String&);
|
||||||
|
|
||||||
IRCQuery* query_with_name(const String&);
|
IRCQuery* query_with_name(const String&);
|
||||||
|
@ -137,6 +143,11 @@ private:
|
||||||
void send_privmsg(const String& target, const String&);
|
void send_privmsg(const String& target, const String&);
|
||||||
void send_notice(const String& target, const String&);
|
void send_notice(const String& target, const String&);
|
||||||
void send_topic(const String& channel_name, const String&);
|
void send_topic(const String& channel_name, const String&);
|
||||||
|
void send_invite(const String& channel_name, const String& nick);
|
||||||
|
void send_voice_user(const String& channel_name, const String& nick);
|
||||||
|
void send_devoice_user(const String& channel_name, const String& nick);
|
||||||
|
void send_op_user(const String& channel_name, const String& nick);
|
||||||
|
void send_deop_user(const String& channel_name, const String& nick);
|
||||||
void send_kick(const String& channel_name, const String& nick, const String&);
|
void send_kick(const String& channel_name, const String& nick, const String&);
|
||||||
void send_list();
|
void send_list();
|
||||||
void send_whois(const String&);
|
void send_whois(const String&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue