added emojis to the emote popup

This commit is contained in:
fourtf
2017-12-19 03:18:00 +01:00
parent 14e80d5012
commit 6f0620ead6
3 changed files with 43 additions and 9 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ BaseWidget::BaseWidget(ColorScheme &_colorScheme, QWidget *parent)
BaseWidget::BaseWidget(BaseWidget *parent) BaseWidget::BaseWidget(BaseWidget *parent)
: QWidget(parent) : QWidget(parent)
, colorScheme(parent->colorScheme) , colorScheme(*ColorScheme::instance)
// , windowManager(parent->windowManager) // , windowManager(parent->windowManager)
{ {
this->init(); this->init();
+39 -7
View File
@@ -1,6 +1,7 @@
#include "emotepopup.hpp" #include "emotepopup.hpp"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QTabWidget>
#include "messages/messagebuilder.hpp" #include "messages/messagebuilder.hpp"
#include "twitch/twitchchannel.hpp" #include "twitch/twitchchannel.hpp"
@@ -16,12 +17,18 @@ EmotePopup::EmotePopup(ColorScheme &colorScheme)
{ {
this->initAsWindow(); this->initAsWindow();
QHBoxLayout *layout = new QHBoxLayout(this); this->viewEmotes = new ChannelView();
this->setLayout(layout); this->viewEmojis = new ChannelView();
layout->setMargin(0);
this->view = new ChannelView(this); this->setLayout(new QVBoxLayout(this));
layout->addWidget(this->view);
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> _channel) void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
@@ -66,9 +73,34 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes", addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
"FrankerFaceZ Channel Emote"); "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<Channel> 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 } // namespace widgets
+3 -1
View File
@@ -13,9 +13,11 @@ public:
explicit EmotePopup(ColorScheme &); explicit EmotePopup(ColorScheme &);
void loadChannel(std::shared_ptr<Channel> channel); void loadChannel(std::shared_ptr<Channel> channel);
void loadEmojis();
private: private:
ChannelView *view; ChannelView *viewEmotes;
ChannelView *viewEmojis;
}; };
} // namespace widgets } // namespace widgets