mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-14 15:13:07 +00:00
LibGUI: Simplify submenu construction
The API for adding a submenu to a menu is now: auto& submenu = menu.add_submenu("Name"); submenu.add_action(my_action);
This commit is contained in:
parent
13dcd9a037
commit
f0cde70c18
Notes:
sideshowbarker
2024-07-19 07:11:54 +09:00
Author: https://github.com/awesomekling
Commit: f0cde70c18
9 changed files with 57 additions and 65 deletions
|
@ -90,10 +90,9 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
m_client.handle_whois_action(m_client.nick_without_prefix(nick.characters()));
|
||||
}));
|
||||
|
||||
RefPtr<GUI::Menu> m_context_control_menu = GUI::Menu::construct("Control");
|
||||
m_context_menu->add_submenu(*m_context_control_menu);
|
||||
auto& context_control_menu = m_context_menu->add_submenu("Control");
|
||||
|
||||
m_context_control_menu->add_action(GUI::Action::create("Voice", [&](const GUI::Action&) {
|
||||
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;
|
||||
|
@ -101,44 +100,44 @@ 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_control_menu->add_action(GUI::Action::create("DeVoice", [&](const GUI::Action&) {
|
||||
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_control_menu->add_action(GUI::Action::create("Hop", [&](const GUI::Action&) {
|
||||
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_control_menu->add_action(GUI::Action::create("DeHop", [&](const GUI::Action&) {
|
||||
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_control_menu->add_action(GUI::Action::create("Op", [&](const GUI::Action&) {
|
||||
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_control_menu->add_action(GUI::Action::create("DeOp", [&](const GUI::Action&) {
|
||||
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_control_menu->add_separator();
|
||||
context_control_menu.add_separator();
|
||||
|
||||
m_context_control_menu->add_action(GUI::Action::create("Kick", [&](const GUI::Action&) {
|
||||
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;
|
||||
|
@ -149,38 +148,37 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
m_client.handle_kick_user_action(m_name.characters(), m_client.nick_without_prefix(nick.characters()), input_box->text_value());
|
||||
}));
|
||||
|
||||
RefPtr<GUI::Menu> m_context_ctcp_menu = GUI::Menu::construct("CTCP");
|
||||
m_context_menu->add_submenu(*m_context_ctcp_menu);
|
||||
auto& context_ctcp_menu = m_context_menu->add_submenu("CTCP");
|
||||
|
||||
m_context_ctcp_menu->add_action(GUI::Action::create("User info", [&](const GUI::Action&) {
|
||||
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()), "USERINFO");
|
||||
}));
|
||||
|
||||
m_context_ctcp_menu->add_action(GUI::Action::create("Finger", [&](const GUI::Action&) {
|
||||
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()), "FINGER");
|
||||
}));
|
||||
|
||||
m_context_ctcp_menu->add_action(GUI::Action::create("Time", [&](const GUI::Action&) {
|
||||
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()), "TIME");
|
||||
}));
|
||||
|
||||
m_context_ctcp_menu->add_action(GUI::Action::create("Version", [&](const GUI::Action&) {
|
||||
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()), "VERSION");
|
||||
}));
|
||||
|
||||
m_context_ctcp_menu->add_action(GUI::Action::create("Client info", [&](const GUI::Action&) {
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue