mirror-chatterino2/src/messages/message.hpp

59 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
2017-01-05 16:07:20 +01:00
#include "messages/messageelement.hpp"
2018-01-28 15:28:02 +01:00
#include "util/flagsenum.hpp"
2018-01-06 03:48:56 +01:00
#include "widgets/helper/scrollbarhighlight.hpp"
#include <cinttypes>
2017-04-12 17:46:44 +02:00
#include <memory>
2017-09-24 18:43:24 +02:00
#include <vector>
2017-01-11 01:08:20 +01:00
#include <QTime>
namespace chatterino {
2017-04-14 17:52:22 +02:00
namespace messages {
2018-01-28 03:29:42 +01:00
struct Message {
enum MessageFlags : uint16_t {
2018-01-05 23:14:55 +01:00
None = 0,
System = (1 << 0),
Timeout = (1 << 1),
Highlighted = (1 << 2),
DoNotTriggerNotification = (1 << 3), // disable notification sound
Centered = (1 << 4),
Disabled = (1 << 5),
DisableCompactEmotes = (1 << 6),
Collapsed = (1 << 7),
DisconnectedMessage = (1 << 8),
2018-01-05 23:14:55 +01:00
};
2018-01-28 03:29:42 +01:00
util::FlagsEnum<MessageFlags> flags;
QTime parseTime;
QString id;
QString searchText;
QString loginName;
QString displayName;
QString localizedName;
QString timeoutUser;
// Messages should not be added after the message is done initializing.
void addElement(MessageElement *element);
const std::vector<std::unique_ptr<MessageElement>> &getElements() const;
// Scrollbar
2018-01-06 03:48:56 +01:00
widgets::ScrollbarHighlight getScrollBarHighlight() const;
2017-01-05 20:49:33 +01:00
2017-01-05 16:07:20 +01:00
private:
2018-01-28 03:29:42 +01:00
std::vector<std::unique_ptr<MessageElement>> elements;
2017-01-07 20:43:55 +01:00
2018-01-28 03:29:42 +01:00
public:
static std::shared_ptr<Message> createSystemMessage(const QString &text);
2017-01-07 20:43:55 +01:00
2018-01-28 03:29:42 +01:00
static std::shared_ptr<Message> createTimeoutMessage(const QString &username,
const QString &durationInSeconds,
const QString &reason, bool multipleTimes);
2017-01-05 16:07:20 +01:00
};
2017-01-28 20:29:02 +01:00
2018-01-28 03:29:42 +01:00
typedef std::shared_ptr<Message> MessagePtr;
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino