feat: include more data when copying messages as JSON (#5600)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "providers/links/LinkInfo.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
@@ -16,6 +17,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QJsonObject;
|
||||
|
||||
namespace chatterino {
|
||||
class Channel;
|
||||
struct MessageLayoutContainer;
|
||||
@@ -183,6 +186,8 @@ public:
|
||||
virtual void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) = 0;
|
||||
|
||||
virtual QJsonObject toJson() const;
|
||||
|
||||
protected:
|
||||
MessageElement(MessageElementFlags flags);
|
||||
bool trailingSpace = true;
|
||||
@@ -202,6 +207,8 @@ public:
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
ImagePtr image_;
|
||||
};
|
||||
@@ -216,6 +223,8 @@ public:
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
ImagePtr image_;
|
||||
int padding_;
|
||||
@@ -234,6 +243,8 @@ public:
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
QStringList words_;
|
||||
|
||||
@@ -253,6 +264,8 @@ public:
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
MessageColor color_;
|
||||
FontStyle style_;
|
||||
@@ -294,6 +307,8 @@ public:
|
||||
return &this->linkInfo_;
|
||||
}
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
LinkInfo linkInfo_;
|
||||
// these are implicitly shared
|
||||
@@ -328,6 +343,8 @@ public:
|
||||
MessageElement *setLink(const Link &link) override;
|
||||
Link getLink() const override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The color of the element in case the "Colorize @usernames" is disabled
|
||||
@@ -355,6 +372,8 @@ public:
|
||||
MessageElementFlags flags_) override;
|
||||
EmotePtr getEmote() const;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
virtual MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size);
|
||||
@@ -390,6 +409,8 @@ public:
|
||||
std::vector<Emote> getUniqueEmotes() const;
|
||||
const std::vector<QString> &getEmoteTooltips() const;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
MessageLayoutElement *makeImageLayoutElement(
|
||||
const std::vector<ImagePtr> &image, const std::vector<QSize> &sizes,
|
||||
@@ -416,6 +437,8 @@ public:
|
||||
|
||||
EmotePtr getEmote() const;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
virtual MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size);
|
||||
@@ -429,6 +452,8 @@ class ModBadgeElement : public BadgeElement
|
||||
public:
|
||||
ModBadgeElement(const EmotePtr &data, MessageElementFlags flags_);
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size) override;
|
||||
@@ -439,6 +464,8 @@ class VipBadgeElement : public BadgeElement
|
||||
public:
|
||||
VipBadgeElement(const EmotePtr &data, MessageElementFlags flags_);
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size) override;
|
||||
@@ -450,6 +477,8 @@ public:
|
||||
FfzBadgeElement(const EmotePtr &data, MessageElementFlags flags_,
|
||||
QColor color_);
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
protected:
|
||||
MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size) override;
|
||||
@@ -460,7 +489,8 @@ protected:
|
||||
class TimestampElement : public MessageElement
|
||||
{
|
||||
public:
|
||||
TimestampElement(QTime time_ = QTime::currentTime());
|
||||
TimestampElement();
|
||||
TimestampElement(QTime time_);
|
||||
~TimestampElement() override = default;
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
@@ -468,6 +498,8 @@ public:
|
||||
|
||||
TextElement *formatTime(const QTime &time);
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
QTime time_;
|
||||
std::unique_ptr<TextElement> element_;
|
||||
@@ -483,6 +515,8 @@ public:
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
|
||||
// Forces a linebreak
|
||||
@@ -493,6 +527,8 @@ public:
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
|
||||
// Image element which will pick the quality of the image based on ui scale
|
||||
@@ -504,6 +540,8 @@ public:
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
ImageSet images_;
|
||||
};
|
||||
@@ -515,6 +553,13 @@ public:
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<chatterino::MessageElementFlag> {
|
||||
static constexpr bool is_flags = true; // NOLINT(readability-identifier-*)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user