2017-09-16 16:20:10 +02:00
|
|
|
#include "emotepopup.hpp"
|
2017-09-16 00:05:06 +02:00
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
|
|
|
#include "messages/messagebuilder.hpp"
|
|
|
|
#include "twitch/twitchchannel.hpp"
|
|
|
|
|
|
|
|
using namespace chatterino::twitch;
|
|
|
|
using namespace chatterino::messages;
|
|
|
|
|
2017-09-15 17:23:49 +02:00
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
|
2017-09-17 02:13:57 +02:00
|
|
|
EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager,
|
|
|
|
WindowManager &windowManager)
|
2017-09-16 00:05:06 +02:00
|
|
|
: BaseWidget(colorScheme, 0)
|
|
|
|
, emoteManager(emoteManager)
|
2017-09-15 17:23:49 +02:00
|
|
|
{
|
2017-09-23 18:37:51 +02:00
|
|
|
this->initAsWindow();
|
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
|
|
|
this->setLayout(layout);
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
2017-09-17 02:13:57 +02:00
|
|
|
view = new ChannelView(windowManager, this);
|
2017-09-16 00:05:06 +02:00
|
|
|
layout->addWidget(view);
|
2017-09-15 17:23:49 +02:00
|
|
|
}
|
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
2017-09-15 17:23:49 +02:00
|
|
|
{
|
2017-09-16 00:05:06 +02:00
|
|
|
TwitchChannel *channel = dynamic_cast<TwitchChannel *>(_channel.get());
|
|
|
|
|
|
|
|
if (channel == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> emoteChannel(new Channel);
|
|
|
|
|
|
|
|
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
|
|
|
// TITLE
|
|
|
|
messages::MessageBuilder builder1;
|
|
|
|
|
|
|
|
builder1.appendWord(
|
2017-09-21 00:54:10 +02:00
|
|
|
Word(title, Word::Type::Text, MessageColor(MessageColor::Text), QString(), QString()));
|
2017-09-16 00:05:06 +02:00
|
|
|
|
|
|
|
builder1.getMessage()->centered = true;
|
|
|
|
emoteChannel->addMessage(builder1.getMessage());
|
|
|
|
|
|
|
|
// EMOTES
|
|
|
|
messages::MessageBuilder builder2;
|
|
|
|
builder2.getMessage()->centered = true;
|
|
|
|
|
|
|
|
map.each([&](const QString &key, const EmoteData &value) {
|
|
|
|
builder2.appendWord(Word(value.image, Word::Type::AlwaysShow, key, emoteDesc,
|
|
|
|
Link(Link::Type::InsertText, key)));
|
|
|
|
});
|
|
|
|
|
|
|
|
emoteChannel->addMessage(builder2.getMessage());
|
|
|
|
};
|
|
|
|
|
|
|
|
addEmotes(this->emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes",
|
|
|
|
"BetterTTV Global Emote");
|
|
|
|
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
|
|
|
"BetterTTV Channel Emote");
|
|
|
|
addEmotes(this->emoteManager.ffzGlobalEmotes, "FrankerFaceZ Global Emotes",
|
|
|
|
"FrankerFaceZ Global Emote");
|
|
|
|
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
|
|
|
|
"FrankerFaceZ Channel Emote");
|
2017-09-15 17:23:49 +02:00
|
|
|
|
2017-09-16 16:20:10 +02:00
|
|
|
// addEmotes(this->emoteManager.getEmojis(), "Emojis", "Emoji");
|
|
|
|
|
|
|
|
this->view->setChannel(emoteChannel);
|
2017-09-15 17:23:49 +02:00
|
|
|
}
|
2017-09-23 18:37:51 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|