From 6f0620ead64056c8ab4dbfa370cd5bf9796e7a4e Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 19 Dec 2017 03:18:00 +0100 Subject: [PATCH] added emojis to the emote popup --- src/widgets/basewidget.cpp | 2 +- src/widgets/emotepopup.cpp | 46 ++++++++++++++++++++++++++++++++------ src/widgets/emotepopup.hpp | 4 +++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index 76c9121ce..c043db4d5 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -22,7 +22,7 @@ BaseWidget::BaseWidget(ColorScheme &_colorScheme, QWidget *parent) BaseWidget::BaseWidget(BaseWidget *parent) : QWidget(parent) - , colorScheme(parent->colorScheme) + , colorScheme(*ColorScheme::instance) // , windowManager(parent->windowManager) { this->init(); diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index 6ea249fbb..5257d8cf8 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -1,6 +1,7 @@ #include "emotepopup.hpp" #include +#include #include "messages/messagebuilder.hpp" #include "twitch/twitchchannel.hpp" @@ -16,12 +17,18 @@ EmotePopup::EmotePopup(ColorScheme &colorScheme) { this->initAsWindow(); - QHBoxLayout *layout = new QHBoxLayout(this); - this->setLayout(layout); - layout->setMargin(0); + this->viewEmotes = new ChannelView(); + this->viewEmojis = new ChannelView(); - this->view = new ChannelView(this); - layout->addWidget(this->view); + this->setLayout(new QVBoxLayout(this)); + + QTabWidget *tabs = new QTabWidget(this); + this->layout()->addWidget(tabs); + this->layout()->setMargin(0); + tabs->addTab(this->viewEmotes, "Emotes"); + tabs->addTab(this->viewEmojis, "Emojis"); + + this->loadEmojis(); } void EmotePopup::loadChannel(std::shared_ptr _channel) @@ -66,9 +73,34 @@ void EmotePopup::loadChannel(std::shared_ptr _channel) addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes", "FrankerFaceZ Channel Emote"); - // addEmotes(emoteManager.getEmojis(), "Emojis", "Emoji"); + this->viewEmotes->setChannel(emoteChannel); +} - this->view->setChannel(emoteChannel); +void EmotePopup::loadEmojis() +{ + EmoteMap &emojis = EmoteManager::getInstance().getEmojis(); + + std::shared_ptr emojiChannel(new Channel("")); + + // title + messages::MessageBuilder builder1; + + builder1.appendWord( + Word("emojis", Word::Type::Text, MessageColor(MessageColor::Text), QString(), QString())); + + builder1.getMessage()->centered = true; + emojiChannel->addMessage(builder1.getMessage()); + + // emojis + messages::MessageBuilder builder; + builder.getMessage()->centered = true; + emojis.each([this, &builder](const QString &key, const EmoteData &value) { + builder.appendWord(Word(value.image, Word::Type::AlwaysShow, key, "emoji", + Link(Link::Type::InsertText, key))); + }); + emojiChannel->addMessage(builder.getMessage()); + + this->viewEmojis->setChannel(emojiChannel); } } // namespace widgets diff --git a/src/widgets/emotepopup.hpp b/src/widgets/emotepopup.hpp index 282f1ddc5..fa1f5dcbb 100644 --- a/src/widgets/emotepopup.hpp +++ b/src/widgets/emotepopup.hpp @@ -13,9 +13,11 @@ public: explicit EmotePopup(ColorScheme &); void loadChannel(std::shared_ptr channel); + void loadEmojis(); private: - ChannelView *view; + ChannelView *viewEmotes; + ChannelView *viewEmojis; }; } // namespace widgets