mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
parent
fc0e89edf3
commit
355b80680d
5 changed files with 31 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "messages/image.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "singletons/windowmanager.hpp"
|
||||
|
@ -209,6 +210,15 @@ const QString &Image::getName() const
|
|||
return this->name;
|
||||
}
|
||||
|
||||
const QString &Image::getCopyString() const
|
||||
{
|
||||
if (this->copyString.isEmpty()) {
|
||||
return this->name;
|
||||
}
|
||||
|
||||
return this->copyString;
|
||||
}
|
||||
|
||||
const QString &Image::getTooltip() const
|
||||
{
|
||||
return this->tooltip;
|
||||
|
@ -258,5 +268,10 @@ int Image::getScaledHeight() const
|
|||
getApp()->settings->emoteScale.getValue());
|
||||
}
|
||||
|
||||
void Image::setCopyString(const QString &newCopyString)
|
||||
{
|
||||
this->copyString = newCopyString;
|
||||
}
|
||||
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
qreal getScale() const;
|
||||
const QString &getUrl() const;
|
||||
const QString &getName() const;
|
||||
const QString &getCopyString() const;
|
||||
const QString &getTooltip() const;
|
||||
const QMargins &getMargin() const;
|
||||
bool isAnimated() const;
|
||||
|
@ -34,6 +35,8 @@ public:
|
|||
int getHeight() const;
|
||||
int getScaledHeight() const;
|
||||
|
||||
void setCopyString(const QString &newCopyString);
|
||||
|
||||
private:
|
||||
struct FrameData {
|
||||
QPixmap *image;
|
||||
|
@ -50,6 +53,7 @@ private:
|
|||
|
||||
QString url;
|
||||
QString name;
|
||||
QString copyString;
|
||||
QString tooltip;
|
||||
bool animated = false;
|
||||
QMargins margin;
|
||||
|
|
|
@ -74,7 +74,7 @@ ImageLayoutElement::ImageLayoutElement(MessageElement &_creator, Image *_image,
|
|||
|
||||
void ImageLayoutElement::addCopyTextToString(QString &str, int from, int to) const
|
||||
{
|
||||
str += this->image->getName();
|
||||
str += this->image->getCopyString();
|
||||
|
||||
if (this->hasTrailingSpace()) {
|
||||
str += " ";
|
||||
|
|
|
@ -85,7 +85,8 @@ EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags f
|
|||
{
|
||||
if (_data.isValid()) {
|
||||
this->setTooltip(data.image1x->getTooltip());
|
||||
this->textElement.reset(new TextElement(_data.image1x->getName(), MessageElement::Misc));
|
||||
this->textElement.reset(
|
||||
new TextElement(_data.image1x->getCopyString(), MessageElement::Misc));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,13 +120,22 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo
|
|||
|
||||
return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] {
|
||||
util::EmoteData newEmoteData;
|
||||
auto cleanCode = cleanUpCode(emoteName);
|
||||
cleanCode.replace("<", "<");
|
||||
cleanCode.replace(">", ">");
|
||||
newEmoteData.image1x = new messages::Image(getEmoteLink(id, "1.0"), 1, emoteName,
|
||||
_emoteName + "<br/>Twitch Emote 1x");
|
||||
newEmoteData.image1x->setCopyString(cleanCode);
|
||||
|
||||
newEmoteData.image2x = new messages::Image(getEmoteLink(id, "2.0"), .5, emoteName,
|
||||
_emoteName + "<br/>Twitch Emote 2x");
|
||||
newEmoteData.image2x->setCopyString(cleanCode);
|
||||
|
||||
newEmoteData.image3x = new messages::Image(getEmoteLink(id, "3.0"), .25, emoteName,
|
||||
_emoteName + "<br/>Twitch Emote 3x");
|
||||
|
||||
newEmoteData.image3x->setCopyString(cleanCode);
|
||||
|
||||
return newEmoteData;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue