diff --git a/src/messages/messagebuilder.cpp b/src/messages/messagebuilder.cpp index 2116ac76e..fa1a381e1 100644 --- a/src/messages/messagebuilder.cpp +++ b/src/messages/messagebuilder.cpp @@ -18,7 +18,7 @@ MessagePtr MessageBuilder::getMessage() return this->message; } -void MessageBuilder::appendElement(MessageElement *element) +void MessageBuilder::append(MessageElement *element) { this->message->addElement(element); } @@ -39,7 +39,7 @@ void MessageBuilder::setHighlight(bool value) void MessageBuilder::appendTimestamp(const QTime &time) { - this->appendElement(new TimestampElement(time)); + this->append(new TimestampElement(time)); } QString MessageBuilder::matchLink(const QString &string) diff --git a/src/messages/messagebuilder.hpp b/src/messages/messagebuilder.hpp index 2965cc0c3..3b9b550d3 100644 --- a/src/messages/messagebuilder.hpp +++ b/src/messages/messagebuilder.hpp @@ -9,35 +9,29 @@ namespace chatterino { namespace messages { -struct MessageBuilder -{ +struct MessageBuilder { public: MessageBuilder(); MessagePtr getMessage(); void setHighlight(bool value); - void appendElement(MessageElement *element); + void append(MessageElement *element); + void appendTimestamp(); + void appendTimestamp(const QTime &time); + QString matchLink(const QString &string); - // typename std::enable_if::value, T>::type - - template + template ::value>::type> T *emplace(Args &&... args) { static_assert(std::is_base_of::value, "T must extend MessageElement"); T *element = new T(std::forward(args)...); - this->appendElement(element); + this->append(element); return element; } - void appendTimestamp(); - void appendTimestamp(const QTime &time); - - QString matchLink(const QString &string); - - QString originalMessage; - protected: MessagePtr message; }; diff --git a/src/messages/messagecolor.hpp b/src/messages/messagecolor.hpp index 0e7b54af3..6919e201c 100644 --- a/src/messages/messagecolor.hpp +++ b/src/messages/messagecolor.hpp @@ -7,9 +7,7 @@ namespace chatterino { namespace messages { -struct MessageColor -{ -public: +struct MessageColor { enum Type { Custom, Text, Link, System }; MessageColor(const QColor &color); diff --git a/src/twitch/twitchmessagebuilder.hpp b/src/twitch/twitchmessagebuilder.hpp index 7b6ecde8f..16035a714 100644 --- a/src/twitch/twitchmessagebuilder.hpp +++ b/src/twitch/twitchmessagebuilder.hpp @@ -45,6 +45,7 @@ private: QString roomID; QColor usernameColor; + QString originalMessage; void parseMessageID(); void parseRoomID(); diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index e67f1b67c..eac36dec1 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -56,7 +56,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) // TITLE messages::MessageBuilder builder1; - builder1.appendElement(new TextElement(title, MessageElement::Text)); + builder1.append(new TextElement(title, MessageElement::Text)); builder1.getMessage()->flags &= Message::Centered; emoteChannel->addMessage(builder1.getMessage()); @@ -67,7 +67,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) builder2.getMessage()->flags &= Message::DisableCompactEmotes; map.each([&](const QString &key, const util::EmoteData &value) { - builder2.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) + builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) ->setLink(Link(Link::InsertText, key))); }); @@ -96,7 +96,7 @@ void EmotePopup::loadEmojis() // title messages::MessageBuilder builder1; - builder1.appendElement(new TextElement("emojis", MessageElement::Text)); + builder1.append(new TextElement("emojis", MessageElement::Text)); builder1.getMessage()->flags &= Message::Centered; emojiChannel->addMessage(builder1.getMessage()); @@ -106,7 +106,7 @@ void EmotePopup::loadEmojis() builder.getMessage()->flags &= Message::DisableCompactEmotes; emojis.each([this, &builder](const QString &key, const util::EmoteData &value) { - builder.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) + builder.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) ->setLink(Link(Link::Type::InsertText, key))); }); emojiChannel->addMessage(builder.getMessage());