Add categories to emoji viewer (#6598)

Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
Reviewed-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
Jade
2025-12-06 15:40:11 +02:00
committed by GitHub
parent 8c9c0ce10f
commit bd026b3551
4 changed files with 48 additions and 1 deletions
+1
View File
@@ -15,6 +15,7 @@
- Minor: Added an API to get the current Twitch account in plugins. (#6554)
- Minor: Added options to close multiple visible tabs. (#6515, #6619)
- Minor: Added a setting to show the stream title in live messages. (#6572)
- Minor: Add categories to the emoji viewer. (#6598)
- Minor: Added broadcaster-only `/poll`, `/cancelpoll`, and `/endpoll` commands. (#6583, #6605)
- Minor: Added broadcaster-only `/prediction` command to start a prediction. (#6583)
- Bugfix: Expose the "Extra extension IDs" setting on non-Windows systems too. (#6509)
+6
View File
@@ -62,6 +62,8 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
rj::getSafe(unparsedEmoji, "has_img_twitter", capabilities.twitter);
rj::getSafe(unparsedEmoji, "has_img_facebook", capabilities.facebook);
rj::getSafe(unparsedEmoji, "category", emojiData->category);
if (capabilities.apple)
{
emojiData->capabilities.set(EmojiData::Capability::Apple);
@@ -219,6 +221,10 @@ void Emojis::loadEmojis()
parseEmoji(variationEmojiData, variation,
emojiData->shortCodes[0] + "_" + toneName);
// NOTE: Emoji variations do not have a category.
// We have to manually inherit it from the original emojiData.
variationEmojiData->category = emojiData->category;
this->emojiShortCodeToEmoji_.insert(
variationEmojiData->shortCodes[0], variationEmojiData);
this->shortCodes.push_back(variationEmojiData->shortCodes[0]);
+2
View File
@@ -31,6 +31,8 @@ struct EmojiData {
// i.e. thinking
std::vector<QString> shortCodes;
QString category;
using Capability = EmojiStyle;
using Capabilities = FlagsEnum<Capability>;
+39 -1
View File
@@ -1,6 +1,7 @@
#include "widgets/dialogs/EmotePopup.hpp"
#include "Application.hpp"
#include "common/enums/MessageContext.hpp"
#include "common/QLogging.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/emotes/EmoteController.hpp"
@@ -164,11 +165,48 @@ void addTwitchEmoteSets(const std::shared_ptr<const EmoteMap> &local,
void loadEmojis(ChannelView &view, const std::vector<EmojiPtr> &emojiMap)
{
static auto emoteCategoryMap = [&] {
std::map<QString, std::vector<EmojiPtr>> emoteCatMap;
for (const auto &emoji : emojiMap)
{
auto cat = emoteCatMap.find(emoji->category);
if (cat != emoteCatMap.end())
{
auto &vec = cat->second;
vec.push_back(emoji);
}
else
{
emoteCatMap.emplace(emoji->category,
std::vector<EmojiPtr>{emoji});
}
}
return emoteCatMap;
}();
ChannelPtr emojiChannel(new Channel("", Channel::Type::None));
// set the channel first to make sure the scrollbar is at the top
view.setChannel(emojiChannel);
emojiChannel->addMessage(makeEmojiMessage(emojiMap),
for (auto &it : emoteCategoryMap)
{
// Skip the Component category for now.
if (it.first == "Component")
{
continue;
}
emojiChannel->addMessage(makeTitleMessage(it.first),
MessageContext::Original);
emojiChannel->addMessage(makeEmojiMessage(it.second),
MessageContext::Original);
}
// Add the Component category at the bottom of the picker.
emojiChannel->addMessage(makeTitleMessage("Component"),
MessageContext::Original);
emojiChannel->addMessage(makeEmojiMessage(emoteCategoryMap["Component"]),
MessageContext::Original);
}