diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-06-22 04:25:56 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-06-22 04:25:56 -0400 |
commit | e65174f5aab55fe3917dd52f97b1b00a07d30d38 (patch) | |
tree | fed590caf0440fd47b72a51e21e692fe703860bd /src/components/channellist/channellisttree.cpp | |
parent | 3dc8fa8e65bdd1bd45dfa0171a06dfbb448baf0d (diff) | |
parent | 7af15b326df5a638b24c5e637d5f37396276f906 (diff) | |
download | abaddon-portaudio-e65174f5aab55fe3917dd52f97b1b00a07d30d38.tar.gz abaddon-portaudio-e65174f5aab55fe3917dd52f97b1b00a07d30d38.zip |
Merge branch 'master' into stages
Diffstat (limited to 'src/components/channellist/channellisttree.cpp')
-rw-r--r-- | src/components/channellist/channellisttree.cpp | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 9233941..9adee61 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -26,12 +26,12 @@ ChannelListTree::ChannelListTree() , m_menu_channel_open_tab("Open in New _Tab", true) , m_menu_dm_open_tab("Open in New _Tab", true) #endif -#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_voice_channel_mark_as_read("Mark as _Read", true) + , m_menu_voice_open_chat("Open _Chat", true) , m_menu_dm_copy_id("_Copy ID", true) , m_menu_dm_close("") // changes depending on if group or not #ifdef WITH_VOICE @@ -210,11 +210,24 @@ ChannelListTree::ChannelListTree() m_menu_voice_channel_disconnect.signal_activate().connect([this]() { m_signal_action_disconnect_voice.emit(); }); +#endif + + m_menu_voice_channel_mark_as_read.signal_activate().connect([this]() { + Abaddon::Get().GetDiscordClient().MarkChannelAsRead(static_cast<Snowflake>((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]), NOOP_CALLBACK); + }); + + m_menu_voice_open_chat.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_channel_item_select.emit(id); + }); m_menu_voice_channel.append(m_menu_voice_channel_join); m_menu_voice_channel.append(m_menu_voice_channel_disconnect); + m_menu_voice_channel.append(m_menu_voice_channel_mark_as_read); + m_menu_voice_channel.append(m_menu_voice_open_chat); m_menu_voice_channel.show_all(); +#ifdef WITH_VOICE 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); @@ -223,11 +236,11 @@ ChannelListTree::ChannelListTree() m_menu_voice_stage_disconnect.signal_activate().connect([this]() { m_signal_action_disconnect_voice.emit(); }); +#endif 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] { Gtk::Clipboard::get()->set_text(std::to_string((*m_model->get_iter(m_path_for_menu))[m_columns.m_id])); @@ -370,10 +383,8 @@ int ChannelListTree::SortFunc(const Gtk::TreeModel::iterator &a, const Gtk::Tree const int64_t b_sort = (*b)[m_columns.m_sort]; 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 || 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))); } @@ -505,7 +516,9 @@ void ChannelListTree::UpdateChannel(Snowflake id) { auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id); if (!iter || !channel.has_value()) return; if (channel->Type == ChannelType::GUILD_CATEGORY) return UpdateChannelCategory(*channel); - if (!channel->IsText()) return; + // TODO: theres like 4 different fucking ways of checking if somethin g is text or voice can i fix that How stupid . + // fun fact clang-format is indenting me right now i wonder why ,,,,,,,,,,, + if (!channel->IsText() && channel->Type != ChannelType::GUILD_VOICE) return; // refresh stuff that might have changed const bool is_orphan_TMP = !channel->ParentID.has_value(); @@ -527,7 +540,7 @@ void ChannelListTree::UpdateChannel(Snowflake id) { void ChannelListTree::UpdateCreateChannel(const ChannelData &channel) { if (channel.Type == ChannelType::GUILD_CATEGORY) return (void)UpdateCreateChannelCategory(channel); if (channel.Type == ChannelType::DM || channel.Type == ChannelType::GROUP_DM) return UpdateCreateDMChannel(channel); - if (channel.Type != ChannelType::GUILD_TEXT && channel.Type != ChannelType::GUILD_NEWS) return; + if (channel.Type != ChannelType::GUILD_TEXT && channel.Type != ChannelType::GUILD_NEWS && channel.Type != ChannelType::GUILD_VOICE) return; Gtk::TreeRow channel_row; bool orphan; @@ -540,7 +553,7 @@ void ChannelListTree::UpdateCreateChannel(const ChannelData &channel) { auto iter = GetIteratorForGuildFromID(*channel.GuildID); channel_row = *m_model->append(iter->children()); } - channel_row[m_columns.m_type] = RenderType::TextChannel; + channel_row[m_columns.m_type] = IsTextChannel(channel.Type) ? RenderType::TextChannel : RenderType::VoiceChannel; channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -636,7 +649,6 @@ 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); @@ -659,7 +671,6 @@ void ChannelListTree::OnVoiceStateSet(Snowflake user_id, Snowflake channel_id, V (*iter)[m_columns.m_voice_flags] = flags; } } -#endif void ChannelListTree::DeleteThreadRow(Snowflake id) { auto iter = GetIteratorForRowFromID(id); @@ -921,11 +932,7 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const for (const auto &channel_ : *guild.Channels) { 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 || channel->Type == ChannelType::GUILD_STAGE_VOICE) { -#else - if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS) { -#endif if (channel->ParentID.has_value()) categories[*channel->ParentID].push_back(*channel); else @@ -952,7 +959,6 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const } }; -#ifdef WITH_VOICE auto add_voice_participants = [this, &discord](const ChannelData &channel, const Gtk::TreeNodeChildren &root) { for (auto user_id : discord.GetUsersInVoiceChannel(channel.ID)) { if (const auto user = discord.GetUser(user_id); user.has_value()) { @@ -960,25 +966,21 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const } } }; -#endif for (const auto &channel : orphan_channels) { auto channel_row = *m_model->append(guild_row.children()); if (IsTextChannel(channel.Type)) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); - } -#ifdef WITH_VOICE - 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()); + } else { + 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()); } -#endif channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_sort] = *channel.Position + OrphanChannelSortOffset; channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -1003,18 +1005,15 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const if (IsTextChannel(channel.Type)) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); - } -#ifdef WITH_VOICE - 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()); + } else { + 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()); } -#endif channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_sort] = *channel.Position; channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -1052,7 +1051,6 @@ Gtk::TreeModel::iterator ChannelListTree::CreateThreadRow(const Gtk::TreeNodeChi return thread_iter; } -#ifdef WITH_VOICE Gtk::TreeModel::iterator ChannelListTree::CreateVoiceParticipantRow(const UserData &user, const Gtk::TreeNodeChildren &parent) { auto row = *m_model->append(parent); row[m_columns.m_type] = RenderType::VoiceParticipant; @@ -1074,7 +1072,6 @@ Gtk::TreeModel::iterator ChannelListTree::CreateVoiceParticipantRow(const UserDa return row; } -#endif void ChannelListTree::UpdateChannelCategory(const ChannelData &channel) { auto iter = GetIteratorForRowFromID(channel.ID); @@ -1182,8 +1179,11 @@ bool ChannelListTree::SelectionFunc(const Glib::RefPtr<Gtk::TreeModel> &model, c } } - auto type = (*model->get_iter(path))[m_columns.m_type]; - return type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread; + const auto type = (*model->get_iter(path))[m_columns.m_type]; + const auto id = static_cast<Snowflake>((*model->get_iter(path))[m_columns.m_id]); + // todo maybe just keep this last check? + if (type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread || (id == m_active_channel)) return true; + return is_currently_selected; } void ChannelListTree::AddPrivateChannels() { @@ -1215,13 +1215,11 @@ void ChannelListTree::AddPrivateChannels() { row[m_columns.m_icon] = img.GetPlaceholder(DMIconSize); row[m_columns.m_expanded] = true; -#ifdef WITH_VOICE for (auto user_id : discord.GetUsersInVoiceChannel(dm_id)) { if (const auto user = discord.GetUser(user_id); user.has_value()) { CreateVoiceParticipantRow(*user, row->children()); } } -#endif SetDMChannelIcon(iter, *dm); } @@ -1352,7 +1350,6 @@ bool ChannelListTree::OnButtonPressEvent(GdkEventButton *ev) { OnChannelSubmenuPopup(); m_menu_channel.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); break; -#ifdef WITH_VOICE case RenderType::VoiceChannel: OnVoiceChannelSubmenuPopup(); m_menu_voice_channel.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); @@ -1361,7 +1358,6 @@ bool ChannelListTree::OnButtonPressEvent(GdkEventButton *ev) { OnVoiceStageSubmenuPopup(); m_menu_voice_stage.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); break; -#endif case RenderType::DM: { OnDMSubmenuPopup(); const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(static_cast<Snowflake>(row[m_columns.m_id])); @@ -1454,8 +1450,8 @@ void ChannelListTree::OnChannelSubmenuPopup() { m_menu_channel_toggle_mute.set_label("Mute"); } -#ifdef WITH_VOICE void ChannelListTree::OnVoiceChannelSubmenuPopup() { +#ifdef WITH_VOICE 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]); @@ -1467,9 +1463,14 @@ void ChannelListTree::OnVoiceChannelSubmenuPopup() { m_menu_voice_channel_join.set_sensitive(true); m_menu_voice_channel_disconnect.set_sensitive(false); } +#else + m_menu_voice_channel_join.set_sensitive(false); + m_menu_voice_channel_disconnect.set_sensitive(false); +#endif } void ChannelListTree::OnVoiceStageSubmenuPopup() { +#ifdef WITH_VOICE 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]); @@ -1481,8 +1482,10 @@ void ChannelListTree::OnVoiceStageSubmenuPopup() { m_menu_voice_stage_join.set_sensitive(true); m_menu_voice_stage_disconnect.set_sensitive(false); } -} #endif + m_menu_voice_stage_join.set_sensitive(false); + m_menu_voice_stage_disconnect.set_sensitive(false); +} void ChannelListTree::OnDMSubmenuPopup() { auto iter = m_model->get_iter(m_path_for_menu); |