diff options
Diffstat (limited to 'src/components/channellist/channellisttree.cpp')
-rw-r--r-- | src/components/channellist/channellisttree.cpp | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 4816b42..8b313a3 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -29,6 +29,8 @@ ChannelListTree::ChannelListTree() #ifdef WITH_VOICE , m_menu_voice_channel_join("_Join", true) , m_menu_voice_channel_disconnect("_Disconnect", true) + , m_menu_voice_stage_join("_Join", true) + , m_menu_voice_stage_disconnect("_Disconnect", true) #endif , m_menu_dm_copy_id("_Copy ID", true) , m_menu_dm_close("") // changes depending on if group or not @@ -212,6 +214,19 @@ ChannelListTree::ChannelListTree() m_menu_voice_channel.append(m_menu_voice_channel_join); m_menu_voice_channel.append(m_menu_voice_channel_disconnect); m_menu_voice_channel.show_all(); + + m_menu_voice_stage_join.signal_activate().connect([this]() { + const auto id = static_cast<Snowflake>((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]); + m_signal_action_join_voice_channel.emit(id); + }); + + m_menu_voice_stage_disconnect.signal_activate().connect([this]() { + m_signal_action_disconnect_voice.emit(); + }); + + m_menu_voice_stage.append(m_menu_voice_stage_join); + m_menu_voice_stage.append(m_menu_voice_stage_disconnect); + m_menu_voice_stage.show_all(); #endif m_menu_dm_copy_id.signal_activate().connect([this] { @@ -356,8 +371,8 @@ int ChannelListTree::SortFunc(const Gtk::TreeModel::iterator &a, const Gtk::Tree if (a_type == RenderType::DMHeader) return -1; if (b_type == RenderType::DMHeader) return 1; #ifdef WITH_VOICE - if (a_type == RenderType::TextChannel && b_type == RenderType::VoiceChannel) return -1; - if (b_type == RenderType::TextChannel && a_type == RenderType::VoiceChannel) return 1; + if (a_type == RenderType::TextChannel && (b_type == RenderType::VoiceChannel || b_type == RenderType::VoiceStage)) return -1; + if (b_type == RenderType::TextChannel && (a_type == RenderType::VoiceChannel || a_type == RenderType::VoiceStage)) return 1; #endif return static_cast<int>(std::clamp(a_sort - b_sort, int64_t(-1), int64_t(1))); } @@ -624,6 +639,7 @@ void ChannelListTree::OnThreadListSync(const ThreadListSyncData &data) { #ifdef WITH_VOICE void ChannelListTree::OnVoiceUserConnect(Snowflake user_id, Snowflake channel_id) { auto parent_iter = GetIteratorForRowFromIDOfType(channel_id, RenderType::VoiceChannel); + if (!parent_iter) parent_iter = GetIteratorForRowFromIDOfType(channel_id, RenderType::VoiceStage); if (!parent_iter) parent_iter = GetIteratorForRowFromIDOfType(channel_id, RenderType::DM); if (!parent_iter) return; const auto user = Abaddon::Get().GetDiscordClient().GetUser(user_id); @@ -906,7 +922,7 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const const auto channel = discord.GetChannel(channel_.ID); if (!channel.has_value()) continue; #ifdef WITH_VOICE - if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS || channel->Type == ChannelType::GUILD_VOICE) { + if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS || channel->Type == ChannelType::GUILD_VOICE || channel->Type == ChannelType::GUILD_STAGE_VOICE) { #else if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS) { #endif @@ -953,10 +969,14 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); } #ifdef WITH_VOICE - else { + else if (channel.Type == ChannelType::GUILD_VOICE) { channel_row[m_columns.m_type] = RenderType::VoiceChannel; channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); add_voice_participants(channel, channel_row->children()); + } else if (channel.Type == ChannelType::GUILD_STAGE_VOICE) { + channel_row[m_columns.m_type] = RenderType::VoiceStage; + channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); + add_voice_participants(channel, channel_row->children()); } #endif channel_row[m_columns.m_id] = channel.ID; @@ -985,10 +1005,14 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); } #ifdef WITH_VOICE - else { + else if (channel.Type == ChannelType::GUILD_VOICE) { channel_row[m_columns.m_type] = RenderType::VoiceChannel; channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); add_voice_participants(channel, channel_row->children()); + } else if (channel.Type == ChannelType::GUILD_STAGE_VOICE) { + channel_row[m_columns.m_type] = RenderType::VoiceStage; + channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); + add_voice_participants(channel, channel_row->children()); } #endif channel_row[m_columns.m_id] = channel.ID; @@ -1333,6 +1357,10 @@ bool ChannelListTree::OnButtonPressEvent(GdkEventButton *ev) { OnVoiceChannelSubmenuPopup(); m_menu_voice_channel.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); break; + case RenderType::VoiceStage: + OnVoiceStageSubmenuPopup(); + m_menu_voice_stage.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); + break; #endif case RenderType::DM: { OnDMSubmenuPopup(); @@ -1440,6 +1468,20 @@ void ChannelListTree::OnVoiceChannelSubmenuPopup() { m_menu_voice_channel_disconnect.set_sensitive(false); } } + +void ChannelListTree::OnVoiceStageSubmenuPopup() { + const auto iter = m_model->get_iter(m_path_for_menu); + if (!iter) return; + const auto id = static_cast<Snowflake>((*iter)[m_columns.m_id]); + auto &discord = Abaddon::Get().GetDiscordClient(); + if (discord.IsVoiceConnected() || discord.IsVoiceConnecting()) { + m_menu_voice_stage_join.set_sensitive(false); + m_menu_voice_stage_disconnect.set_sensitive(discord.GetVoiceChannelID() == id); + } else { + m_menu_voice_stage_join.set_sensitive(true); + m_menu_voice_stage_disconnect.set_sensitive(false); + } +} #endif void ChannelListTree::OnDMSubmenuPopup() { |