Navigation Menu

Skip to content

Commit

Permalink
Added missing context menu entries to emote popup (#2670)
Browse files Browse the repository at this point in the history
  • Loading branch information
zneix committed Apr 24, 2021
1 parent 24a2d8a commit 1ef2f17
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## Unversioned

- Bugfix: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670)
- Bugfix: Fixed visual glitch with smooth scrolling. (#2084)

## 2.3.0
Expand Down
64 changes: 36 additions & 28 deletions src/widgets/dialogs/EmotePopup.cpp
Expand Up @@ -27,35 +27,36 @@ namespace {
builder->flags.set(MessageFlag::Centered);
return builder.release();
}
auto makeEmoteMessage(const EmoteMap &map)
auto makeEmoteMessage(const EmoteMap &map,
const MessageElementFlag &emoteFlag)
{
MessageBuilder builder;
builder->flags.set(MessageFlag::Centered);
builder->flags.set(MessageFlag::DisableCompactEmotes);

if (!map.empty())
{
std::vector<std::pair<EmoteName, EmotePtr>> vec(map.begin(),
map.end());
std::sort(vec.begin(), vec.end(),
[](const std::pair<EmoteName, EmotePtr> &l,
const std::pair<EmoteName, EmotePtr> &r) {
return CompletionModel::compareStrings(
l.first.string, r.first.string);
});
for (const auto &emote : vec)
{
builder
.emplace<EmoteElement>(emote.second,
MessageElementFlag::AlwaysShow)
->setLink(Link(Link::InsertText, emote.first.string));
}
}
else
if (map.empty())
{
builder.emplace<TextElement>("no emotes available",
MessageElementFlag::Text,
MessageColor::System);
return builder.release();
}

std::vector<std::pair<EmoteName, EmotePtr>> vec(map.begin(), map.end());
std::sort(vec.begin(), vec.end(),
[](const std::pair<EmoteName, EmotePtr> &l,
const std::pair<EmoteName, EmotePtr> &r) {
return CompletionModel::compareStrings(l.first.string,
r.first.string);
});
for (const auto &emote : vec)
{
builder
.emplace<EmoteElement>(
emote.second,
MessageElementFlags{MessageElementFlag::AlwaysShow,
emoteFlag})
->setLink(Link(Link::InsertText, emote.first.string));
}

return builder.release();
Expand Down Expand Up @@ -92,7 +93,8 @@ namespace {
.emplace<EmoteElement>(
getApp()->emotes->twitch.getOrCreateEmote(emote.id,
emote.name),
MessageElementFlag::AlwaysShow)
MessageElementFlags{MessageElementFlag::AlwaysShow,
MessageElementFlag::TwitchEmote})
->setLink(Link(Link::InsertText, emote.name.string));
}

Expand Down Expand Up @@ -206,9 +208,10 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
return;

auto addEmotes = [&](Channel &channel, const EmoteMap &map,
const QString &title) {
const QString &title,
const MessageElementFlag &emoteFlag) {
channel.addMessage(makeTitleMessage(title));
channel.addMessage(makeEmoteMessage(map));
channel.addMessage(makeEmoteMessage(map, emoteFlag));
};

auto subChannel = std::make_shared<Channel>("", Channel::Type::None);
Expand All @@ -222,13 +225,15 @@ void EmotePopup::loadChannel(ChannelPtr _channel)

// global
addEmotes(*globalChannel, *twitchChannel->globalBttv().emotes(),
"BetterTTV");
"BetterTTV", MessageElementFlag::BttvEmote);
addEmotes(*globalChannel, *twitchChannel->globalFfz().emotes(),
"FrankerFaceZ");
"FrankerFaceZ", MessageElementFlag::FfzEmote);

// channel
addEmotes(*channelChannel, *twitchChannel->bttvEmotes(), "BetterTTV");
addEmotes(*channelChannel, *twitchChannel->ffzEmotes(), "FrankerFaceZ");
addEmotes(*channelChannel, *twitchChannel->bttvEmotes(), "BetterTTV",
MessageElementFlag::BttvEmote);
addEmotes(*channelChannel, *twitchChannel->ffzEmotes(), "FrankerFaceZ",
MessageElementFlag::FfzEmote);

this->globalEmotesView_->setChannel(globalChannel);
this->subEmotesView_->setChannel(subChannel);
Expand Down Expand Up @@ -259,7 +264,10 @@ void EmotePopup::loadEmojis()

emojis.each([&builder](const auto &key, const auto &value) {
builder
.emplace<EmoteElement>(value->emote, MessageElementFlag::AlwaysShow)
.emplace<EmoteElement>(
value->emote,
MessageElementFlags{MessageElementFlag::AlwaysShow,
MessageElementFlag::EmojiAll})
->setLink(
Link(Link::Type::InsertText, ":" + value->shortCodes[0] + ":"));
});
Expand Down

0 comments on commit 1ef2f17

Please sign in to comment.