Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing context menu entries to emote popup #2670

Merged
merged 4 commits into from Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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