Allow each layered image to retain its own flags (#4460)

This fixes an issue where context-menu items for zero-width emotes displayed the wrong provider.
This commit is contained in:
nerix
2023-03-19 11:26:30 +01:00
committed by GitHub
parent 0acbc0d2c3
commit a777a227d4
6 changed files with 58 additions and 29 deletions
+11 -5
View File
@@ -187,6 +187,7 @@ public:
const Link &getLink() const;
bool hasTrailingSpace() const;
MessageElementFlags getFlags() const;
void addFlags(MessageElementFlags flags);
MessageElement *updateLink();
virtual void addToContainer(MessageLayoutContainer &container,
@@ -325,19 +326,24 @@ private:
class LayeredEmoteElement : public MessageElement
{
public:
struct Emote {
EmotePtr ptr;
MessageElementFlags flags;
};
LayeredEmoteElement(
std::vector<EmotePtr> &&emotes, MessageElementFlags flags,
std::vector<Emote> &&emotes, MessageElementFlags flags,
const MessageColor &textElementColor = MessageColor::Text);
void addEmoteLayer(const EmotePtr &emote);
void addEmoteLayer(const Emote &emote);
void addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags) override;
// Returns a concatenation of each emote layer's cleaned copy string
QString getCleanCopyString() const;
const std::vector<EmotePtr> &getEmotes() const;
std::vector<EmotePtr> getUniqueEmotes() const;
const std::vector<Emote> &getEmotes() const;
std::vector<Emote> getUniqueEmotes() const;
const std::vector<QString> &getEmoteTooltips() const;
private:
@@ -349,7 +355,7 @@ private:
void updateTooltips();
std::vector<ImagePtr> getLoadedImages(float scale);
std::vector<EmotePtr> emotes_;
std::vector<Emote> emotes_;
std::vector<QString> emoteTooltips_;
std::unique_ptr<TextElement> textElement_;